1import { 2 useTracking 3} from "/admin/node_modules/.strapi/vite/deps/chunk-CHHAHVGY.js?v=d15f9e09"; 4import { 5 AssetSource, 6 AssetType, 7 DocType, 8 PERMISSIONS, 9 byte_size_default, 10 getTrad, 11 pluginId, 12 sortOptions, 13 tableHeaders, 14 typeFromMime, 15 urlSchema 16} from "/admin/node_modules/.strapi/vite/deps/chunk-RYRCH4HT.js?v=d15f9e09"; 17import { 18 useDrag, 19 useDrop 20} from "/admin/node_modules/.strapi/vite/deps/chunk-6X4VQDZK.js?v=d15f9e09"; 21import { 22 useMutation, 23 useQuery, 24 useQueryClient 25} from "/admin/node_modules/.strapi/vite/deps/chunk-7YGG4WL2.js?v=d15f9e09"; 26import { 27 useFetchClient 28} from "/admin/node_modules/.strapi/vite/deps/chunk-DHUTWCDY.js?v=d15f9e09"; 29import { 30 _arrayLikeToArray, 31 _classCallCheck, 32 _createClass, 33 _createSuper, 34 _inherits, 35 _unsupportedIterableToArray, 36 intervalToDuration 37} from "/admin/node_modules/.strapi/vite/deps/chunk-W67CYUYQ.js?v=d15f9e09"; 38import { 39 require_isEmpty 40} from "/admin/node_modules/.strapi/vite/deps/chunk-BDHMN2HB.js?v=d15f9e09"; 41import { 42 Form, 43 Formik 44} from "/admin/node_modules/.strapi/vite/deps/chunk-CUFQ37WH.js?v=d15f9e09"; 45import { 46 ConfirmDialog 47} from "/admin/node_modules/.strapi/vite/deps/chunk-PQ56O6IT.js?v=d15f9e09"; 48import { 49 useClipboard 50} from "/admin/node_modules/.strapi/vite/deps/chunk-RZTJCV3X.js?v=d15f9e09"; 51import { 52 parseISO 53} from "/admin/node_modules/.strapi/vite/deps/chunk-C5HVKIIE.js?v=d15f9e09"; 54import { 55 Layouts 56} from "/admin/node_modules/.strapi/vite/deps/chunk-U65IFX6E.js?v=d15f9e09"; 57import { 58 useRBAC 59} from "/admin/node_modules/.strapi/vite/deps/chunk-ESYATGOB.js?v=d15f9e09"; 60import { 61 require_isEqual 62} from "/admin/node_modules/.strapi/vite/deps/chunk-HOHMMZY4.js?v=d15f9e09"; 63import { 64 ForwardRef$m 65} from "/admin/node_modules/.strapi/vite/deps/chunk-GS5WUXY5.js?v=d15f9e09"; 66import { 67 useQueryParams 68} from "/admin/node_modules/.strapi/vite/deps/chunk-OBBKKGYS.js?v=d15f9e09"; 69import { 70 useNotification 71} from "/admin/node_modules/.strapi/vite/deps/chunk-QJWF7P4Z.js?v=d15f9e09"; 72import { 73 adminApi, 74 require_lib 75} from "/admin/node_modules/.strapi/vite/deps/chunk-I5GSXQM4.js?v=d15f9e09"; 76import { 77 _defineProperty, 78 _objectSpread2, 79 _typeof, 80 useDispatch 81} from "/admin/node_modules/.strapi/vite/deps/chunk-AH3YIZJN.js?v=d15f9e09"; 82import { 83 require_hoist_non_react_statics_cjs, 84 useIntl 85} from "/admin/node_modules/.strapi/vite/deps/chunk-2EC2GH3P.js?v=d15f9e09"; 86import { 87 Link, 88 NavLink, 89 useLocation, 90 useNavigate 91} from "/admin/node_modules/.strapi/vite/deps/chunk-KHAUUTAT.js?v=d15f9e09"; 92import { 93 create4 as create, 94 create5 as create2, 95 create6 as create3 96} from "/admin/node_modules/.strapi/vite/deps/chunk-X5VCMDGA.js?v=d15f9e09"; 97import { 98 Avatar, 99 Badge, 100 Box, 101 Breadcrumbs, 102 Button, 103 Card, 104 CardActionImpl, 105 CardAsset, 106 CardBadge, 107 CardBody, 108 CardCheckbox, 109 CardContent, 110 CardHeader, 111 CardSubtitle, 112 CardTimer, 113 CardTitle, 114 CheckboxImpl, 115 Crumb, 116 CrumbLink, 117 CrumbSimpleMenu, 118 DateTimePicker, 119 Dialog, 120 Divider, 121 Field, 122 Flex, 123 FocusTrap, 124 ForwardRef$1H, 125 ForwardRef$1K, 126 ForwardRef$1L, 127 ForwardRef$1M, 128 ForwardRef$1O, 129 ForwardRef$1P, 130 ForwardRef$1T, 131 ForwardRef$1f, 132 ForwardRef$20, 133 ForwardRef$26, 134 ForwardRef$27, 135 ForwardRef$2i, 136 ForwardRef$2l, 137 ForwardRef$2o, 138 ForwardRef$2u, 139 ForwardRef$2v, 140 ForwardRef$4, 141 ForwardRef$F, 142 ForwardRef$G, 143 ForwardRef$N, 144 ForwardRef$b, 145 Grid, 146 IconButton, 147 KeyboardNavigable, 148 Loader, 149 Menu, 150 MenuItem, 151 Modal, 152 Popover, 153 ProgressBar, 154 SingleSelect, 155 SingleSelectOption, 156 Table, 157 Tabs, 158 Tag, 159 Tbody, 160 Td, 161 TextInput, 162 Textarea, 163 Th, 164 Thead, 165 TooltipImpl, 166 Tr, 167 Typography, 168 VisuallyHidden, 169 _extends, 170 _objectWithoutPropertiesLoose, 171 autoUpdate, 172 useNotifyAT 173} from "/admin/node_modules/.strapi/vite/deps/chunk-NQ2VHHSG.js?v=d15f9e09"; 174import { 175 require_jsx_runtime 176} from "/admin/node_modules/.strapi/vite/deps/chunk-P5ARCO6G.js?v=d15f9e09"; 177import { 178 dt, 179 ft, 180 nt 181} from "/admin/node_modules/.strapi/vite/deps/chunk-4CO2ZYT2.js?v=d15f9e09"; 182import { 183 require_react_dom 184} from "/admin/node_modules/.strapi/vite/deps/chunk-2VJDPHGP.js?v=d15f9e09"; 185import { 186 require_react 187} from "/admin/node_modules/.strapi/vite/deps/chunk-VB5JOH6R.js?v=d15f9e09"; 188import { 189 __toESM 190} from "/admin/node_modules/.strapi/vite/deps/chunk-X6GFWOGJ.js?v=d15f9e09"; 191
vendor: 2,330 bytes, lines 192-285
192// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/hooks/useAssets.mjs 193var React = __toESM(require_react(), 1); 194var useAssets = ({ skipWhen = false, query = {} } = {}) => { 195 var _a3; 196 const { formatMessage } = useIntl(); 197 const { toggleNotification } = useNotification(); 198 const { notifyStatus } = useNotifyAT(); 199 const { get } = useFetchClient(); 200 const { folderPath, _q, ...paramsExceptFolderAndQ } = query; 201 let params; 202 if (_q) { 203 params = { 204 ...paramsExceptFolderAndQ, 205 _q: encodeURIComponent(_q) 206 }; 207 } else { 208 params = { 209 ...paramsExceptFolderAndQ, 210 filters: { 211 $and: [ 212 ...((_a3 = paramsExceptFolderAndQ == null ? void 0 : paramsExceptFolderAndQ.filters) == null ? void 0 : _a3.$and) ?? [], 213 { 214 folderPath: { 215 $eq: folderPath ?? "/" 216 } 217 } 218 ] 219 } 220 }; 221 } 222 const { data, error, isLoading } = useQuery([ 223 pluginId, 224 "assets", 225 params 226 ], async () => { 227 const { data: data2 } = await get("/upload/files", { 228 params 229 }); 230 return data2; 231 }, { 232 enabled: !skipWhen, 233 staleTime: 0, 234 cacheTime: 0, 235 select(data2) { 236 if ((data2 == null ? void 0 : data2.results) && Array.isArray(data2.results)) { 237 return { 238 ...data2, 239 results: data2.results.filter((asset) => asset.name).map((asset) => ({ 240 ...asset, 241 /** 242 * Mime and ext cannot be null in the front-end because 243 * we expect them to be strings and use the `includes` method. 244 */ 245 mime: asset.mime ?? "", 246 ext: asset.ext ?? "" 247 })) 248 }; 249 } 250 return data2; 251 } 252 }); 253 React.useEffect(() => { 254 if (data) { 255 notifyStatus(formatMessage({ 256 id: "list.asset.at.finished", 257 defaultMessage: "The assets have finished loading." 258 })); 259 } 260 }, [ 261 data, 262 formatMessage, 263 notifyStatus 264 ]); 265 React.useEffect(() => { 266 if (error) { 267 toggleNotification({ 268 type: "danger", 269 message: formatMessage({ 270 id: "notification.error" 271 }) 272 }); 273 } 274 }, [ 275 error, 276 formatMessage, 277 toggleNotification 278 ]); 279 return { 280 data, 281 error, 282 isLoading 283 }; 284}; 285
vendor: 1,870 bytes, lines 286-365
286// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/hooks/useFolders.mjs 287var React2 = __toESM(require_react(), 1); 288var import_qs = __toESM(require_lib(), 1); 289var useFolders = ({ enabled = true, query = {} } = {}) => { 290 var _a3; 291 const { formatMessage } = useIntl(); 292 const { toggleNotification } = useNotification(); 293 const { notifyStatus } = useNotifyAT(); 294 const { folder, _q, ...paramsExceptFolderAndQ } = query; 295 const { get } = useFetchClient(); 296 let params; 297 if (_q) { 298 params = { 299 ...paramsExceptFolderAndQ, 300 pagination: { 301 pageSize: -1 302 }, 303 _q 304 }; 305 } else { 306 params = { 307 ...paramsExceptFolderAndQ, 308 pagination: { 309 pageSize: -1 310 }, 311 filters: { 312 $and: [ 313 ...((_a3 = paramsExceptFolderAndQ == null ? void 0 : paramsExceptFolderAndQ.filters) == null ? void 0 : _a3.$and) ?? [], 314 { 315 parent: { 316 id: folder ?? { 317 $null: true 318 } 319 } 320 } 321 ] 322 } 323 }; 324 } 325 const { data, error, isLoading } = useQuery([ 326 pluginId, 327 "folders", 328 (0, import_qs.stringify)(params) 329 ], async () => { 330 const { data: { data: data2 } } = await get("/upload/folders", { 331 params 332 }); 333 return data2; 334 }, { 335 enabled, 336 staleTime: 0, 337 cacheTime: 0, 338 onError() { 339 toggleNotification({ 340 type: "danger", 341 message: formatMessage({ 342 id: "notification.error" 343 }) 344 }); 345 } 346 }); 347 React2.useEffect(() => { 348 if (data) { 349 notifyStatus(formatMessage({ 350 id: "list.asset.at.finished", 351 defaultMessage: "The folders have finished loading." 352 })); 353 } 354 }, [ 355 data, 356 formatMessage, 357 notifyStatus 358 ]); 359 return { 360 data, 361 error, 362 isLoading 363 }; 364}; 365
vendor: 372 bytes, lines 366-375
366// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/hooks/useMediaLibraryPermissions.mjs 367var { main: _main, ...restPermissions } = PERMISSIONS; 368var useMediaLibraryPermissions = () => { 369 const { allowedActions, isLoading } = useRBAC(restPermissions); 370 return { 371 ...allowedActions, 372 isLoading 373 }; 374}; 375
vendor: 2,104 bytes, lines 376-437
376// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/hooks/useSelectionState.mjs 377var React3 = __toESM(require_react(), 1); 378var useSelectionState = (keys, initialValue) => { 379 const [selections, setSelections] = React3.useState(initialValue); 380 const selectOne = (selection) => { 381 const index2 = selections.findIndex((currentSelection) => keys.every((key) => currentSelection[key] === selection[key])); 382 if (index2 > -1) { 383 setSelections((prevSelected) => [ 384 ...prevSelected.slice(0, index2), 385 ...prevSelected.slice(index2 + 1) 386 ]); 387 } else { 388 setSelections((prevSelected) => [ 389 ...prevSelected, 390 selection 391 ]); 392 } 393 }; 394 const selectAll = (nextSelections) => { 395 if (selections.length > 0) { 396 setSelections([]); 397 } else { 398 setSelections(nextSelections); 399 } 400 }; 401 const selectOnly = (nextSelection) => { 402 const index2 = selections.findIndex((currentSelection) => keys.every((key) => currentSelection[key] === nextSelection[key])); 403 if (index2 > -1) { 404 setSelections([]); 405 } else { 406 setSelections([ 407 nextSelection 408 ]); 409 } 410 }; 411 const selectMultiple = (nextSelections) => { 412 setSelections((currSelections) => [ 413 // already selected items 414 ...currSelections, 415 // filter out already selected items from nextSelections 416 ...nextSelections.filter((nextSelection) => currSelections.findIndex((currentSelection) => keys.every((key) => currentSelection[key] === nextSelection[key])) === -1) 417 ]); 418 }; 419 const deselectMultiple = (nextSelections) => { 420 setSelections((currSelections) => [ 421 // filter out items in currSelections that are in nextSelections 422 ...currSelections.filter((currentSelection) => nextSelections.findIndex((nextSelection) => keys.every((key) => currentSelection[key] === nextSelection[key])) === -1) 423 ]); 424 }; 425 return [ 426 selections, 427 { 428 selectOne, 429 selectAll, 430 selectOnly, 431 selectMultiple, 432 deselectMultiple, 433 setSelections 434 } 435 ]; 436}; 437
vendor: 537 bytes, lines 438-453
438// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/utils/containsAssetFilter.mjs 439var containsMimeTypeFilter = (query) => { 440 var _a3; 441 const filters = (_a3 = query == null ? void 0 : query.filters) == null ? void 0 : _a3.$and; 442 if (!filters) { 443 return false; 444 } 445 const result = filters.find((filter) => { 446 return Object.keys(filter).includes("mime"); 447 }); 448 return !!result; 449}; 450var containsAssetFilter = (query) => { 451 return containsMimeTypeFilter(query); 452}; 453
vendor: 322 bytes, lines 454-458
454// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EditAssetDialog/EditAssetContent.mjs 455var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1); 456var React16 = __toESM(require_react(), 1); 457var import_isEqual = __toESM(require_isEqual(), 1); 458
vendor: 2,218 bytes, lines 459-537
459// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/hooks/useEditAsset.mjs 460var React4 = __toESM(require_react(), 1); 461var import_qs2 = __toESM(require_lib(), 1); 462var editAssetRequest = (asset, file, signal, onProgress, post) => { 463 const endpoint2 = `/${pluginId}?id=${asset.id}`; 464 const formData = new FormData(); 465 if (file) { 466 formData.append("files", file); 467 } 468 formData.append("fileInfo", JSON.stringify({ 469 alternativeText: asset.alternativeText, 470 caption: asset.caption, 471 folder: asset.folder, 472 name: asset.name 473 })); 474 return post(endpoint2, formData, { 475 signal 476 }).then((res) => res.data); 477}; 478var useEditAsset = () => { 479 const [progress, setProgress] = React4.useState(0); 480 const { formatMessage } = useIntl(); 481 const { toggleNotification } = useNotification(); 482 const queryClient = useQueryClient(); 483 const abortController = new AbortController(); 484 const signal = abortController.signal; 485 const { post } = useFetchClient(); 486 const mutation = useMutation(({ asset, file }) => editAssetRequest(asset, file, signal, setProgress, post), { 487 onSuccess() { 488 queryClient.refetchQueries([ 489 pluginId, 490 "assets" 491 ], { 492 active: true 493 }); 494 queryClient.refetchQueries([ 495 pluginId, 496 "asset-count" 497 ], { 498 active: true 499 }); 500 queryClient.refetchQueries([ 501 pluginId, 502 "folders" 503 ], { 504 active: true 505 }); 506 }, 507 onError(reason) { 508 var _a3; 509 if (((_a3 = reason == null ? void 0 : reason.response) == null ? void 0 : _a3.status) === 403) { 510 toggleNotification({ 511 type: "info", 512 message: formatMessage({ 513 id: getTrad("permissions.not-allowed.update") 514 }) 515 }); 516 } else { 517 toggleNotification({ 518 type: "danger", 519 message: reason == null ? void 0 : reason.message 520 }); 521 } 522 } 523 }); 524 const editAsset = (asset, file) => mutation.mutateAsync({ 525 asset, 526 file 527 }); 528 const cancel = () => abortController.abort(); 529 return { 530 ...mutation, 531 cancel, 532 editAsset, 533 progress, 534 status: mutation.status 535 }; 536}; 537
vendor: 190 bytes, lines 538-540
538// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/hooks/useFolderStructure.mjs 539var import_qs3 = __toESM(require_lib(), 1); 540
vendor: 460 bytes, lines 541-549
541// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/hooks/utils/renameKeys.mjs 542var recursiveRenameKeys = (obj, fn) => Object.fromEntries(Object.entries(obj).map(([key, value]) => { 543 const getValue = (v2) => typeof v2 === "object" && v2 !== null ? recursiveRenameKeys(v2, fn) : v2; 544 return [ 545 fn(key), 546 Array.isArray(value) ? value.map((val) => getValue(val)) : getValue(value) 547 ]; 548})); 549
vendor: 1,055 bytes, lines 550-587
550// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/hooks/useFolderStructure.mjs 551var FIELD_MAPPING = { 552 name: "label", 553 id: "value" 554}; 555var useFolderStructure = ({ enabled = true } = {}) => { 556 const { formatMessage } = useIntl(); 557 const { get } = useFetchClient(); 558 const fetchFolderStructure = async () => { 559 const { data: { data: data2 } } = await get("/upload/folder-structure"); 560 const children = data2.map((f) => recursiveRenameKeys(f, (key) => (FIELD_MAPPING == null ? void 0 : FIELD_MAPPING[key]) ?? key)); 561 return [ 562 { 563 value: null, 564 label: formatMessage({ 565 id: getTrad("form.input.label.folder-location-default-label"), 566 defaultMessage: "Media Library" 567 }), 568 children 569 } 570 ]; 571 }; 572 const { data, error, isLoading } = useQuery([ 573 pluginId, 574 "folder", 575 "structure" 576 ], fetchFolderStructure, { 577 enabled, 578 staleTime: 0, 579 cacheTime: 0 580 }); 581 return { 582 data, 583 error, 584 isLoading 585 }; 586}; 587
vendor: 422 bytes, lines 588-601
588// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/utils/findRecursiveFolderByValue.mjs 589function findRecursiveFolderByValue(data, value) { 590 let result; 591 function iter(a2) { 592 if (a2.value === value) { 593 result = a2; 594 return true; 595 } 596 return Array.isArray(a2.children) && a2.children.some(iter); 597 } 598 data.some(iter); 599 return result; 600} 601
vendor: 459 bytes, lines 602-613
602// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/utils/formatBytes.mjs 603function formatBytes(receivedBytes, decimals = 0) { 604 const realBytes = typeof receivedBytes === "string" ? Number(receivedBytes) : receivedBytes; 605 const { value, unit } = byte_size_default(realBytes * 1e3, { 606 precision: decimals 607 }); 608 if (!unit) { 609 return "0B"; 610 } 611 return `${value}${unit.toUpperCase()}`; 612} 613
vendor: 209 bytes, lines 614-616
614// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EditAssetDialog/EditAssetContent.mjs 615var import_qs9 = __toESM(require_lib(), 1); 616
vendor: 224 bytes, lines 617-619
617// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/utils/getFileExtension.mjs 618var getFileExtension = (ext) => ext && ext[0] === "." ? ext.substring(1) : ext; 619
vendor: 1,233 bytes, lines 620-658
620// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/ContextInfo/ContextInfo.mjs 621var import_jsx_runtime = __toESM(require_jsx_runtime(), 1); 622var ContextInfo = ({ blocks }) => { 623 return (0, import_jsx_runtime.jsx)(Box, { 624 hasRadius: true, 625 paddingLeft: 6, 626 paddingRight: 6, 627 paddingTop: 4, 628 paddingBottom: 4, 629 background: "neutral100", 630 children: (0, import_jsx_runtime.jsx)(Grid.Root, { 631 gap: 4, 632 children: blocks.map(({ label, value }) => (0, import_jsx_runtime.jsx)(Grid.Item, { 633 col: 6, 634 xs: 12, 635 direction: "column", 636 alignItems: "stretch", 637 children: (0, import_jsx_runtime.jsxs)(Flex, { 638 direction: "column", 639 alignItems: "stretch", 640 gap: 1, 641 children: [ 642 (0, import_jsx_runtime.jsx)(Typography, { 643 variant: "sigma", 644 textColor: "neutral600", 645 children: label 646 }), 647 (0, import_jsx_runtime.jsx)(Typography, { 648 variant: "pi", 649 textColor: "neutral700", 650 children: value 651 }) 652 ] 653 }) 654 }, label)) 655 }) 656 }); 657}; 658
vendor: 258 bytes, lines 659-662
659// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/SelectTree/SelectTree.mjs 660var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1); 661var React10 = __toESM(require_react(), 1); 662
vendor: 175 bytes, lines 663-667
663// node_modules/.pnpm/@[email protected]/node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js 664function _arrayWithHoles(r10) { 665 if (Array.isArray(r10)) return r10; 666} 667
vendor: 802 bytes, lines 668-690
668// node_modules/.pnpm/@[email protected]/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js 669function _iterableToArrayLimit(r10, l2) { 670 var t2 = null == r10 ? null : "undefined" != typeof Symbol && r10[Symbol.iterator] || r10["@@iterator"]; 671 if (null != t2) { 672 var e, n2, i3, u3, a2 = [], f = true, o2 = false; 673 try { 674 if (i3 = (t2 = t2.call(r10)).next, 0 === l2) { 675 if (Object(t2) !== t2) return; 676 f = false; 677 } else for (; !(f = (e = i3.call(t2)).done) && (a2.push(e.value), a2.length !== l2); f = true) ; 678 } catch (r11) { 679 o2 = true, n2 = r11; 680 } finally { 681 try { 682 if (!f && null != t2["return"] && (u3 = t2["return"](), Object(u3) !== u3)) return; 683 } finally { 684 if (o2) throw n2; 685 } 686 } 687 return a2; 688 } 689} 690
vendor: 300 bytes, lines 691-695
691// node_modules/.pnpm/@[email protected]/node_modules/@babel/runtime/helpers/esm/nonIterableRest.js 692function _nonIterableRest() { 693 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 694} 695
vendor: 263 bytes, lines 696-700
696// node_modules/.pnpm/@[email protected]/node_modules/@babel/runtime/helpers/esm/slicedToArray.js 697function _slicedToArray(r10, e) { 698 return _arrayWithHoles(r10) || _iterableToArrayLimit(r10, e) || _unsupportedIterableToArray(r10, e) || _nonIterableRest(); 699} 700
vendor: 482 bytes, lines 701-711
701// node_modules/.pnpm/@[email protected]/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js 702function _objectWithoutProperties(e, t2) { 703 if (null == e) return {}; 704 var o2, r10, i3 = _objectWithoutPropertiesLoose(e, t2); 705 if (Object.getOwnPropertySymbols) { 706 var n2 = Object.getOwnPropertySymbols(e); 707 for (r10 = 0; r10 < n2.length; r10++) o2 = n2[r10], -1 === t2.indexOf(o2) && {}.propertyIsEnumerable.call(e, o2) && (i3[o2] = e[o2]); 708 } 709 return i3; 710} 711
vendor: 3,118 bytes, lines 712-758
712// node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/react-select/dist/useStateManager-7e1e8489.esm.js 713var import_react = __toESM(require_react()); 714var _excluded = ["defaultInputValue", "defaultMenuIsOpen", "defaultValue", "inputValue", "menuIsOpen", "onChange", "onInputChange", "onMenuClose", "onMenuOpen", "value"]; 715function useStateManager(_ref3) { 716 var _ref$defaultInputValu = _ref3.defaultInputValue, defaultInputValue = _ref$defaultInputValu === void 0 ? "" : _ref$defaultInputValu, _ref$defaultMenuIsOpe = _ref3.defaultMenuIsOpen, defaultMenuIsOpen = _ref$defaultMenuIsOpe === void 0 ? false : _ref$defaultMenuIsOpe, _ref$defaultValue = _ref3.defaultValue, defaultValue = _ref$defaultValue === void 0 ? null : _ref$defaultValue, propsInputValue = _ref3.inputValue, propsMenuIsOpen = _ref3.menuIsOpen, propsOnChange = _ref3.onChange, propsOnInputChange = _ref3.onInputChange, propsOnMenuClose = _ref3.onMenuClose, propsOnMenuOpen = _ref3.onMenuOpen, propsValue = _ref3.value, restSelectProps = _objectWithoutProperties(_ref3, _excluded); 717 var _useState = (0, import_react.useState)(propsInputValue !== void 0 ? propsInputValue : defaultInputValue), _useState2 = _slicedToArray(_useState, 2), stateInputValue = _useState2[0], setStateInputValue = _useState2[1]; 718 var _useState3 = (0, import_react.useState)(propsMenuIsOpen !== void 0 ? propsMenuIsOpen : defaultMenuIsOpen), _useState4 = _slicedToArray(_useState3, 2), stateMenuIsOpen = _useState4[0], setStateMenuIsOpen = _useState4[1]; 719 var _useState5 = (0, import_react.useState)(propsValue !== void 0 ? propsValue : defaultValue), _useState6 = _slicedToArray(_useState5, 2), stateValue = _useState6[0], setStateValue = _useState6[1]; 720 var onChange2 = (0, import_react.useCallback)(function(value2, actionMeta) { 721 if (typeof propsOnChange === "function") { 722 propsOnChange(value2, actionMeta); 723 } 724 setStateValue(value2); 725 }, [propsOnChange]); 726 var onInputChange = (0, import_react.useCallback)(function(value2, actionMeta) { 727 var newValue; 728 if (typeof propsOnInputChange === "function") { 729 newValue = propsOnInputChange(value2, actionMeta); 730 } 731 setStateInputValue(newValue !== void 0 ? newValue : value2); 732 }, [propsOnInputChange]); 733 var onMenuOpen = (0, import_react.useCallback)(function() { 734 if (typeof propsOnMenuOpen === "function") { 735 propsOnMenuOpen(); 736 } 737 setStateMenuIsOpen(true); 738 }, [propsOnMenuOpen]); 739 var onMenuClose = (0, import_react.useCallback)(function() { 740 if (typeof propsOnMenuClose === "function") { 741 propsOnMenuClose(); 742 } 743 setStateMenuIsOpen(false); 744 }, [propsOnMenuClose]); 745 var inputValue = propsInputValue !== void 0 ? propsInputValue : stateInputValue; 746 var menuIsOpen = propsMenuIsOpen !== void 0 ? propsMenuIsOpen : stateMenuIsOpen; 747 var value = propsValue !== void 0 ? propsValue : stateValue; 748 return _objectSpread2(_objectSpread2({}, restSelectProps), {}, { 749 inputValue, 750 menuIsOpen, 751 onChange: onChange2, 752 onInputChange, 753 onMenuClose, 754 onMenuOpen, 755 value 756 }); 757} 758
vendor: 243 bytes, lines 759-762
759// node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/react-select/dist/react-select.esm.js 760var React9 = __toESM(require_react()); 761var import_react8 = __toESM(require_react()); 762
vendor: 200 bytes, lines 763-767
763// node_modules/.pnpm/@[email protected]/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js 764function _arrayWithoutHoles(r10) { 765 if (Array.isArray(r10)) return _arrayLikeToArray(r10); 766} 767
vendor: 260 bytes, lines 768-772
768// node_modules/.pnpm/@[email protected]/node_modules/@babel/runtime/helpers/esm/iterableToArray.js 769function _iterableToArray(r10) { 770 if ("undefined" != typeof Symbol && null != r10[Symbol.iterator] || null != r10["@@iterator"]) return Array.from(r10); 771} 772
vendor: 299 bytes, lines 773-777
773// node_modules/.pnpm/@[email protected]/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js 774function _nonIterableSpread() { 775 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 776} 777
vendor: 262 bytes, lines 778-782
778// node_modules/.pnpm/@[email protected]/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js 779function _toConsumableArray(r10) { 780 return _arrayWithoutHoles(r10) || _iterableToArray(r10) || _unsupportedIterableToArray(r10) || _nonIterableSpread(); 781} 782
vendor: 246 bytes, lines 783-786
783// node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/react-select/dist/Select-49a62830.esm.js 784var React8 = __toESM(require_react()); 785var import_react6 = __toESM(require_react()); 786
vendor: 238 bytes, lines 787-790
787// node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@emotion/react/dist/emotion-element-f0de968e.browser.esm.js 788var React6 = __toESM(require_react()); 789var import_react2 = __toESM(require_react()); 790
vendor: 2,476 bytes, lines 791-873
791// node_modules/.pnpm/@[email protected]/node_modules/@emotion/sheet/dist/emotion-sheet.esm.js 792var isDevelopment = false; 793function sheetForTag(tag) { 794 if (tag.sheet) { 795 return tag.sheet; 796 } 797 for (var i3 = 0; i3 < document.styleSheets.length; i3++) { 798 if (document.styleSheets[i3].ownerNode === tag) { 799 return document.styleSheets[i3]; 800 } 801 } 802 return void 0; 803} 804function createStyleElement(options2) { 805 var tag = document.createElement("style"); 806 tag.setAttribute("data-emotion", options2.key); 807 if (options2.nonce !== void 0) { 808 tag.setAttribute("nonce", options2.nonce); 809 } 810 tag.appendChild(document.createTextNode("")); 811 tag.setAttribute("data-s", ""); 812 return tag; 813} 814var StyleSheet = function() { 815 function StyleSheet2(options2) { 816 var _this = this; 817 this._insertTag = function(tag) { 818 var before; 819 if (_this.tags.length === 0) { 820 if (_this.insertionPoint) { 821 before = _this.insertionPoint.nextSibling; 822 } else if (_this.prepend) { 823 before = _this.container.firstChild; 824 } else { 825 before = _this.before; 826 } 827 } else { 828 before = _this.tags[_this.tags.length - 1].nextSibling; 829 } 830 _this.container.insertBefore(tag, before); 831 _this.tags.push(tag); 832 }; 833 this.isSpeedy = options2.speedy === void 0 ? !isDevelopment : options2.speedy; 834 this.tags = []; 835 this.ctr = 0; 836 this.nonce = options2.nonce; 837 this.key = options2.key; 838 this.container = options2.container; 839 this.prepend = options2.prepend; 840 this.insertionPoint = options2.insertionPoint; 841 this.before = null; 842 } 843 var _proto = StyleSheet2.prototype; 844 _proto.hydrate = function hydrate(nodes) { 845 nodes.forEach(this._insertTag); 846 }; 847 _proto.insert = function insert(rule) { 848 if (this.ctr % (this.isSpeedy ? 65e3 : 1) === 0) { 849 this._insertTag(createStyleElement(this)); 850 } 851 var tag = this.tags[this.tags.length - 1]; 852 if (this.isSpeedy) { 853 var sheet = sheetForTag(tag); 854 try { 855 sheet.insertRule(rule, sheet.cssRules.length); 856 } catch (e) { 857 } 858 } else { 859 tag.appendChild(document.createTextNode(rule)); 860 } 861 this.ctr++; 862 }; 863 _proto.flush = function flush() { 864 this.tags.forEach(function(tag) { 865 var _tag$parentNode; 866 return (_tag$parentNode = tag.parentNode) == null ? void 0 : _tag$parentNode.removeChild(tag); 867 }); 868 this.tags = []; 869 this.ctr = 0; 870 }; 871 return StyleSheet2; 872}(); 873
vendor: 275 bytes, lines 874-884
874// node_modules/.pnpm/[email protected]/node_modules/stylis/src/Enum.js 875var MS = "-ms-"; 876var MOZ = "-moz-"; 877var WEBKIT = "-webkit-"; 878var COMMENT = "comm"; 879var RULESET = "rule"; 880var DECLARATION = "decl"; 881var IMPORT = "@import"; 882var KEYFRAMES = "@keyframes"; 883var LAYER = "@layer"; 884
vendor: 1,032 bytes, lines 885-922
885// node_modules/.pnpm/[email protected]/node_modules/stylis/src/Utility.js 886var abs = Math.abs; 887var from = String.fromCharCode; 888var assign = Object.assign; 889function hash(value, length2) { 890 return charat(value, 0) ^ 45 ? (((length2 << 2 ^ charat(value, 0)) << 2 ^ charat(value, 1)) << 2 ^ charat(value, 2)) << 2 ^ charat(value, 3) : 0; 891} 892function trim(value) { 893 return value.trim(); 894} 895function match(value, pattern) { 896 return (value = pattern.exec(value)) ? value[0] : value; 897} 898function replace(value, pattern, replacement) { 899 return value.replace(pattern, replacement); 900} 901function indexof(value, search) { 902 return value.indexOf(search); 903} 904function charat(value, index2) { 905 return value.charCodeAt(index2) | 0; 906} 907function substr(value, begin, end) { 908 return value.slice(begin, end); 909} 910function strlen(value) { 911 return value.length; 912} 913function sizeof(value) { 914 return value.length; 915} 916function append(value, array) { 917 return array.push(value), value; 918} 919function combine(array, callback) { 920 return array.map(callback).join(""); 921} 922
vendor: 2,947 bytes, lines 923-1048
923// node_modules/.pnpm/[email protected]/node_modules/stylis/src/Tokenizer.js 924var line = 1; 925var column = 1; 926var length = 0; 927var position = 0; 928var character = 0; 929var characters = ""; 930function node(value, root, parent, type, props, children, length2) { 931 return { value, root, parent, type, props, children, line, column, length: length2, return: "" }; 932} 933function copy(root, props) { 934 return assign(node("", null, null, "", null, null, 0), root, { length: -root.length }, props); 935} 936function char() { 937 return character; 938} 939function prev() { 940 character = position > 0 ? charat(characters, --position) : 0; 941 if (column--, character === 10) 942 column = 1, line--; 943 return character; 944} 945function next() { 946 character = position < length ? charat(characters, position++) : 0; 947 if (column++, character === 10) 948 column = 1, line++; 949 return character; 950} 951function peek() { 952 return charat(characters, position); 953} 954function caret() { 955 return position; 956} 957function slice(begin, end) { 958 return substr(characters, begin, end); 959} 960function token(type) { 961 switch (type) { 962 case 0: 963 case 9: 964 case 10: 965 case 13: 966 case 32: 967 return 5; 968 case 33: 969 case 43: 970 case 44: 971 case 47: 972 case 62: 973 case 64: 974 case 126: 975 case 59: 976 case 123: 977 case 125: 978 return 4; 979 case 58: 980 return 3; 981 case 34: 982 case 39: 983 case 40: 984 case 91: 985 return 2; 986 case 41: 987 case 93: 988 return 1; 989 } 990 return 0; 991} 992function alloc(value) { 993 return line = column = 1, length = strlen(characters = value), position = 0, []; 994} 995function dealloc(value) { 996 return characters = "", value; 997} 998function delimit(type) { 999 return trim(slice(position - 1, delimiter(type === 91 ? type + 2 : type === 40 ? type + 1 : type))); 1000} 1001function whitespace(type) { 1002 while (character = peek()) 1003 if (character < 33) 1004 next(); 1005 else 1006 break; 1007 return token(type) > 2 || token(character) > 3 ? "" : " "; 1008} 1009function escaping(index2, count) { 1010 while (--count && next()) 1011 if (character < 48 || character > 102 || character > 57 && character < 65 || character > 70 && character < 97) 1012 break; 1013 return slice(index2, caret() + (count < 6 && peek() == 32 && next() == 32)); 1014} 1015function delimiter(type) { 1016 while (next()) 1017 switch (character) { 1018 case type: 1019 return position; 1020 case 34: 1021 case 39: 1022 if (type !== 34 && type !== 39) 1023 delimiter(character); 1024 break; 1025 case 40: 1026 if (type === 41) 1027 delimiter(type); 1028 break; 1029 case 92: 1030 next(); 1031 break; 1032 } 1033 return position; 1034} 1035function commenter(type, index2) { 1036 while (next()) 1037 if (type + character === 47 + 10) 1038 break; 1039 else if (type + character === 42 + 42 && peek() === 47) 1040 break; 1041 return "/*" + slice(index2, position - 1) + "*" + from(type === 47 ? type : next()); 1042} 1043function identifier(index2) { 1044 while (!token(peek())) 1045 next(); 1046 return slice(index2, position); 1047} 1048
vendor: 5,079 bytes, lines 1049-1180
1049// node_modules/.pnpm/[email protected]/node_modules/stylis/src/Parser.js 1050function compile(value) { 1051 return dealloc(parse("", null, null, null, [""], value = alloc(value), 0, [0], value)); 1052} 1053function parse(value, root, parent, rule, rules, rulesets, pseudo, points, declarations) { 1054 var index2 = 0; 1055 var offset = 0; 1056 var length2 = pseudo; 1057 var atrule = 0; 1058 var property = 0; 1059 var previous = 0; 1060 var variable = 1; 1061 var scanning = 1; 1062 var ampersand = 1; 1063 var character2 = 0; 1064 var type = ""; 1065 var props = rules; 1066 var children = rulesets; 1067 var reference = rule; 1068 var characters2 = type; 1069 while (scanning) 1070 switch (previous = character2, character2 = next()) { 1071 case 40: 1072 if (previous != 108 && charat(characters2, length2 - 1) == 58) { 1073 if (indexof(characters2 += replace(delimit(character2), "&", "&\f"), "&\f") != -1) 1074 ampersand = -1; 1075 break; 1076 } 1077 case 34: 1078 case 39: 1079 case 91: 1080 characters2 += delimit(character2); 1081 break; 1082 case 9: 1083 case 10: 1084 case 13: 1085 case 32: 1086 characters2 += whitespace(previous); 1087 break; 1088 case 92: 1089 characters2 += escaping(caret() - 1, 7); 1090 continue; 1091 case 47: 1092 switch (peek()) { 1093 case 42: 1094 case 47: 1095 append(comment(commenter(next(), caret()), root, parent), declarations); 1096 break; 1097 default: 1098 characters2 += "/"; 1099 } 1100 break; 1101 case 123 * variable: 1102 points[index2++] = strlen(characters2) * ampersand; 1103 case 125 * variable: 1104 case 59: 1105 case 0: 1106 switch (character2) { 1107 case 0: 1108 case 125: 1109 scanning = 0; 1110 case 59 + offset: 1111 if (ampersand == -1) characters2 = replace(characters2, /\f/g, ""); 1112 if (property > 0 && strlen(characters2) - length2) 1113 append(property > 32 ? declaration(characters2 + ";", rule, parent, length2 - 1) : declaration(replace(characters2, " ", "") + ";", rule, parent, length2 - 2), declarations); 1114 break; 1115 case 59: 1116 characters2 += ";"; 1117 default: 1118 append(reference = ruleset(characters2, root, parent, index2, offset, rules, points, type, props = [], children = [], length2), rulesets); 1119 if (character2 === 123) 1120 if (offset === 0) 1121 parse(characters2, root, reference, reference, props, rulesets, length2, points, children); 1122 else 1123 switch (atrule === 99 && charat(characters2, 3) === 110 ? 100 : atrule) { 1124 case 100: 1125 case 108: 1126 case 109: 1127 case 115: 1128 parse(value, reference, reference, rule && append(ruleset(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length2), children), rules, children, length2, points, rule ? props : children); 1129 break; 1130 default: 1131 parse(characters2, reference, reference, reference, [""], children, 0, points, children); 1132 } 1133 } 1134 index2 = offset = property = 0, variable = ampersand = 1, type = characters2 = "", length2 = pseudo; 1135 break; 1136 case 58: 1137 length2 = 1 + strlen(characters2), property = previous; 1138 default: 1139 if (variable < 1) { 1140 if (character2 == 123) 1141 --variable; 1142 else if (character2 == 125 && variable++ == 0 && prev() == 125) 1143 continue; 1144 } 1145 switch (characters2 += from(character2), character2 * variable) { 1146 case 38: 1147 ampersand = offset > 0 ? 1 : (characters2 += "\f", -1); 1148 break; 1149 case 44: 1150 points[index2++] = (strlen(characters2) - 1) * ampersand, ampersand = 1; 1151 break; 1152 case 64: 1153 if (peek() === 45) 1154 characters2 += delimit(next()); 1155 atrule = peek(), offset = length2 = strlen(type = characters2 += identifier(caret())), character2++; 1156 break; 1157 case 45: 1158 if (previous === 45 && strlen(characters2) == 2) 1159 variable = 0; 1160 } 1161 } 1162 return rulesets; 1163} 1164function ruleset(value, root, parent, index2, offset, rules, points, type, props, children, length2) { 1165 var post = offset - 1; 1166 var rule = offset === 0 ? rules : [""]; 1167 var size = sizeof(rule); 1168 for (var i3 = 0, j3 = 0, k3 = 0; i3 < index2; ++i3) 1169 for (var x2 = 0, y4 = substr(value, post + 1, post = abs(j3 = points[i3])), z3 = value; x2 < size; ++x2) 1170 if (z3 = trim(j3 > 0 ? rule[x2] + " " + y4 : replace(y4, /&\f/g, rule[x2]))) 1171 props[k3++] = z3; 1172 return node(value, root, parent, offset === 0 ? RULESET : type, props, children, length2); 1173} 1174function comment(value, root, parent) { 1175 return node(value, root, parent, COMMENT, from(char()), substr(value, 2, -2), 0); 1176} 1177function declaration(value, root, parent, length2) { 1178 return node(value, root, parent, DECLARATION, substr(value, 0, length2), substr(value, length2 + 1, -1), length2); 1179} 1180
vendor: 893 bytes, lines 1181-1205
1181// node_modules/.pnpm/[email protected]/node_modules/stylis/src/Serializer.js 1182function serialize(children, callback) { 1183 var output2 = ""; 1184 var length2 = sizeof(children); 1185 for (var i3 = 0; i3 < length2; i3++) 1186 output2 += callback(children[i3], i3, children, callback) || ""; 1187 return output2; 1188} 1189function stringify2(element, index2, children, callback) { 1190 switch (element.type) { 1191 case LAYER: 1192 if (element.children.length) break; 1193 case IMPORT: 1194 case DECLARATION: 1195 return element.return = element.return || element.value; 1196 case COMMENT: 1197 return ""; 1198 case KEYFRAMES: 1199 return element.return = element.value + "{" + serialize(element.children, callback) + "}"; 1200 case RULESET: 1201 element.value = element.props.join(","); 1202 } 1203 return strlen(children = serialize(element.children, callback)) ? element.return = element.value + "{" + children + "}" : ""; 1204} 1205
vendor: 528 bytes, lines 1206-1224
1206// node_modules/.pnpm/[email protected]/node_modules/stylis/src/Middleware.js 1207function middleware(collection) { 1208 var length2 = sizeof(collection); 1209 return function(element, index2, children, callback) { 1210 var output2 = ""; 1211 for (var i3 = 0; i3 < length2; i3++) 1212 output2 += collection[i3](element, index2, children, callback) || ""; 1213 return output2; 1214 }; 1215} 1216function rulesheet(callback) { 1217 return function(element) { 1218 if (!element.root) { 1219 if (element = element.return) 1220 callback(element); 1221 } 1222 }; 1223} 1224
vendor: 372 bytes, lines 1225-1237
1225// node_modules/.pnpm/@[email protected]/node_modules/@emotion/weak-memoize/dist/emotion-weak-memoize.esm.js 1226var weakMemoize = function weakMemoize2(func) { 1227 var cache = /* @__PURE__ */ new WeakMap(); 1228 return function(arg) { 1229 if (cache.has(arg)) { 1230 return cache.get(arg); 1231 } 1232 var ret = func(arg); 1233 cache.set(arg, ret); 1234 return ret; 1235 }; 1236}; 1237
vendor: 286 bytes, lines 1238-1246
1238// node_modules/.pnpm/@[email protected]/node_modules/@emotion/memoize/dist/emotion-memoize.esm.js 1239function memoize(fn) { 1240 var cache = /* @__PURE__ */ Object.create(null); 1241 return function(arg) { 1242 if (cache[arg] === void 0) cache[arg] = fn(arg); 1243 return cache[arg]; 1244 }; 1245} 1246
vendor: 10,049 bytes, lines 1247-1549
1247// node_modules/.pnpm/@[email protected]/node_modules/@emotion/cache/dist/emotion-cache.browser.esm.js 1248var identifierWithPointTracking = function identifierWithPointTracking2(begin, points, index2) { 1249 var previous = 0; 1250 var character2 = 0; 1251 while (true) { 1252 previous = character2; 1253 character2 = peek(); 1254 if (previous === 38 && character2 === 12) { 1255 points[index2] = 1; 1256 } 1257 if (token(character2)) { 1258 break; 1259 } 1260 next(); 1261 } 1262 return slice(begin, position); 1263}; 1264var toRules = function toRules2(parsed, points) { 1265 var index2 = -1; 1266 var character2 = 44; 1267 do { 1268 switch (token(character2)) { 1269 case 0: 1270 if (character2 === 38 && peek() === 12) { 1271 points[index2] = 1; 1272 } 1273 parsed[index2] += identifierWithPointTracking(position - 1, points, index2); 1274 break; 1275 case 2: 1276 parsed[index2] += delimit(character2); 1277 break; 1278 case 4: 1279 if (character2 === 44) { 1280 parsed[++index2] = peek() === 58 ? "&\f" : ""; 1281 points[index2] = parsed[index2].length; 1282 break; 1283 } 1284 default: 1285 parsed[index2] += from(character2); 1286 } 1287 } while (character2 = next()); 1288 return parsed; 1289}; 1290var getRules = function getRules2(value, points) { 1291 return dealloc(toRules(alloc(value), points)); 1292}; 1293var fixedElements = /* @__PURE__ */ new WeakMap(); 1294var compat = function compat2(element) { 1295 if (element.type !== "rule" || !element.parent || // positive .length indicates that this rule contains pseudo 1296 // negative .length indicates that this rule has been already prefixed 1297 element.length < 1) { 1298 return; 1299 } 1300 var value = element.value; 1301 var parent = element.parent; 1302 var isImplicitRule = element.column === parent.column && element.line === parent.line; 1303 while (parent.type !== "rule") { 1304 parent = parent.parent; 1305 if (!parent) return; 1306 } 1307 if (element.props.length === 1 && value.charCodeAt(0) !== 58 && !fixedElements.get(parent)) { 1308 return; 1309 } 1310 if (isImplicitRule) { 1311 return; 1312 } 1313 fixedElements.set(element, true); 1314 var points = []; 1315 var rules = getRules(value, points); 1316 var parentRules = parent.props; 1317 for (var i3 = 0, k3 = 0; i3 < rules.length; i3++) { 1318 for (var j3 = 0; j3 < parentRules.length; j3++, k3++) { 1319 element.props[k3] = points[i3] ? rules[i3].replace(/&\f/g, parentRules[j3]) : parentRules[j3] + " " + rules[i3]; 1320 } 1321 } 1322}; 1323var removeLabel = function removeLabel2(element) { 1324 if (element.type === "decl") { 1325 var value = element.value; 1326 if ( 1327 // charcode for l 1328 value.charCodeAt(0) === 108 && // charcode for b 1329 value.charCodeAt(2) === 98 1330 ) { 1331 element["return"] = ""; 1332 element.value = ""; 1333 } 1334 } 1335}; 1336function prefix2(value, length2) { 1337 switch (hash(value, length2)) { 1338 case 5103: 1339 return WEBKIT + "print-" + value + value; 1340 case 5737: 1341 case 4201: 1342 case 3177: 1343 case 3433: 1344 case 1641: 1345 case 4457: 1346 case 2921: 1347 case 5572: 1348 case 6356: 1349 case 5844: 1350 case 3191: 1351 case 6645: 1352 case 3005: 1353 case 6391: 1354 case 5879: 1355 case 5623: 1356 case 6135: 1357 case 4599: 1358 case 4855: 1359 case 4215: 1360 case 6389: 1361 case 5109: 1362 case 5365: 1363 case 5621: 1364 case 3829: 1365 return WEBKIT + value + value; 1366 case 5349: 1367 case 4246: 1368 case 4810: 1369 case 6968: 1370 case 2756: 1371 return WEBKIT + value + MOZ + value + MS + value + value; 1372 case 6828: 1373 case 4268: 1374 return WEBKIT + value + MS + value + value; 1375 case 6165: 1376 return WEBKIT + value + MS + "flex-" + value + value; 1377 case 5187: 1378 return WEBKIT + value + replace(value, /(\w+).+(:[^]+)/, WEBKIT + "box-$1$2" + MS + "flex-$1$2") + value; 1379 case 5443: 1380 return WEBKIT + value + MS + "flex-item-" + replace(value, /flex-|-self/, "") + value; 1381 case 4675: 1382 return WEBKIT + value + MS + "flex-line-pack" + replace(value, /align-content|flex-|-self/, "") + value; 1383 case 5548: 1384 return WEBKIT + value + MS + replace(value, "shrink", "negative") + value; 1385 case 5292: 1386 return WEBKIT + value + MS + replace(value, "basis", "preferred-size") + value; 1387 case 6060: 1388 return WEBKIT + "box-" + replace(value, "-grow", "") + WEBKIT + value + MS + replace(value, "grow", "positive") + value; 1389 case 4554: 1390 return WEBKIT + replace(value, /([^-])(transform)/g, "$1" + WEBKIT + "$2") + value; 1391 case 6187: 1392 return replace(replace(replace(value, /(zoom-|grab)/, WEBKIT + "$1"), /(image-set)/, WEBKIT + "$1"), value, "") + value; 1393 case 5495: 1394 case 3959: 1395 return replace(value, /(image-set\([^]*)/, WEBKIT + "$1$`$1"); 1396 case 4968: 1397 return replace(replace(value, /(.+:)(flex-)?(.*)/, WEBKIT + "box-pack:$3" + MS + "flex-pack:$3"), /s.+-b[^;]+/, "justify") + WEBKIT + value + value; 1398 case 4095: 1399 case 3583: 1400 case 4068: 1401 case 2532: 1402 return replace(value, /(.+)-inline(.+)/, WEBKIT + "$1$2") + value; 1403 case 8116: 1404 case 7059: 1405 case 5753: 1406 case 5535: 1407 case 5445: 1408 case 5701: 1409 case 4933: 1410 case 4677: 1411 case 5533: 1412 case 5789: 1413 case 5021: 1414 case 4765: 1415 if (strlen(value) - 1 - length2 > 6) switch (charat(value, length2 + 1)) { 1416 case 109: 1417 if (charat(value, length2 + 4) !== 45) break; 1418 case 102: 1419 return replace(value, /(.+:)(.+)-([^]+)/, "$1" + WEBKIT + "$2-$3$1" + MOZ + (charat(value, length2 + 3) == 108 ? "$3" : "$2-$3")) + value; 1420 case 115: 1421 return ~indexof(value, "stretch") ? prefix2(replace(value, "stretch", "fill-available"), length2) + value : value; 1422 } 1423 break; 1424 case 4949: 1425 if (charat(value, length2 + 1) !== 115) break; 1426 case 6444: 1427 switch (charat(value, strlen(value) - 3 - (~indexof(value, "!important") && 10))) { 1428 case 107: 1429 return replace(value, ":", ":" + WEBKIT) + value; 1430 case 101: 1431 return replace(value, /(.+:)([^;!]+)(;|!.+)?/, "$1" + WEBKIT + (charat(value, 14) === 45 ? "inline-" : "") + "box$3$1" + WEBKIT + "$2$3$1" + MS + "$2box$3") + value; 1432 } 1433 break; 1434 case 5936: 1435 switch (charat(value, length2 + 11)) { 1436 case 114: 1437 return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "tb") + value; 1438 case 108: 1439 return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "tb-rl") + value; 1440 case 45: 1441 return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "lr") + value; 1442 } 1443 return WEBKIT + value + MS + value + value; 1444 } 1445 return value; 1446} 1447var prefixer = function prefixer2(element, index2, children, callback) { 1448 if (element.length > -1) { 1449 if (!element["return"]) switch (element.type) { 1450 case DECLARATION: 1451 element["return"] = prefix2(element.value, element.length); 1452 break; 1453 case KEYFRAMES: 1454 return serialize([copy(element, { 1455 value: replace(element.value, "@", "@" + WEBKIT) 1456 })], callback); 1457 case RULESET: 1458 if (element.length) return combine(element.props, function(value) { 1459 switch (match(value, /(::plac\w+|:read-\w+)/)) { 1460 case ":read-only": 1461 case ":read-write": 1462 return serialize([copy(element, { 1463 props: [replace(value, /:(read-\w+)/, ":" + MOZ + "$1")] 1464 })], callback); 1465 case "::placeholder": 1466 return serialize([copy(element, { 1467 props: [replace(value, /:(plac\w+)/, ":" + WEBKIT + "input-$1")] 1468 }), copy(element, { 1469 props: [replace(value, /:(plac\w+)/, ":" + MOZ + "$1")] 1470 }), copy(element, { 1471 props: [replace(value, /:(plac\w+)/, MS + "input-$1")] 1472 })], callback); 1473 } 1474 return ""; 1475 }); 1476 } 1477 } 1478}; 1479var defaultStylisPlugins = [prefixer]; 1480var createCache = function createCache2(options2) { 1481 var key = options2.key; 1482 if (key === "css") { 1483 var ssrStyles = document.querySelectorAll("style[data-emotion]:not([data-s])"); 1484 Array.prototype.forEach.call(ssrStyles, function(node2) { 1485 var dataEmotionAttribute = node2.getAttribute("data-emotion"); 1486 if (dataEmotionAttribute.indexOf(" ") === -1) { 1487 return; 1488 } 1489 document.head.appendChild(node2); 1490 node2.setAttribute("data-s", ""); 1491 }); 1492 } 1493 var stylisPlugins = options2.stylisPlugins || defaultStylisPlugins; 1494 var inserted = {}; 1495 var container; 1496 var nodesToHydrate = []; 1497 { 1498 container = options2.container || document.head; 1499 Array.prototype.forEach.call( 1500 // this means we will ignore elements which don't have a space in them which 1501 // means that the style elements we're looking at are only Emotion 11 server-rendered style elements 1502 document.querySelectorAll('style[data-emotion^="' + key + ' "]'), 1503 function(node2) { 1504 var attrib = node2.getAttribute("data-emotion").split(" "); 1505 for (var i3 = 1; i3 < attrib.length; i3++) { 1506 inserted[attrib[i3]] = true; 1507 } 1508 nodesToHydrate.push(node2); 1509 } 1510 ); 1511 } 1512 var _insert; 1513 var omnipresentPlugins = [compat, removeLabel]; 1514 { 1515 var currentSheet; 1516 var finalizingPlugins = [stringify2, rulesheet(function(rule) { 1517 currentSheet.insert(rule); 1518 })]; 1519 var serializer = middleware(omnipresentPlugins.concat(stylisPlugins, finalizingPlugins)); 1520 var stylis = function stylis2(styles) { 1521 return serialize(compile(styles), serializer); 1522 }; 1523 _insert = function insert(selector, serialized, sheet, shouldCache) { 1524 currentSheet = sheet; 1525 stylis(selector ? selector + "{" + serialized.styles + "}" : serialized.styles); 1526 if (shouldCache) { 1527 cache.inserted[serialized.name] = true; 1528 } 1529 }; 1530 } 1531 var cache = { 1532 key, 1533 sheet: new StyleSheet({ 1534 key, 1535 container, 1536 nonce: options2.nonce, 1537 speedy: options2.speedy, 1538 prepend: options2.prepend, 1539 insertionPoint: options2.insertionPoint 1540 }), 1541 nonce: options2.nonce, 1542 inserted, 1543 registered: {}, 1544 insert: _insert 1545 }; 1546 cache.sheet.hydrate(nodesToHydrate); 1547 return cache; 1548}; 1549
vendor: 257 bytes, lines 1550-1552
1550// node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@emotion/react/_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.esm.js 1551var import_hoist_non_react_statics = __toESM(require_hoist_non_react_statics_cjs()); 1552
vendor: 1,812 bytes, lines 1553-1594
1553// node_modules/.pnpm/@[email protected]/node_modules/@emotion/utils/dist/emotion-utils.browser.esm.js 1554var isBrowser = true; 1555function getRegisteredStyles(registered, registeredStyles, classNames2) { 1556 var rawClassName = ""; 1557 classNames2.split(" ").forEach(function(className) { 1558 if (registered[className] !== void 0) { 1559 registeredStyles.push(registered[className] + ";"); 1560 } else if (className) { 1561 rawClassName += className + " "; 1562 } 1563 }); 1564 return rawClassName; 1565} 1566var registerStyles = function registerStyles2(cache, serialized, isStringTag) { 1567 var className = cache.key + "-" + serialized.name; 1568 if ( 1569 // we only need to add the styles to the registered cache if the 1570 // class name could be used further down 1571 // the tree but if it's a string tag, we know it won't 1572 // so we don't have to add it to registered cache. 1573 // this improves memory usage since we can avoid storing the whole style string 1574 (isStringTag === false || // we need to always store it if we're in compat mode and 1575 // in node since emotion-server relies on whether a style is in 1576 // the registered cache to know whether a style is global or not 1577 // also, note that this check will be dead code eliminated in the browser 1578 isBrowser === false) && cache.registered[className] === void 0 1579 ) { 1580 cache.registered[className] = serialized.styles; 1581 } 1582}; 1583var insertStyles = function insertStyles2(cache, serialized, isStringTag) { 1584 registerStyles(cache, serialized, isStringTag); 1585 var className = cache.key + "-" + serialized.name; 1586 if (cache.inserted[serialized.name] === void 0) { 1587 var current = serialized; 1588 do { 1589 cache.insert(serialized === current ? "." + className : "", current, cache.sheet, true); 1590 current = current.next; 1591 } while (current !== void 0); 1592 } 1593}; 1594
vendor: 1,115 bytes, lines 1595-1624
1595// node_modules/.pnpm/@[email protected]/node_modules/@emotion/hash/dist/emotion-hash.esm.js 1596function murmur2(str) { 1597 var h3 = 0; 1598 var k3, i3 = 0, len = str.length; 1599 for (; len >= 4; ++i3, len -= 4) { 1600 k3 = str.charCodeAt(i3) & 255 | (str.charCodeAt(++i3) & 255) << 8 | (str.charCodeAt(++i3) & 255) << 16 | (str.charCodeAt(++i3) & 255) << 24; 1601 k3 = /* Math.imul(k, m): */ 1602 (k3 & 65535) * 1540483477 + ((k3 >>> 16) * 59797 << 16); 1603 k3 ^= /* k >>> r: */ 1604 k3 >>> 24; 1605 h3 = /* Math.imul(k, m): */ 1606 (k3 & 65535) * 1540483477 + ((k3 >>> 16) * 59797 << 16) ^ /* Math.imul(h, m): */ 1607 (h3 & 65535) * 1540483477 + ((h3 >>> 16) * 59797 << 16); 1608 } 1609 switch (len) { 1610 case 3: 1611 h3 ^= (str.charCodeAt(i3 + 2) & 255) << 16; 1612 case 2: 1613 h3 ^= (str.charCodeAt(i3 + 1) & 255) << 8; 1614 case 1: 1615 h3 ^= str.charCodeAt(i3) & 255; 1616 h3 = /* Math.imul(h, m): */ 1617 (h3 & 65535) * 1540483477 + ((h3 >>> 16) * 59797 << 16); 1618 } 1619 h3 ^= h3 >>> 13; 1620 h3 = /* Math.imul(h, m): */ 1621 (h3 & 65535) * 1540483477 + ((h3 >>> 16) * 59797 << 16); 1622 return ((h3 ^ h3 >>> 15) >>> 0).toString(36); 1623} 1624
vendor: 1,007 bytes, lines 1625-1676
1625// node_modules/.pnpm/@[email protected]/node_modules/@emotion/unitless/dist/emotion-unitless.esm.js 1626var unitlessKeys = { 1627 animationIterationCount: 1, 1628 aspectRatio: 1, 1629 borderImageOutset: 1, 1630 borderImageSlice: 1, 1631 borderImageWidth: 1, 1632 boxFlex: 1, 1633 boxFlexGroup: 1, 1634 boxOrdinalGroup: 1, 1635 columnCount: 1, 1636 columns: 1, 1637 flex: 1, 1638 flexGrow: 1, 1639 flexPositive: 1, 1640 flexShrink: 1, 1641 flexNegative: 1, 1642 flexOrder: 1, 1643 gridRow: 1, 1644 gridRowEnd: 1, 1645 gridRowSpan: 1, 1646 gridRowStart: 1, 1647 gridColumn: 1, 1648 gridColumnEnd: 1, 1649 gridColumnSpan: 1, 1650 gridColumnStart: 1, 1651 msGridRow: 1, 1652 msGridRowSpan: 1, 1653 msGridColumn: 1, 1654 msGridColumnSpan: 1, 1655 fontWeight: 1, 1656 lineHeight: 1, 1657 opacity: 1, 1658 order: 1, 1659 orphans: 1, 1660 scale: 1, 1661 tabSize: 1, 1662 widows: 1, 1663 zIndex: 1, 1664 zoom: 1, 1665 WebkitLineClamp: 1, 1666 // SVG-related properties 1667 fillOpacity: 1, 1668 floodOpacity: 1, 1669 stopOpacity: 1, 1670 strokeDasharray: 1, 1671 strokeDashoffset: 1, 1672 strokeMiterlimit: 1, 1673 strokeOpacity: 1, 1674 strokeWidth: 1 1675}; 1676
vendor: 5,634 bytes, lines 1677-1850
1677// node_modules/.pnpm/@[email protected]/node_modules/@emotion/serialize/dist/emotion-serialize.esm.js 1678var isDevelopment2 = false; 1679var hyphenateRegex = /[A-Z]|^ms/g; 1680var animationRegex = /_EMO_([^_]+?)_([^]*?)_EMO_/g; 1681var isCustomProperty = function isCustomProperty2(property) { 1682 return property.charCodeAt(1) === 45; 1683}; 1684var isProcessableValue = function isProcessableValue2(value) { 1685 return value != null && typeof value !== "boolean"; 1686}; 1687var processStyleName = memoize(function(styleName) { 1688 return isCustomProperty(styleName) ? styleName : styleName.replace(hyphenateRegex, "-$&").toLowerCase(); 1689}); 1690var processStyleValue = function processStyleValue2(key, value) { 1691 switch (key) { 1692 case "animation": 1693 case "animationName": { 1694 if (typeof value === "string") { 1695 return value.replace(animationRegex, function(match2, p1, p22) { 1696 cursor = { 1697 name: p1, 1698 styles: p22, 1699 next: cursor 1700 }; 1701 return p1; 1702 }); 1703 } 1704 } 1705 } 1706 if (unitlessKeys[key] !== 1 && !isCustomProperty(key) && typeof value === "number" && value !== 0) { 1707 return value + "px"; 1708 } 1709 return value; 1710}; 1711var noComponentSelectorMessage = "Component selectors can only be used in conjunction with @emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware compiler transform."; 1712function handleInterpolation(mergedProps, registered, interpolation) { 1713 if (interpolation == null) { 1714 return ""; 1715 } 1716 var componentSelector = interpolation; 1717 if (componentSelector.__emotion_styles !== void 0) { 1718 return componentSelector; 1719 } 1720 switch (typeof interpolation) { 1721 case "boolean": { 1722 return ""; 1723 } 1724 case "object": { 1725 var keyframes2 = interpolation; 1726 if (keyframes2.anim === 1) { 1727 cursor = { 1728 name: keyframes2.name, 1729 styles: keyframes2.styles, 1730 next: cursor 1731 }; 1732 return keyframes2.name; 1733 } 1734 var serializedStyles = interpolation; 1735 if (serializedStyles.styles !== void 0) { 1736 var next2 = serializedStyles.next; 1737 if (next2 !== void 0) { 1738 while (next2 !== void 0) { 1739 cursor = { 1740 name: next2.name, 1741 styles: next2.styles, 1742 next: cursor 1743 }; 1744 next2 = next2.next; 1745 } 1746 } 1747 var styles = serializedStyles.styles + ";"; 1748 return styles; 1749 } 1750 return createStringFromObject(mergedProps, registered, interpolation); 1751 } 1752 case "function": { 1753 if (mergedProps !== void 0) { 1754 var previousCursor = cursor; 1755 var result = interpolation(mergedProps); 1756 cursor = previousCursor; 1757 return handleInterpolation(mergedProps, registered, result); 1758 } 1759 break; 1760 } 1761 } 1762 var asString = interpolation; 1763 if (registered == null) { 1764 return asString; 1765 } 1766 var cached = registered[asString]; 1767 return cached !== void 0 ? cached : asString; 1768} 1769function createStringFromObject(mergedProps, registered, obj) { 1770 var string = ""; 1771 if (Array.isArray(obj)) { 1772 for (var i3 = 0; i3 < obj.length; i3++) { 1773 string += handleInterpolation(mergedProps, registered, obj[i3]) + ";"; 1774 } 1775 } else { 1776 for (var key in obj) { 1777 var value = obj[key]; 1778 if (typeof value !== "object") { 1779 var asString = value; 1780 if (registered != null && registered[asString] !== void 0) { 1781 string += key + "{" + registered[asString] + "}"; 1782 } else if (isProcessableValue(asString)) { 1783 string += processStyleName(key) + ":" + processStyleValue(key, asString) + ";"; 1784 } 1785 } else { 1786 if (key === "NO_COMPONENT_SELECTOR" && isDevelopment2) { 1787 throw new Error(noComponentSelectorMessage); 1788 } 1789 if (Array.isArray(value) && typeof value[0] === "string" && (registered == null || registered[value[0]] === void 0)) { 1790 for (var _i2 = 0; _i2 < value.length; _i2++) { 1791 if (isProcessableValue(value[_i2])) { 1792 string += processStyleName(key) + ":" + processStyleValue(key, value[_i2]) + ";"; 1793 } 1794 } 1795 } else { 1796 var interpolated = handleInterpolation(mergedProps, registered, value); 1797 switch (key) { 1798 case "animation": 1799 case "animationName": { 1800 string += processStyleName(key) + ":" + interpolated + ";"; 1801 break; 1802 } 1803 default: { 1804 string += key + "{" + interpolated + "}"; 1805 } 1806 } 1807 } 1808 } 1809 } 1810 } 1811 return string; 1812} 1813var labelPattern = /label:\s*([^\s;{]+)\s*(;|$)/g; 1814var cursor; 1815function serializeStyles(args, registered, mergedProps) { 1816 if (args.length === 1 && typeof args[0] === "object" && args[0] !== null && args[0].styles !== void 0) { 1817 return args[0]; 1818 } 1819 var stringMode = true; 1820 var styles = ""; 1821 cursor = void 0; 1822 var strings = args[0]; 1823 if (strings == null || strings.raw === void 0) { 1824 stringMode = false; 1825 styles += handleInterpolation(mergedProps, registered, strings); 1826 } else { 1827 var asTemplateStringsArr = strings; 1828 styles += asTemplateStringsArr[0]; 1829 } 1830 for (var i3 = 1; i3 < args.length; i3++) { 1831 styles += handleInterpolation(mergedProps, registered, args[i3]); 1832 if (stringMode) { 1833 var templateStringsArr = strings; 1834 styles += templateStringsArr[i3]; 1835 } 1836 } 1837 labelPattern.lastIndex = 0; 1838 var identifierName = ""; 1839 var match2; 1840 while ((match2 = labelPattern.exec(styles)) !== null) { 1841 identifierName += "-" + match2[1]; 1842 } 1843 var name = murmur2(styles) + identifierName; 1844 return { 1845 name, 1846 styles, 1847 next: cursor 1848 }; 1849} 1850
vendor: 593 bytes, lines 1851-1859
1851// node_modules/.pnpm/@[email protected][email protected]/node_modules/@emotion/use-insertion-effect-with-fallbacks/dist/emotion-use-insertion-effect-with-fallbacks.browser.esm.js 1852var React5 = __toESM(require_react()); 1853var syncFallback = function syncFallback2(create4) { 1854 return create4(); 1855}; 1856var useInsertionEffect2 = React5["useInsertionEffect"] ? React5["useInsertionEffect"] : false; 1857var useInsertionEffectAlwaysWithSyncFallback = useInsertionEffect2 || syncFallback; 1858var useInsertionEffectWithLayoutFallback = useInsertionEffect2 || React5.useLayoutEffect; 1859
vendor: 3,273 bytes, lines 1860-1945
1860// node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@emotion/react/dist/emotion-element-f0de968e.browser.esm.js 1861var isDevelopment3 = false; 1862var EmotionCacheContext = React6.createContext( 1863 // we're doing this to avoid preconstruct's dead code elimination in this one case 1864 // because this module is primarily intended for the browser and node 1865 // but it's also required in react native and similar environments sometimes 1866 // and we could have a special build just for that 1867 // but this is much easier and the native packages 1868 // might use a different theme context in the future anyway 1869 typeof HTMLElement !== "undefined" ? createCache({ 1870 key: "css" 1871 }) : null 1872); 1873var CacheProvider = EmotionCacheContext.Provider; 1874var withEmotionCache = function withEmotionCache2(func) { 1875 return (0, import_react2.forwardRef)(function(props, ref) { 1876 var cache = (0, import_react2.useContext)(EmotionCacheContext); 1877 return func(props, cache, ref); 1878 }); 1879}; 1880var ThemeContext = React6.createContext({}); 1881var getTheme = function getTheme2(outerTheme, theme) { 1882 if (typeof theme === "function") { 1883 var mergedTheme = theme(outerTheme); 1884 return mergedTheme; 1885 } 1886 return _extends({}, outerTheme, theme); 1887}; 1888var createCacheWithTheme = weakMemoize(function(outerTheme) { 1889 return weakMemoize(function(theme) { 1890 return getTheme(outerTheme, theme); 1891 }); 1892}); 1893var hasOwn = {}.hasOwnProperty; 1894var typePropName = "__EMOTION_TYPE_PLEASE_DO_NOT_USE__"; 1895var createEmotionProps = function createEmotionProps2(type, props) { 1896 var newProps = {}; 1897 for (var _key in props) { 1898 if (hasOwn.call(props, _key)) { 1899 newProps[_key] = props[_key]; 1900 } 1901 } 1902 newProps[typePropName] = type; 1903 return newProps; 1904}; 1905var Insertion = function Insertion2(_ref3) { 1906 var cache = _ref3.cache, serialized = _ref3.serialized, isStringTag = _ref3.isStringTag; 1907 registerStyles(cache, serialized, isStringTag); 1908 useInsertionEffectAlwaysWithSyncFallback(function() { 1909 return insertStyles(cache, serialized, isStringTag); 1910 }); 1911 return null; 1912}; 1913var Emotion = withEmotionCache(function(props, cache, ref) { 1914 var cssProp = props.css; 1915 if (typeof cssProp === "string" && cache.registered[cssProp] !== void 0) { 1916 cssProp = cache.registered[cssProp]; 1917 } 1918 var WrappedComponent = props[typePropName]; 1919 var registeredStyles = [cssProp]; 1920 var className = ""; 1921 if (typeof props.className === "string") { 1922 className = getRegisteredStyles(cache.registered, registeredStyles, props.className); 1923 } else if (props.className != null) { 1924 className = props.className + " "; 1925 } 1926 var serialized = serializeStyles(registeredStyles, void 0, React6.useContext(ThemeContext)); 1927 className += cache.key + "-" + serialized.name; 1928 var newProps = {}; 1929 for (var _key2 in props) { 1930 if (hasOwn.call(props, _key2) && _key2 !== "css" && _key2 !== typePropName && !isDevelopment3) { 1931 newProps[_key2] = props[_key2]; 1932 } 1933 } 1934 newProps.className = className; 1935 if (ref) { 1936 newProps.ref = ref; 1937 } 1938 return React6.createElement(React6.Fragment, null, React6.createElement(Insertion, { 1939 cache, 1940 serialized, 1941 isStringTag: typeof WrappedComponent === "string" 1942 }), React6.createElement(WrappedComponent, newProps)); 1943}); 1944var Emotion$1 = Emotion; 1945
vendor: 5,481 bytes, lines 1946-2121
1946// node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@emotion/react/dist/emotion-react.browser.esm.js 1947var React7 = __toESM(require_react()); 1948var import_hoist_non_react_statics2 = __toESM(require_hoist_non_react_statics_cjs()); 1949var jsx2 = function jsx3(type, props) { 1950 var args = arguments; 1951 if (props == null || !hasOwn.call(props, "css")) { 1952 return React7.createElement.apply(void 0, args); 1953 } 1954 var argsLength = args.length; 1955 var createElementArgArray = new Array(argsLength); 1956 createElementArgArray[0] = Emotion$1; 1957 createElementArgArray[1] = createEmotionProps(type, props); 1958 for (var i3 = 2; i3 < argsLength; i3++) { 1959 createElementArgArray[i3] = args[i3]; 1960 } 1961 return React7.createElement.apply(null, createElementArgArray); 1962}; 1963(function(_jsx) { 1964 var JSX; 1965 /* @__PURE__ */ (function(_JSX) { 1966 })(JSX || (JSX = _jsx.JSX || (_jsx.JSX = {}))); 1967})(jsx2 || (jsx2 = {})); 1968var Global = withEmotionCache(function(props, cache) { 1969 var styles = props.styles; 1970 var serialized = serializeStyles([styles], void 0, React7.useContext(ThemeContext)); 1971 var sheetRef = React7.useRef(); 1972 useInsertionEffectWithLayoutFallback(function() { 1973 var key = cache.key + "-global"; 1974 var sheet = new cache.sheet.constructor({ 1975 key, 1976 nonce: cache.sheet.nonce, 1977 container: cache.sheet.container, 1978 speedy: cache.sheet.isSpeedy 1979 }); 1980 var rehydrating = false; 1981 var node2 = document.querySelector('style[data-emotion="' + key + " " + serialized.name + '"]'); 1982 if (cache.sheet.tags.length) { 1983 sheet.before = cache.sheet.tags[0]; 1984 } 1985 if (node2 !== null) { 1986 rehydrating = true; 1987 node2.setAttribute("data-emotion", key); 1988 sheet.hydrate([node2]); 1989 } 1990 sheetRef.current = [sheet, rehydrating]; 1991 return function() { 1992 sheet.flush(); 1993 }; 1994 }, [cache]); 1995 useInsertionEffectWithLayoutFallback(function() { 1996 var sheetRefCurrent = sheetRef.current; 1997 var sheet = sheetRefCurrent[0], rehydrating = sheetRefCurrent[1]; 1998 if (rehydrating) { 1999 sheetRefCurrent[1] = false; 2000 return; 2001 } 2002 if (serialized.next !== void 0) { 2003 insertStyles(cache, serialized.next, true); 2004 } 2005 if (sheet.tags.length) { 2006 var element = sheet.tags[sheet.tags.length - 1].nextElementSibling; 2007 sheet.before = element; 2008 sheet.flush(); 2009 } 2010 cache.insert("", serialized, sheet, false); 2011 }, [cache, serialized.name]); 2012 return null; 2013}); 2014function css() { 2015 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 2016 args[_key] = arguments[_key]; 2017 } 2018 return serializeStyles(args); 2019} 2020function keyframes() { 2021 var insertable = css.apply(void 0, arguments); 2022 var name = "animation-" + insertable.name; 2023 return { 2024 name, 2025 styles: "@keyframes " + name + "{" + insertable.styles + "}", 2026 anim: 1, 2027 toString: function toString() { 2028 return "_EMO_" + this.name + "_" + this.styles + "_EMO_"; 2029 } 2030 }; 2031} 2032var classnames = function classnames2(args) { 2033 var len = args.length; 2034 var i3 = 0; 2035 var cls = ""; 2036 for (; i3 < len; i3++) { 2037 var arg = args[i3]; 2038 if (arg == null) continue; 2039 var toAdd = void 0; 2040 switch (typeof arg) { 2041 case "boolean": 2042 break; 2043 case "object": { 2044 if (Array.isArray(arg)) { 2045 toAdd = classnames2(arg); 2046 } else { 2047 toAdd = ""; 2048 for (var k3 in arg) { 2049 if (arg[k3] && k3) { 2050 toAdd && (toAdd += " "); 2051 toAdd += k3; 2052 } 2053 } 2054 } 2055 break; 2056 } 2057 default: { 2058 toAdd = arg; 2059 } 2060 } 2061 if (toAdd) { 2062 cls && (cls += " "); 2063 cls += toAdd; 2064 } 2065 } 2066 return cls; 2067}; 2068function merge(registered, css5, className) { 2069 var registeredStyles = []; 2070 var rawClassName = getRegisteredStyles(registered, registeredStyles, className); 2071 if (registeredStyles.length < 2) { 2072 return className; 2073 } 2074 return rawClassName + css5(registeredStyles); 2075} 2076var Insertion3 = function Insertion4(_ref3) { 2077 var cache = _ref3.cache, serializedArr = _ref3.serializedArr; 2078 useInsertionEffectAlwaysWithSyncFallback(function() { 2079 for (var i3 = 0; i3 < serializedArr.length; i3++) { 2080 insertStyles(cache, serializedArr[i3], false); 2081 } 2082 }); 2083 return null; 2084}; 2085var ClassNames = withEmotionCache(function(props, cache) { 2086 var hasRendered = false; 2087 var serializedArr = []; 2088 var css5 = function css6() { 2089 if (hasRendered && isDevelopment3) { 2090 throw new Error("css can only be used during render"); 2091 } 2092 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 2093 args[_key] = arguments[_key]; 2094 } 2095 var serialized = serializeStyles(args, cache.registered); 2096 serializedArr.push(serialized); 2097 registerStyles(cache, serialized, false); 2098 return cache.key + "-" + serialized.name; 2099 }; 2100 var cx = function cx2() { 2101 if (hasRendered && isDevelopment3) { 2102 throw new Error("cx can only be used during render"); 2103 } 2104 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 2105 args[_key2] = arguments[_key2]; 2106 } 2107 return merge(cache.registered, css5, classnames(args)); 2108 }; 2109 var content = { 2110 css: css5, 2111 cx, 2112 theme: React7.useContext(ThemeContext) 2113 }; 2114 var ele = props.children(content); 2115 hasRendered = true; 2116 return React7.createElement(React7.Fragment, null, React7.createElement(Insertion3, { 2117 cache, 2118 serializedArr 2119 }), ele); 2120}); 2121
vendor: 285 bytes, lines 2122-2130
2122// node_modules/.pnpm/@[email protected]/node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteral.js 2123function _taggedTemplateLiteral(e, t2) { 2124 return t2 || (t2 = e.slice(0)), Object.freeze(Object.defineProperties(e, { 2125 raw: { 2126 value: Object.freeze(t2) 2127 } 2128 })); 2129} 2130
vendor: 259 bytes, lines 2131-2134
2131// node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/react-select/dist/index-a301f526.esm.js 2132var import_react5 = __toESM(require_react()); 2133var import_react_dom = __toESM(require_react_dom()); 2134
vendor: 272 bytes, lines 2135-2138
2135// node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js 2136var import_react3 = __toESM(require_react()); 2137var index = import_react3.useLayoutEffect; 2138
vendor: 61,931 bytes, lines 2139-3158
2139// node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/react-select/dist/index-a301f526.esm.js 2140var _excluded$4 = ["className", "clearValue", "cx", "getStyles", "getClassNames", "getValue", "hasValue", "isMulti", "isRtl", "options", "selectOption", "selectProps", "setValue", "theme"]; 2141var noop = function noop2() { 2142}; 2143function applyPrefixToName(prefix3, name) { 2144 if (!name) { 2145 return prefix3; 2146 } else if (name[0] === "-") { 2147 return prefix3 + name; 2148 } else { 2149 return prefix3 + "__" + name; 2150 } 2151} 2152function classNames(prefix3, state) { 2153 for (var _len = arguments.length, classNameList = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { 2154 classNameList[_key - 2] = arguments[_key]; 2155 } 2156 var arr = [].concat(classNameList); 2157 if (state && prefix3) { 2158 for (var key in state) { 2159 if (state.hasOwnProperty(key) && state[key]) { 2160 arr.push("".concat(applyPrefixToName(prefix3, key))); 2161 } 2162 } 2163 } 2164 return arr.filter(function(i3) { 2165 return i3; 2166 }).map(function(i3) { 2167 return String(i3).trim(); 2168 }).join(" "); 2169} 2170var cleanValue = function cleanValue2(value) { 2171 if (isArray(value)) return value.filter(Boolean); 2172 if (_typeof(value) === "object" && value !== null) return [value]; 2173 return []; 2174}; 2175var cleanCommonProps = function cleanCommonProps2(props) { 2176 props.className; 2177 props.clearValue; 2178 props.cx; 2179 props.getStyles; 2180 props.getClassNames; 2181 props.getValue; 2182 props.hasValue; 2183 props.isMulti; 2184 props.isRtl; 2185 props.options; 2186 props.selectOption; 2187 props.selectProps; 2188 props.setValue; 2189 props.theme; 2190 var innerProps = _objectWithoutProperties(props, _excluded$4); 2191 return _objectSpread2({}, innerProps); 2192}; 2193var getStyleProps = function getStyleProps2(props, name, classNamesState) { 2194 var cx = props.cx, getStyles = props.getStyles, getClassNames = props.getClassNames, className = props.className; 2195 return { 2196 css: getStyles(name, props), 2197 className: cx(classNamesState !== null && classNamesState !== void 0 ? classNamesState : {}, getClassNames(name, props), className) 2198 }; 2199}; 2200function isDocumentElement(el) { 2201 return [document.documentElement, document.body, window].indexOf(el) > -1; 2202} 2203function normalizedHeight(el) { 2204 if (isDocumentElement(el)) { 2205 return window.innerHeight; 2206 } 2207 return el.clientHeight; 2208} 2209function getScrollTop(el) { 2210 if (isDocumentElement(el)) { 2211 return window.pageYOffset; 2212 } 2213 return el.scrollTop; 2214} 2215function scrollTo(el, top) { 2216 if (isDocumentElement(el)) { 2217 window.scrollTo(0, top); 2218 return; 2219 } 2220 el.scrollTop = top; 2221} 2222function getScrollParent(element) { 2223 var style = getComputedStyle(element); 2224 var excludeStaticParent = style.position === "absolute"; 2225 var overflowRx = /(auto|scroll)/; 2226 if (style.position === "fixed") return document.documentElement; 2227 for (var parent = element; parent = parent.parentElement; ) { 2228 style = getComputedStyle(parent); 2229 if (excludeStaticParent && style.position === "static") { 2230 continue; 2231 } 2232 if (overflowRx.test(style.overflow + style.overflowY + style.overflowX)) { 2233 return parent; 2234 } 2235 } 2236 return document.documentElement; 2237} 2238function easeOutCubic(t2, b3, c3, d2) { 2239 return c3 * ((t2 = t2 / d2 - 1) * t2 * t2 + 1) + b3; 2240} 2241function animatedScrollTo(element, to) { 2242 var duration = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 200; 2243 var callback = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : noop; 2244 var start = getScrollTop(element); 2245 var change3 = to - start; 2246 var increment = 10; 2247 var currentTime = 0; 2248 function animateScroll() { 2249 currentTime += increment; 2250 var val = easeOutCubic(currentTime, start, change3, duration); 2251 scrollTo(element, val); 2252 if (currentTime < duration) { 2253 window.requestAnimationFrame(animateScroll); 2254 } else { 2255 callback(element); 2256 } 2257 } 2258 animateScroll(); 2259} 2260function scrollIntoView(menuEl, focusedEl) { 2261 var menuRect = menuEl.getBoundingClientRect(); 2262 var focusedRect = focusedEl.getBoundingClientRect(); 2263 var overScroll = focusedEl.offsetHeight / 3; 2264 if (focusedRect.bottom + overScroll > menuRect.bottom) { 2265 scrollTo(menuEl, Math.min(focusedEl.offsetTop + focusedEl.clientHeight - menuEl.offsetHeight + overScroll, menuEl.scrollHeight)); 2266 } else if (focusedRect.top - overScroll < menuRect.top) { 2267 scrollTo(menuEl, Math.max(focusedEl.offsetTop - overScroll, 0)); 2268 } 2269} 2270function getBoundingClientObj(element) { 2271 var rect = element.getBoundingClientRect(); 2272 return { 2273 bottom: rect.bottom, 2274 height: rect.height, 2275 left: rect.left, 2276 right: rect.right, 2277 top: rect.top, 2278 width: rect.width 2279 }; 2280} 2281function isTouchCapable() { 2282 try { 2283 document.createEvent("TouchEvent"); 2284 return true; 2285 } catch (e) { 2286 return false; 2287 } 2288} 2289function isMobileDevice() { 2290 try { 2291 return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); 2292 } catch (e) { 2293 return false; 2294 } 2295} 2296var passiveOptionAccessed = false; 2297var options = { 2298 get passive() { 2299 return passiveOptionAccessed = true; 2300 } 2301}; 2302var w = typeof window !== "undefined" ? window : {}; 2303if (w.addEventListener && w.removeEventListener) { 2304 w.addEventListener("p", noop, options); 2305 w.removeEventListener("p", noop, false); 2306} 2307var supportsPassiveEvents = passiveOptionAccessed; 2308function notNullish(item) { 2309 return item != null; 2310} 2311function isArray(arg) { 2312 return Array.isArray(arg); 2313} 2314function valueTernary(isMulti, multiValue, singleValue) { 2315 return isMulti ? multiValue : singleValue; 2316} 2317function singleValueAsValue(singleValue) { 2318 return singleValue; 2319} 2320function multiValueAsValue(multiValue) { 2321 return multiValue; 2322} 2323var removeProps = function removeProps2(propsObj) { 2324 for (var _len2 = arguments.length, properties = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { 2325 properties[_key2 - 1] = arguments[_key2]; 2326 } 2327 var propsMap = Object.entries(propsObj).filter(function(_ref3) { 2328 var _ref23 = _slicedToArray(_ref3, 1), key = _ref23[0]; 2329 return !properties.includes(key); 2330 }); 2331 return propsMap.reduce(function(newProps, _ref3) { 2332 var _ref4 = _slicedToArray(_ref3, 2), key = _ref4[0], val = _ref4[1]; 2333 newProps[key] = val; 2334 return newProps; 2335 }, {}); 2336}; 2337var _excluded$3 = ["children", "innerProps"]; 2338var _excluded2$1 = ["children", "innerProps"]; 2339function getMenuPlacement(_ref3) { 2340 var preferredMaxHeight = _ref3.maxHeight, menuEl = _ref3.menuEl, minHeight = _ref3.minHeight, preferredPlacement = _ref3.placement, shouldScroll = _ref3.shouldScroll, isFixedPosition = _ref3.isFixedPosition, controlHeight2 = _ref3.controlHeight; 2341 var scrollParent = getScrollParent(menuEl); 2342 var defaultState = { 2343 placement: "bottom", 2344 maxHeight: preferredMaxHeight 2345 }; 2346 if (!menuEl || !menuEl.offsetParent) return defaultState; 2347 var _scrollParent$getBoun = scrollParent.getBoundingClientRect(), scrollHeight = _scrollParent$getBoun.height; 2348 var _menuEl$getBoundingCl = menuEl.getBoundingClientRect(), menuBottom = _menuEl$getBoundingCl.bottom, menuHeight = _menuEl$getBoundingCl.height, menuTop = _menuEl$getBoundingCl.top; 2349 var _menuEl$offsetParent$ = menuEl.offsetParent.getBoundingClientRect(), containerTop = _menuEl$offsetParent$.top; 2350 var viewHeight = isFixedPosition ? window.innerHeight : normalizedHeight(scrollParent); 2351 var scrollTop = getScrollTop(scrollParent); 2352 var marginBottom = parseInt(getComputedStyle(menuEl).marginBottom, 10); 2353 var marginTop = parseInt(getComputedStyle(menuEl).marginTop, 10); 2354 var viewSpaceAbove = containerTop - marginTop; 2355 var viewSpaceBelow = viewHeight - menuTop; 2356 var scrollSpaceAbove = viewSpaceAbove + scrollTop; 2357 var scrollSpaceBelow = scrollHeight - scrollTop - menuTop; 2358 var scrollDown = menuBottom - viewHeight + scrollTop + marginBottom; 2359 var scrollUp = scrollTop + menuTop - marginTop; 2360 var scrollDuration = 160; 2361 switch (preferredPlacement) { 2362 case "auto": 2363 case "bottom": 2364 if (viewSpaceBelow >= menuHeight) { 2365 return { 2366 placement: "bottom", 2367 maxHeight: preferredMaxHeight 2368 }; 2369 } 2370 if (scrollSpaceBelow >= menuHeight && !isFixedPosition) { 2371 if (shouldScroll) { 2372 animatedScrollTo(scrollParent, scrollDown, scrollDuration); 2373 } 2374 return { 2375 placement: "bottom", 2376 maxHeight: preferredMaxHeight 2377 }; 2378 } 2379 if (!isFixedPosition && scrollSpaceBelow >= minHeight || isFixedPosition && viewSpaceBelow >= minHeight) { 2380 if (shouldScroll) { 2381 animatedScrollTo(scrollParent, scrollDown, scrollDuration); 2382 } 2383 var constrainedHeight = isFixedPosition ? viewSpaceBelow - marginBottom : scrollSpaceBelow - marginBottom; 2384 return { 2385 placement: "bottom", 2386 maxHeight: constrainedHeight 2387 }; 2388 } 2389 if (preferredPlacement === "auto" || isFixedPosition) { 2390 var _constrainedHeight = preferredMaxHeight; 2391 var spaceAbove = isFixedPosition ? viewSpaceAbove : scrollSpaceAbove; 2392 if (spaceAbove >= minHeight) { 2393 _constrainedHeight = Math.min(spaceAbove - marginBottom - controlHeight2, preferredMaxHeight); 2394 } 2395 return { 2396 placement: "top", 2397 maxHeight: _constrainedHeight 2398 }; 2399 } 2400 if (preferredPlacement === "bottom") { 2401 if (shouldScroll) { 2402 scrollTo(scrollParent, scrollDown); 2403 } 2404 return { 2405 placement: "bottom", 2406 maxHeight: preferredMaxHeight 2407 }; 2408 } 2409 break; 2410 case "top": 2411 if (viewSpaceAbove >= menuHeight) { 2412 return { 2413 placement: "top", 2414 maxHeight: preferredMaxHeight 2415 }; 2416 } 2417 if (scrollSpaceAbove >= menuHeight && !isFixedPosition) { 2418 if (shouldScroll) { 2419 animatedScrollTo(scrollParent, scrollUp, scrollDuration); 2420 } 2421 return { 2422 placement: "top", 2423 maxHeight: preferredMaxHeight 2424 }; 2425 } 2426 if (!isFixedPosition && scrollSpaceAbove >= minHeight || isFixedPosition && viewSpaceAbove >= minHeight) { 2427 var _constrainedHeight2 = preferredMaxHeight; 2428 if (!isFixedPosition && scrollSpaceAbove >= minHeight || isFixedPosition && viewSpaceAbove >= minHeight) { 2429 _constrainedHeight2 = isFixedPosition ? viewSpaceAbove - marginTop : scrollSpaceAbove - marginTop; 2430 } 2431 if (shouldScroll) { 2432 animatedScrollTo(scrollParent, scrollUp, scrollDuration); 2433 } 2434 return { 2435 placement: "top", 2436 maxHeight: _constrainedHeight2 2437 }; 2438 } 2439 return { 2440 placement: "bottom", 2441 maxHeight: preferredMaxHeight 2442 }; 2443 default: 2444 throw new Error('Invalid placement provided "'.concat(preferredPlacement, '".')); 2445 } 2446 return defaultState; 2447} 2448function alignToControl(placement) { 2449 var placementToCSSProp = { 2450 bottom: "top", 2451 top: "bottom" 2452 }; 2453 return placement ? placementToCSSProp[placement] : "bottom"; 2454} 2455var coercePlacement = function coercePlacement2(p3) { 2456 return p3 === "auto" ? "bottom" : p3; 2457}; 2458var menuCSS = function menuCSS2(_ref23, unstyled) { 2459 var _objectSpread24; 2460 var placement = _ref23.placement, _ref2$theme = _ref23.theme, borderRadius2 = _ref2$theme.borderRadius, spacing2 = _ref2$theme.spacing, colors2 = _ref2$theme.colors; 2461 return _objectSpread2((_objectSpread24 = { 2462 label: "menu" 2463 }, _defineProperty(_objectSpread24, alignToControl(placement), "100%"), _defineProperty(_objectSpread24, "position", "absolute"), _defineProperty(_objectSpread24, "width", "100%"), _defineProperty(_objectSpread24, "zIndex", 1), _objectSpread24), unstyled ? {} : { 2464 backgroundColor: colors2.neutral0, 2465 borderRadius: borderRadius2, 2466 boxShadow: "0 0 0 1px hsla(0, 0%, 0%, 0.1), 0 4px 11px hsla(0, 0%, 0%, 0.1)", 2467 marginBottom: spacing2.menuGutter, 2468 marginTop: spacing2.menuGutter 2469 }); 2470}; 2471var PortalPlacementContext = (0, import_react5.createContext)(null); 2472var MenuPlacer = function MenuPlacer2(props) { 2473 var children = props.children, minMenuHeight = props.minMenuHeight, maxMenuHeight = props.maxMenuHeight, menuPlacement = props.menuPlacement, menuPosition = props.menuPosition, menuShouldScrollIntoView = props.menuShouldScrollIntoView, theme = props.theme; 2474 var _ref3 = (0, import_react5.useContext)(PortalPlacementContext) || {}, setPortalPlacement = _ref3.setPortalPlacement; 2475 var ref = (0, import_react5.useRef)(null); 2476 var _useState = (0, import_react5.useState)(maxMenuHeight), _useState2 = _slicedToArray(_useState, 2), maxHeight = _useState2[0], setMaxHeight = _useState2[1]; 2477 var _useState3 = (0, import_react5.useState)(null), _useState4 = _slicedToArray(_useState3, 2), placement = _useState4[0], setPlacement = _useState4[1]; 2478 var controlHeight2 = theme.spacing.controlHeight; 2479 index(function() { 2480 var menuEl = ref.current; 2481 if (!menuEl) return; 2482 var isFixedPosition = menuPosition === "fixed"; 2483 var shouldScroll = menuShouldScrollIntoView && !isFixedPosition; 2484 var state = getMenuPlacement({ 2485 maxHeight: maxMenuHeight, 2486 menuEl, 2487 minHeight: minMenuHeight, 2488 placement: menuPlacement, 2489 shouldScroll, 2490 isFixedPosition, 2491 controlHeight: controlHeight2 2492 }); 2493 setMaxHeight(state.maxHeight); 2494 setPlacement(state.placement); 2495 setPortalPlacement === null || setPortalPlacement === void 0 ? void 0 : setPortalPlacement(state.placement); 2496 }, [maxMenuHeight, menuPlacement, menuPosition, menuShouldScrollIntoView, minMenuHeight, setPortalPlacement, controlHeight2]); 2497 return children({ 2498 ref, 2499 placerProps: _objectSpread2(_objectSpread2({}, props), {}, { 2500 placement: placement || coercePlacement(menuPlacement), 2501 maxHeight 2502 }) 2503 }); 2504}; 2505var Menu2 = function Menu3(props) { 2506 var children = props.children, innerRef = props.innerRef, innerProps = props.innerProps; 2507 return jsx2("div", _extends({}, getStyleProps(props, "menu", { 2508 menu: true 2509 }), { 2510 ref: innerRef 2511 }, innerProps), children); 2512}; 2513var Menu$1 = Menu2; 2514var menuListCSS = function menuListCSS2(_ref4, unstyled) { 2515 var maxHeight = _ref4.maxHeight, baseUnit2 = _ref4.theme.spacing.baseUnit; 2516 return _objectSpread2({ 2517 maxHeight, 2518 overflowY: "auto", 2519 position: "relative", 2520 // required for offset[Height, Top] > keyboard scroll 2521 WebkitOverflowScrolling: "touch" 2522 }, unstyled ? {} : { 2523 paddingBottom: baseUnit2, 2524 paddingTop: baseUnit2 2525 }); 2526}; 2527var MenuList = function MenuList2(props) { 2528 var children = props.children, innerProps = props.innerProps, innerRef = props.innerRef, isMulti = props.isMulti; 2529 return jsx2("div", _extends({}, getStyleProps(props, "menuList", { 2530 "menu-list": true, 2531 "menu-list--is-multi": isMulti 2532 }), { 2533 ref: innerRef 2534 }, innerProps), children); 2535}; 2536var noticeCSS = function noticeCSS2(_ref5, unstyled) { 2537 var _ref5$theme = _ref5.theme, baseUnit2 = _ref5$theme.spacing.baseUnit, colors2 = _ref5$theme.colors; 2538 return _objectSpread2({ 2539 textAlign: "center" 2540 }, unstyled ? {} : { 2541 color: colors2.neutral40, 2542 padding: "".concat(baseUnit2 * 2, "px ").concat(baseUnit2 * 3, "px") 2543 }); 2544}; 2545var noOptionsMessageCSS = noticeCSS; 2546var loadingMessageCSS = noticeCSS; 2547var NoOptionsMessage = function NoOptionsMessage2(_ref6) { 2548 var _ref6$children = _ref6.children, children = _ref6$children === void 0 ? "No options" : _ref6$children, innerProps = _ref6.innerProps, restProps = _objectWithoutProperties(_ref6, _excluded$3); 2549 return jsx2("div", _extends({}, getStyleProps(_objectSpread2(_objectSpread2({}, restProps), {}, { 2550 children, 2551 innerProps 2552 }), "noOptionsMessage", { 2553 "menu-notice": true, 2554 "menu-notice--no-options": true 2555 }), innerProps), children); 2556}; 2557var LoadingMessage = function LoadingMessage2(_ref7) { 2558 var _ref7$children = _ref7.children, children = _ref7$children === void 0 ? "Loading..." : _ref7$children, innerProps = _ref7.innerProps, restProps = _objectWithoutProperties(_ref7, _excluded2$1); 2559 return jsx2("div", _extends({}, getStyleProps(_objectSpread2(_objectSpread2({}, restProps), {}, { 2560 children, 2561 innerProps 2562 }), "loadingMessage", { 2563 "menu-notice": true, 2564 "menu-notice--loading": true 2565 }), innerProps), children); 2566}; 2567var menuPortalCSS = function menuPortalCSS2(_ref8) { 2568 var rect = _ref8.rect, offset = _ref8.offset, position2 = _ref8.position; 2569 return { 2570 left: rect.left, 2571 position: position2, 2572 top: offset, 2573 width: rect.width, 2574 zIndex: 1 2575 }; 2576}; 2577var MenuPortal = function MenuPortal2(props) { 2578 var appendTo = props.appendTo, children = props.children, controlElement = props.controlElement, innerProps = props.innerProps, menuPlacement = props.menuPlacement, menuPosition = props.menuPosition; 2579 var menuPortalRef = (0, import_react5.useRef)(null); 2580 var cleanupRef = (0, import_react5.useRef)(null); 2581 var _useState5 = (0, import_react5.useState)(coercePlacement(menuPlacement)), _useState6 = _slicedToArray(_useState5, 2), placement = _useState6[0], setPortalPlacement = _useState6[1]; 2582 var portalPlacementContext = (0, import_react5.useMemo)(function() { 2583 return { 2584 setPortalPlacement 2585 }; 2586 }, []); 2587 var _useState7 = (0, import_react5.useState)(null), _useState8 = _slicedToArray(_useState7, 2), computedPosition = _useState8[0], setComputedPosition = _useState8[1]; 2588 var updateComputedPosition = (0, import_react5.useCallback)(function() { 2589 if (!controlElement) return; 2590 var rect = getBoundingClientObj(controlElement); 2591 var scrollDistance = menuPosition === "fixed" ? 0 : window.pageYOffset; 2592 var offset = rect[placement] + scrollDistance; 2593 if (offset !== (computedPosition === null || computedPosition === void 0 ? void 0 : computedPosition.offset) || rect.left !== (computedPosition === null || computedPosition === void 0 ? void 0 : computedPosition.rect.left) || rect.width !== (computedPosition === null || computedPosition === void 0 ? void 0 : computedPosition.rect.width)) { 2594 setComputedPosition({ 2595 offset, 2596 rect 2597 }); 2598 } 2599 }, [controlElement, menuPosition, placement, computedPosition === null || computedPosition === void 0 ? void 0 : computedPosition.offset, computedPosition === null || computedPosition === void 0 ? void 0 : computedPosition.rect.left, computedPosition === null || computedPosition === void 0 ? void 0 : computedPosition.rect.width]); 2600 index(function() { 2601 updateComputedPosition(); 2602 }, [updateComputedPosition]); 2603 var runAutoUpdate = (0, import_react5.useCallback)(function() { 2604 if (typeof cleanupRef.current === "function") { 2605 cleanupRef.current(); 2606 cleanupRef.current = null; 2607 } 2608 if (controlElement && menuPortalRef.current) { 2609 cleanupRef.current = autoUpdate(controlElement, menuPortalRef.current, updateComputedPosition, { 2610 elementResize: "ResizeObserver" in window 2611 }); 2612 } 2613 }, [controlElement, updateComputedPosition]); 2614 index(function() { 2615 runAutoUpdate(); 2616 }, [runAutoUpdate]); 2617 var setMenuPortalElement = (0, import_react5.useCallback)(function(menuPortalElement) { 2618 menuPortalRef.current = menuPortalElement; 2619 runAutoUpdate(); 2620 }, [runAutoUpdate]); 2621 if (!appendTo && menuPosition !== "fixed" || !computedPosition) return null; 2622 var menuWrapper = jsx2("div", _extends({ 2623 ref: setMenuPortalElement 2624 }, getStyleProps(_objectSpread2(_objectSpread2({}, props), {}, { 2625 offset: computedPosition.offset, 2626 position: menuPosition, 2627 rect: computedPosition.rect 2628 }), "menuPortal", { 2629 "menu-portal": true 2630 }), innerProps), children); 2631 return jsx2(PortalPlacementContext.Provider, { 2632 value: portalPlacementContext 2633 }, appendTo ? (0, import_react_dom.createPortal)(menuWrapper, appendTo) : menuWrapper); 2634}; 2635var containerCSS = function containerCSS2(_ref3) { 2636 var isDisabled = _ref3.isDisabled, isRtl = _ref3.isRtl; 2637 return { 2638 label: "container", 2639 direction: isRtl ? "rtl" : void 0, 2640 pointerEvents: isDisabled ? "none" : void 0, 2641 // cancel mouse events when disabled 2642 position: "relative" 2643 }; 2644}; 2645var SelectContainer = function SelectContainer2(props) { 2646 var children = props.children, innerProps = props.innerProps, isDisabled = props.isDisabled, isRtl = props.isRtl; 2647 return jsx2("div", _extends({}, getStyleProps(props, "container", { 2648 "--is-disabled": isDisabled, 2649 "--is-rtl": isRtl 2650 }), innerProps), children); 2651}; 2652var valueContainerCSS = function valueContainerCSS2(_ref23, unstyled) { 2653 var spacing2 = _ref23.theme.spacing, isMulti = _ref23.isMulti, hasValue = _ref23.hasValue, controlShouldRenderValue = _ref23.selectProps.controlShouldRenderValue; 2654 return _objectSpread2({ 2655 alignItems: "center", 2656 display: isMulti && hasValue && controlShouldRenderValue ? "flex" : "grid", 2657 flex: 1, 2658 flexWrap: "wrap", 2659 WebkitOverflowScrolling: "touch", 2660 position: "relative", 2661 overflow: "hidden" 2662 }, unstyled ? {} : { 2663 padding: "".concat(spacing2.baseUnit / 2, "px ").concat(spacing2.baseUnit * 2, "px") 2664 }); 2665}; 2666var ValueContainer = function ValueContainer2(props) { 2667 var children = props.children, innerProps = props.innerProps, isMulti = props.isMulti, hasValue = props.hasValue; 2668 return jsx2("div", _extends({}, getStyleProps(props, "valueContainer", { 2669 "value-container": true, 2670 "value-container--is-multi": isMulti, 2671 "value-container--has-value": hasValue 2672 }), innerProps), children); 2673}; 2674var indicatorsContainerCSS = function indicatorsContainerCSS2() { 2675 return { 2676 alignItems: "center", 2677 alignSelf: "stretch", 2678 display: "flex", 2679 flexShrink: 0 2680 }; 2681}; 2682var IndicatorsContainer = function IndicatorsContainer2(props) { 2683 var children = props.children, innerProps = props.innerProps; 2684 return jsx2("div", _extends({}, getStyleProps(props, "indicatorsContainer", { 2685 indicators: true 2686 }), innerProps), children); 2687}; 2688var _templateObject; 2689var _excluded$2 = ["size"]; 2690var _excluded2 = ["innerProps", "isRtl", "size"]; 2691var _ref2 = true ? { 2692 name: "8mmkcg", 2693 styles: "display:inline-block;fill:currentColor;line-height:1;stroke:currentColor;stroke-width:0" 2694} : { 2695 name: "tj5bde-Svg", 2696 styles: "display:inline-block;fill:currentColor;line-height:1;stroke:currentColor;stroke-width:0;label:Svg;", 2697 map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGljYXRvcnMudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXlCSSIsImZpbGUiOiJpbmRpY2F0b3JzLnRzeCIsInNvdXJjZXNDb250ZW50IjpbIi8qKiBAanN4IGpzeCAqL1xuaW1wb3J0IHsgUmVhY3ROb2RlIH0gZnJvbSAncmVhY3QnO1xuaW1wb3J0IHsganN4LCBrZXlmcmFtZXMgfSBmcm9tICdAZW1vdGlvbi9yZWFjdCc7XG5cbmltcG9ydCB7XG4gIENvbW1vblByb3BzQW5kQ2xhc3NOYW1lLFxuICBDU1NPYmplY3RXaXRoTGFiZWwsXG4gIEdyb3VwQmFzZSxcbn0gZnJvbSAnLi4vdHlwZXMnO1xuaW1wb3J0IHsgZ2V0U3R5bGVQcm9wcyB9IGZyb20gJy4uL3V0aWxzJztcblxuLy8gPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG4vLyBEcm9wZG93biAmIENsZWFyIEljb25zXG4vLyA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT1cblxuY29uc3QgU3ZnID0gKHtcbiAgc2l6ZSxcbiAgLi4ucHJvcHNcbn06IEpTWC5JbnRyaW5zaWNFbGVtZW50c1snc3ZnJ10gJiB7IHNpemU6IG51bWJlciB9KSA9PiAoXG4gIDxzdmdcbiAgICBoZWlnaHQ9e3NpemV9XG4gICAgd2lkdGg9e3NpemV9XG4gICAgdmlld0JveD1cIjAgMCAyMCAyMFwiXG4gICAgYXJpYS1oaWRkZW49XCJ0cnVlXCJcbiAgICBmb2N1c2FibGU9XCJmYWxzZVwiXG4gICAgY3NzPXt7XG4gICAgICBkaXNwbGF5OiAnaW5saW5lLWJsb2NrJyxcbiAgICAgIGZpbGw6ICdjdXJyZW50Q29sb3InLFxuICAgICAgbGluZUhlaWdodDogMSxcbiAgICAgIHN0cm9rZTogJ2N1cnJlbnRDb2xvcicsXG4gICAgICBzdHJva2VXaWR0aDogMCxcbiAgICB9fVxuICAgIHsuLi5wcm9wc31cbiAgLz5cbik7XG5cbmV4cG9ydCB0eXBlIENyb3NzSWNvblByb3BzID0gSlNYLkludHJpbnNpY0VsZW1lbnRzWydzdmcnXSAmIHsgc2l6ZT86IG51bWJlciB9O1xuZXhwb3J0IGNvbnN0IENyb3NzSWNvbiA9IChwcm9wczogQ3Jvc3NJY29uUHJvcHMpID0+IChcbiAgPFN2ZyBzaXplPXsyMH0gey4uLnByb3BzfT5cbiAgICA8cGF0aCBkPVwiTTE0LjM0OCAxNC44NDljLTAuNDY5IDAuNDY5LTEuMjI5IDAuNDY5LTEuNjk3IDBsLTIuNjUxLTMuMDMwLTIuNjUxIDMuMDI5Yy0wLjQ2OSAwLjQ2OS0xLjIyOSAwLjQ2OS0xLjY5NyAwLTAuNDY5LTAuNDY5LTAuNDY5LTEuMjI5IDAtMS42OTdsMi43NTgtMy4xNS0yLjc1OS0zLjE1MmMtMC40NjktMC40NjktMC40NjktMS4yMjggMC0xLjY5N3MxLjIyOC0wLjQ2OSAxLjY5NyAwbDIuNjUyIDMuMDMxIDIuNjUxLTMuMDMxYzAuNDY5LTAuNDY5IDEuMjI4LTAuNDY5IDEuNjk3IDBzMC40NjkgMS4yMjkgMCAxLjY5N2wtMi43NTggMy4xNTIgMi43NTggMy4xNWMwLjQ2OSAwLjQ2OSAwLjQ2OSAxLjIyOSAwIDEuNjk4elwiIC8+XG4gIDwvU3ZnPlxuKTtcbmV4cG9ydCB0eXBlIERvd25DaGV2cm9uUHJvcHMgPSBKU1guSW50cmluc2ljRWxlbWVudHNbJ3N2ZyddICYgeyBzaXplPzogbnVtYmVyIH07XG5leHBvcnQgY29uc3QgRG93bkNoZXZyb24gPSAocHJvcHM6IERvd25DaGV2cm9uUHJvcHMpID0+IChcbiAgPFN2ZyBzaXplPXsyMH0gey4uLnByb3BzfT5cbiAgICA8cGF0aCBkPVwiTTQuNTE2IDcuNTQ4YzAuNDM2LTAuNDQ2IDEuMDQzLTAuNDgxIDEuNTc2IDBsMy45MDggMy43NDcgMy45MDgtMy43NDdjMC41MzMtMC40ODEgMS4xNDEtMC40NDYgMS41NzQgMCAwLjQzNiAwLjQ0NSAwLjQwOCAxLjE5NyAwIDEuNjE1LTAuNDA2IDAuNDE4LTQuNjk1IDQuNTAyLTQuNjk1IDQuNTAyLTAuMjE3IDAuMjIzLTAuNTAyIDAuMzM1LTAuNzg3IDAuMzM1cy0wLjU3LTAuMTEyLTAuNzg5LTAuMzM1YzAgMC00LjI4Ny00LjA4NC00LjY5NS00LjUwMnMtMC40MzYtMS4xNyAwLTEuNjE1elwiIC8+XG4gIDwvU3ZnPlxuKTtcblxuLy8gPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG4vLyBEcm9wZG93biAmIENsZWFyIEJ1dHRvbnNcbi8vID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PVxuXG5leHBvcnQgaW50ZXJmYWNlIERyb3Bkb3duSW5kaWNhdG9yUHJvcHM8XG4gIE9wdGlvbiA9IHVua25vd24sXG4gIElzTXVsdGkgZXh0ZW5kcyBib29sZWFuID0gYm9vbGVhbixcbiAgR3JvdXAgZXh0ZW5kcyBHcm91cEJhc2U8T3B0aW9uPiA9IEdyb3VwQmFzZTxPcHRpb24+XG4+IGV4dGVuZHMgQ29tbW9uUHJvcHNBbmRDbGFzc05hbWU8T3B0aW9uLCBJc011bHRpLCBHcm91cD4ge1xuICAvKiogVGhlIGNoaWxkcmVuIHRvIGJlIHJlbmRlcmVkIGluc2lkZSB0aGUgaW5kaWNhdG9yLiAqL1xuICBjaGlsZHJlbj86IFJlYWN0Tm9kZTtcbiAgLyoqIFByb3BzIHRoYXQgd2lsbCBiZSBwYXNzZWQgb24gdG8gdGhlIGNoaWxkcmVuLiAqL1xuICBpbm5lclByb3BzOiBKU1guSW50cmluc2ljRWxlbWVudHNbJ2RpdiddO1xuICAvKiogVGhlIGZvY3VzZWQgc3RhdGUgb2YgdGhlIHNlbGVjdC4gKi9cbiAgaXNGb2N1c2VkOiBib29sZWFuO1xuICBpc0Rpc2FibGVkOiBib29sZWFuO1xufVxuXG5jb25zdCBiYXNlQ1NTID0gPFxuICBPcHRpb24sXG4gIElzTXVsdGkgZXh0ZW5kcyBib29sZWFuLFxuICBHcm91cCBleHRlbmRzIEdyb3VwQmFzZTxPcHRpb24+XG4+KFxuICB7XG4gICAgaXNGb2N1c2VkLFxuICAgIHRoZW1lOiB7XG4gICAgICBzcGFjaW5nOiB7IGJhc2VVbml0IH0sXG4gICAgICBjb2xvcnMsXG4gICAgfSxcbiAgfTpcbiAgICB8IERyb3Bkb3duSW5kaWNhdG9yUHJvcHM8T3B0aW9uLCBJc011bHRpLCBHcm91cD5cbiAgICB8IENsZWFySW5kaWNhdG9yUHJvcHM8T3B0aW9uLCBJc011bHRpLCBHcm91cD4sXG4gIHVuc3R5bGVkOiBib29sZWFuXG4pOiBDU1NPYmplY3RXaXRoTGFiZWwgPT4gKHtcbiAgbGFiZWw6ICdpbmRpY2F0b3JDb250YWluZXInLFxuICBkaXNwbGF5OiAnZmxleCcsXG4gIHRyYW5zaXRpb246ICdjb2xvciAxNTBtcycsXG4gIC4uLih1bnN0eWxlZFxuICAgID8ge31cbiAgICA6IHtcbiAgICAgICAgY29sb3I6IGlzRm9jdXNlZCA/IGNvbG9ycy5uZXV0cmFsNjAgOiBjb2xvcnMubmV1dHJhbDIwLFxuICAgICAgICBwYWRkaW5nOiBiYXNlVW5pdCAqIDIsXG4gICAgICAgICc6aG92ZXInOiB7XG4gICAgICAgICAgY29sb3I6IGlzRm9jdXNlZCA/IGNvbG9ycy5uZXV0cmFsODAgOiBjb2xvcnMubmV1dHJhbDQwLFxuICAgICAgICB9LFxuICAgICAgfSksXG59KTtcblxuZXhwb3J0IGNvbnN0IGRyb3Bkb3duSW5kaWNhdG9yQ1NTID0gYmFzZUNTUztcbmV4cG9ydCBjb25zdCBEcm9wZG93bkluZGljYXRvciA9IDxcbiAgT3B0aW9uLFxuICBJc011bHRpIGV4dGVuZHMgYm9vbGVhbixcbiAgR3JvdXAgZXh0ZW5kcyBHcm91cEJhc2U8T3B0aW9uPlxuPihcbiAgcHJvcHM6IERyb3Bkb3duSW5kaWNhdG9yUHJvcHM8T3B0aW9uLCBJc011bHRpLCBHcm91cD5cbikgPT4ge1xuICBjb25zdCB7IGNoaWxkcmVuLCBpbm5lclByb3BzIH0gPSBwcm9wcztcbiAgcmV0dXJuIChcbiAgICA8ZGl2XG4gICAgICB7Li4uZ2V0U3R5bGVQcm9wcyhwcm9wcywgJ2Ryb3Bkb3duSW5kaWNhdG9yJywge1xuICAgICAgICBpbmRpY2F0b3I6IHRydWUsXG4gICAgICAgICdkcm9wZG93bi1pbmRpY2F0b3InOiB0cnVlLFxuICAgICAgfSl9XG4gICAgICB7Li4uaW5uZXJQcm9wc31cbiAgICA+XG4gICAgICB7Y2hpbGRyZW4gfHwgPERvd25DaGV2cm9uIC8+fVxuICAgIDwvZGl2PlxuICApO1xufTtcblxuZXhwb3J0IGludGVyZmFjZSBDbGVhckluZGljYXRvclByb3BzPFxuICBPcHRpb24gPSB1bmtub3duLFxuICBJc011bHRpIGV4dGVuZHMgYm9vbGVhbiA9IGJvb2xlYW4sXG4gIEdyb3VwIGV4dGVuZHMgR3JvdXBCYXNlPE9wdGlvbj4gPSBHcm91cEJhc2U8T3B0aW9uPlxuPiBleHRlbmRzIENvbW1vblByb3BzQW5kQ2xhc3NOYW1lPE9wdGlvbiwgSXNNdWx0aSwgR3JvdXA+IHtcbiAgLyoqIFRoZSBjaGlsZHJlbiB0byBiZSByZW5kZXJlZCBpbnNpZGUgdGhlIGluZGljYXRvci4gKi9cbiAgY2hpbGRyZW4/OiBSZWFjdE5vZGU7XG4gIC8qKiBQcm9wcyB0aGF0IHdpbGwgYmUgcGFzc2VkIG9uIHRvIHRoZSBjaGlsZHJlbi4gKi9cbiAgaW5uZXJQcm9wczogSlNYLkludHJpbnNpY0VsZW1lbnRzWydkaXYnXTtcbiAgLyoqIFRoZSBmb2N1c2VkIHN0YXRlIG9mIHRoZSBzZWxlY3QuICovXG4gIGlzRm9jdXNlZDogYm9vbGVhbjtcbn1cblxuZXhwb3J0IGNvbnN0IGNsZWFySW5kaWNhdG9yQ1NTID0gYmFzZUNTUztcbmV4cG9ydCBjb25zdCBDbGVhckluZGljYXRvciA9IDxcbiAgT3B0aW9uLFxuICBJc011bHRpIGV4dGVuZHMgYm9vbGVhbixcbiAgR3JvdXAgZXh0ZW5kcyBHcm91cEJhc2U8T3B0aW9uPlxuPihcbiAgcHJvcHM6IENsZWFySW5kaWNhdG9yUHJvcHM8T3B0aW9uLCBJc011bHRpLCBHcm91cD5cbikgPT4ge1xuICBjb25zdCB7IGNoaWxkcmVuLCBpbm5lclByb3BzIH0gPSBwcm9wcztcbiAgcmV0dXJuIChcbiAgICA8ZGl2XG4gICAgICB7Li4uZ2V0U3R5bGVQcm9wcyhwcm9wcywgJ2NsZWFySW5kaWNhdG9yJywge1xuICAgICAgICBpbmRpY2F0b3I6IHRydWUsXG4gICAgICAgICdjbGVhci1pbmRpY2F0b3InOiB0cnVlLFxuICAgICAgfSl9XG4gICAgICB7Li4uaW5uZXJQcm9wc31cbiAgICA+XG4gICAgICB7Y2hpbGRyZW4gfHwgPENyb3NzSWNvbiAvPn1cbiAgICA8L2Rpdj5cbiAgKTtcbn07XG5cbi8vID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PVxuLy8gU2VwYXJhdG9yXG4vLyA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT1cblxuZXhwb3J0IGludGVyZmFjZSBJbmRpY2F0b3JTZXBhcmF0b3JQcm9wczxcbiAgT3B0aW9uID0gdW5rbm93bixcbiAgSXNNdWx0aSBleHRlbmRzIGJvb2xlYW4gPSBib29sZWFuLFxuICBHcm91cCBleHRlbmRzIEdyb3VwQmFzZTxPcHRpb24+ID0gR3JvdXBCYXNlPE9wdGlvbj5cbj4gZXh0ZW5kcyBDb21tb25Qcm9wc0FuZENsYXNzTmFtZTxPcHRpb24sIElzTXVsdGksIEdyb3VwPiB7XG4gIGlzRGlzYWJsZWQ6IGJvb2xlYW47XG4gIGlzRm9jdXNlZDogYm9vbGVhbjtcbiAgaW5uZXJQcm9wcz86IEpTWC5JbnRyaW5zaWNFbGVtZW50c1snc3BhbiddO1xufVxuXG5leHBvcnQgY29uc3QgaW5kaWNhdG9yU2VwYXJhdG9yQ1NTID0gPFxuICBPcHRpb24sXG4gIElzTXVsdGkgZXh0ZW5kcyBib29sZWFuLFxuICBHcm91cCBleHRlbmRzIEdyb3VwQmFzZTxPcHRpb24+XG4+KFxuICB7XG4gICAgaXNEaXNhYmxlZCxcbiAgICB0aGVtZToge1xuICAgICAgc3BhY2luZzogeyBiYXNlVW5pdCB9LFxuICAgICAgY29sb3JzLFxuICAgIH0sXG4gIH06IEluZGljYXRvclNlcGFyYXRvclByb3BzPE9wdGlvbiwgSXNNdWx0aSwgR3JvdXA+LFxuICB1bnN0eWxlZDogYm9vbGVhblxuKTogQ1NTT2JqZWN0V2l0aExhYmVsID0+ICh7XG4gIGxhYmVsOiAnaW5kaWNhdG9yU2VwYXJhdG9yJyxcbiAgYWxpZ25TZWxmOiAnc3RyZXRjaCcsXG4gIHdpZHRoOiAxLFxuICAuLi4odW5zdHlsZWRcbiAgICA/IHt9XG4gICAgOiB7XG4gICAgICAgIGJhY2tncm91bmRDb2xvcjogaXNEaXNhYmxlZCA/IGNvbG9ycy5uZXV0cmFsMTAgOiBjb2xvcnMubmV1dHJhbDIwLFxuICAgICAgICBtYXJnaW5Cb3R0b206IGJhc2VVbml0ICogMixcbiAgICAgICAgbWFyZ2luVG9wOiBiYXNlVW5pdCAqIDIsXG4gICAgICB9KSxcbn0pO1xuXG5leHBvcnQgY29uc3QgSW5kaWNhdG9yU2VwYXJhdG9yID0gPFxuICBPcHRpb24sXG4gIElzTXVsdGkgZXh0ZW5kcyBib29sZWFuLFxuICBHcm91cCBleHRlbmRzIEdyb3VwQmFzZTxPcHRpb24+XG4+KFxuICBwcm9wczogSW5kaWNhdG9yU2VwYXJhdG9yUHJvcHM8T3B0aW9uLCBJc011bHRpLCBHcm91cD5cbikgPT4ge1xuICBjb25zdCB7IGlubmVyUHJvcHMgfSA9IHByb3BzO1xuICByZXR1cm4gKFxuICAgIDxzcGFuXG4gICAgICB7Li4uaW5uZXJQcm9wc31cbiAgICAgIHsuLi5nZXRTdHlsZVByb3BzKHByb3BzLCAnaW5kaWNhdG9yU2VwYXJhdG9yJywge1xuICAgICAgICAnaW5kaWNhdG9yLXNlcGFyYXRvcic6IHRydWUsXG4gICAgICB9KX1cbiAgICAvPlxuICApO1xufTtcblxuLy8gPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG4vLyBMb2FkaW5nXG4vLyA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT1cblxuY29uc3QgbG9hZGluZ0RvdEFuaW1hdGlvbnMgPSBrZXlmcmFtZXNgXG4gIDAlLCA4MCUsIDEwMCUgeyBvcGFjaXR5OiAwOyB9XG4gIDQwJSB7IG9wYWNpdHk6IDE7IH1cbmA7XG5cbmV4cG9ydCBjb25zdCBsb2FkaW5nSW5kaWNhdG9yQ1NTID0gPFxuICBPcHRpb24sXG4gIElzTXVsdGkgZXh0ZW5kcyBib29sZWFuLFxuICBHcm91cCBleHRlbmRzIEdyb3VwQmFzZTxPcHRpb24+XG4+KFxuICB7XG4gICAgaXNGb2N1c2VkLFxuICAgIHNpemUsXG4gICAgdGhlbWU6IHtcbiAgICAgIGNvbG9ycyxcbiAgICAgIHNwYWNpbmc6IHsgYmFzZVVuaXQgfSxcbiAgICB9LFxuICB9OiBMb2FkaW5nSW5kaWNhdG9yUHJvcHM8T3B0aW9uLCBJc011bHRpLCBHcm91cD4sXG4gIHVuc3R5bGVkOiBib29sZWFuXG4pOiBDU1NPYmplY3RXaXRoTGFiZWwgPT4gKHtcbiAgbGFiZWw6ICdsb2FkaW5nSW5kaWNhdG9yJyxcbiAgZGlzcGxheTogJ2ZsZXgnLFxuICB0cmFuc2l0aW9uOiAnY29sb3IgMTUwbXMnLFxuICBhbGlnblNlbGY6ICdjZW50ZXInLFxuICBmb250U2l6ZTogc2l6ZSxcbiAgbGluZUhlaWdodDogMSxcbiAgbWFyZ2luUmlnaHQ6IHNpemUsXG4gIHRleHRBbGlnbjogJ2NlbnRlcicsXG4gIHZlcnRpY2FsQWxpZ246ICdtaWRkbGUnLFxuICAuLi4odW5zdHlsZWRcbiAgICA/IHt9XG4gICAgOiB7XG4gICAgICAgIGNvbG9yOiBpc0ZvY3VzZWQgPyBjb2xvcnMubmV1dHJhbDYwIDogY29sb3JzLm5ldXRyYWwyMCxcbiAgICAgICAgcGFkZGluZzogYmFzZVVuaXQgKiAyLFxuICAgICAgfSksXG59KTtcblxuaW50ZXJmYWNlIExvYWRpbmdEb3RQcm9wcyB7XG4gIGRlbGF5OiBudW1iZXI7XG4gIG9mZnNldDogYm9vbGVhbjtcbn1cbmNvbnN0IExvYWRpbmdEb3QgPSAoeyBkZWxheSwgb2Zmc2V0IH06IExvYWRpbmdEb3RQcm9wcykgPT4gKFxuICA8c3BhblxuICAgIGNzcz17e1xuICAgICAgYW5pbWF0aW9uOiBgJHtsb2FkaW5nRG90QW5pbWF0aW9uc30gMXMgZWFzZS1pbi1vdXQgJHtkZWxheX1tcyBpbmZpbml0ZTtgLFxuICAgICAgYmFja2dyb3VuZENvbG9yOiAnY3VycmVudENvbG9yJyxcbiAgICAgIGJvcmRlclJhZGl1czogJzFlbScsXG4gICAgICBkaXNwbGF5OiAnaW5saW5lLWJsb2NrJyxcbiAgICAgIG1hcmdpbkxlZnQ6IG9mZnNldCA/ICcxZW0nIDogdW5kZWZpbmVkLFxuICAgICAgaGVpZ2h0OiAnMWVtJyxcbiAgICAgIHZlcnRpY2FsQWxpZ246ICd0b3AnLFxuICAgICAgd2lkdGg6ICcxZW0nLFxuICAgIH19XG4gIC8+XG4pO1xuXG5leHBvcnQgaW50ZXJmYWNlIExvYWRpbmdJbmRpY2F0b3JQcm9wczxcbiAgT3B0aW9uID0gdW5rbm93bixcbiAgSXNNdWx0aSBleHRlbmRzIGJvb2xlYW4gPSBib29sZWFuLFxuICBHcm91cCBleHRlbmRzIEdyb3VwQmFzZTxPcHRpb24+ID0gR3JvdXBCYXNlPE9wdGlvbj5cbj4gZXh0ZW5kcyBDb21tb25Qcm9wc0FuZENsYXNzTmFtZTxPcHRpb24sIElzTXVsdGksIEdyb3VwPiB7XG4gIC8qKiBQcm9wcyB0aGF0IHdpbGwgYmUgcGFzc2VkIG9uIHRvIHRoZSBjaGlsZHJlbi4gKi9cbiAgaW5uZXJQcm9wczogSlNYLkludHJpbnNpY0VsZW1lbnRzWydkaXYnXTtcbiAgLyoqIFRoZSBmb2N1c2VkIHN0YXRlIG9mIHRoZSBzZWxlY3QuICovXG4gIGlzRm9jdXNlZDogYm9vbGVhbjtcbiAgaXNEaXNhYmxlZDogYm9vbGVhbjtcbiAgLyoqIFNldCBzaXplIG9mIHRoZSBjb250YWluZXIuICovXG4gIHNpemU6IG51bWJlcjtcbn1cbmV4cG9ydCBjb25zdCBMb2FkaW5nSW5kaWNhdG9yID0gPFxuICBPcHRpb24sXG4gIElzTXVsdGkgZXh0ZW5kcyBib29sZWFuLFxuICBHcm91cCBleHRlbmRzIEdyb3VwQmFzZTxPcHRpb24+XG4+KHtcbiAgaW5uZXJQcm9wcyxcbiAgaXNSdGwsXG4gIHNpemUgPSA0LFxuICAuLi5yZXN0UHJvcHNcbn06IExvYWRpbmdJbmRpY2F0b3JQcm9wczxPcHRpb24sIElzTXVsdGksIEdyb3VwPikgPT4ge1xuICByZXR1cm4gKFxuICAgIDxkaXZcbiAgICAgIHsuLi5nZXRTdHlsZVByb3BzKFxuICAgICAgICB7IC4uLnJlc3RQcm9wcywgaW5uZXJQcm9wcywgaXNSdGwsIHNpemUgfSxcbiAgICAgICAgJ2xvYWRpbmdJbmRpY2F0b3InLFxuICAgICAgICB7XG4gICAgICAgICAgaW5kaWNhdG9yOiB0cnVlLFxuICAgICAgICAgICdsb2FkaW5nLWluZGljYXRvcic6IHRydWUsXG4gICAgICAgIH1cbiAgICAgICl9XG4gICAgICB7Li4uaW5uZXJQcm9wc31cbiAgICA+XG4gICAgICA8TG9hZGluZ0RvdCBkZWxheT17MH0gb2Zmc2V0PXtpc1J0bH0gLz5cbiAgICAgIDxMb2FkaW5nRG90IGRlbGF5PXsxNjB9IG9mZnNldCAvPlxuICAgICAgPExvYWRpbmdEb3QgZGVsYXk9ezMyMH0gb2Zmc2V0PXshaXNSdGx9IC8+XG4gICAgPC9kaXY+XG4gICk7XG59O1xuIl19 */", 2698 toString: _EMOTION_STRINGIFIED_CSS_ERROR__ 2699}; 2700var Svg = function Svg2(_ref3) { 2701 var size = _ref3.size, props = _objectWithoutProperties(_ref3, _excluded$2); 2702 return jsx2("svg", _extends({ 2703 height: size, 2704 width: size, 2705 viewBox: "0 0 20 20", 2706 "aria-hidden": "true", 2707 focusable: "false", 2708 css: _ref2 2709 }, props)); 2710}; 2711var CrossIcon = function CrossIcon2(props) { 2712 return jsx2(Svg, _extends({ 2713 size: 20 2714 }, props), jsx2("path", { 2715 d: "M14.348 14.849c-0.469 0.469-1.229 0.469-1.697 0l-2.651-3.030-2.651 3.029c-0.469 0.469-1.229 0.469-1.697 0-0.469-0.469-0.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-0.469-0.469-0.469-1.228 0-1.697s1.228-0.469 1.697 0l2.652 3.031 2.651-3.031c0.469-0.469 1.228-0.469 1.697 0s0.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c0.469 0.469 0.469 1.229 0 1.698z" 2716 })); 2717}; 2718var DownChevron = function DownChevron2(props) { 2719 return jsx2(Svg, _extends({ 2720 size: 20 2721 }, props), jsx2("path", { 2722 d: "M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z" 2723 })); 2724}; 2725var baseCSS = function baseCSS2(_ref3, unstyled) { 2726 var isFocused = _ref3.isFocused, _ref3$theme = _ref3.theme, baseUnit2 = _ref3$theme.spacing.baseUnit, colors2 = _ref3$theme.colors; 2727 return _objectSpread2({ 2728 label: "indicatorContainer", 2729 display: "flex", 2730 transition: "color 150ms" 2731 }, unstyled ? {} : { 2732 color: isFocused ? colors2.neutral60 : colors2.neutral20, 2733 padding: baseUnit2 * 2, 2734 ":hover": { 2735 color: isFocused ? colors2.neutral80 : colors2.neutral40 2736 } 2737 }); 2738}; 2739var dropdownIndicatorCSS = baseCSS; 2740var DropdownIndicator = function DropdownIndicator2(props) { 2741 var children = props.children, innerProps = props.innerProps; 2742 return jsx2("div", _extends({}, getStyleProps(props, "dropdownIndicator", { 2743 indicator: true, 2744 "dropdown-indicator": true 2745 }), innerProps), children || jsx2(DownChevron, null)); 2746}; 2747var clearIndicatorCSS = baseCSS; 2748var ClearIndicator = function ClearIndicator2(props) { 2749 var children = props.children, innerProps = props.innerProps; 2750 return jsx2("div", _extends({}, getStyleProps(props, "clearIndicator", { 2751 indicator: true, 2752 "clear-indicator": true 2753 }), innerProps), children || jsx2(CrossIcon, null)); 2754}; 2755var indicatorSeparatorCSS = function indicatorSeparatorCSS2(_ref4, unstyled) { 2756 var isDisabled = _ref4.isDisabled, _ref4$theme = _ref4.theme, baseUnit2 = _ref4$theme.spacing.baseUnit, colors2 = _ref4$theme.colors; 2757 return _objectSpread2({ 2758 label: "indicatorSeparator", 2759 alignSelf: "stretch", 2760 width: 1 2761 }, unstyled ? {} : { 2762 backgroundColor: isDisabled ? colors2.neutral10 : colors2.neutral20, 2763 marginBottom: baseUnit2 * 2, 2764 marginTop: baseUnit2 * 2 2765 }); 2766}; 2767var IndicatorSeparator = function IndicatorSeparator2(props) { 2768 var innerProps = props.innerProps; 2769 return jsx2("span", _extends({}, innerProps, getStyleProps(props, "indicatorSeparator", { 2770 "indicator-separator": true 2771 }))); 2772}; 2773var loadingDotAnimations = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0%, 80%, 100% { opacity: 0; }\n 40% { opacity: 1; }\n"]))); 2774var loadingIndicatorCSS = function loadingIndicatorCSS2(_ref5, unstyled) { 2775 var isFocused = _ref5.isFocused, size = _ref5.size, _ref5$theme = _ref5.theme, colors2 = _ref5$theme.colors, baseUnit2 = _ref5$theme.spacing.baseUnit; 2776 return _objectSpread2({ 2777 label: "loadingIndicator", 2778 display: "flex", 2779 transition: "color 150ms", 2780 alignSelf: "center", 2781 fontSize: size, 2782 lineHeight: 1, 2783 marginRight: size, 2784 textAlign: "center", 2785 verticalAlign: "middle" 2786 }, unstyled ? {} : { 2787 color: isFocused ? colors2.neutral60 : colors2.neutral20, 2788 padding: baseUnit2 * 2 2789 }); 2790}; 2791var LoadingDot = function LoadingDot2(_ref6) { 2792 var delay2 = _ref6.delay, offset = _ref6.offset; 2793 return jsx2("span", { 2794 css: css({ 2795 animation: "".concat(loadingDotAnimations, " 1s ease-in-out ").concat(delay2, "ms infinite;"), 2796 backgroundColor: "currentColor", 2797 borderRadius: "1em", 2798 display: "inline-block", 2799 marginLeft: offset ? "1em" : void 0, 2800 height: "1em", 2801 verticalAlign: "top", 2802 width: "1em" 2803 }, true ? "" : ";label:LoadingDot;", true ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGljYXRvcnMudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQW1RSSIsImZpbGUiOiJpbmRpY2F0b3JzLnRzeCIsInNvdXJjZXNDb250ZW50IjpbIi8qKiBAanN4IGpzeCAqL1xuaW1wb3J0IHsgUmVhY3ROb2RlIH0gZnJvbSAncmVhY3QnO1xuaW1wb3J0IHsganN4LCBrZXlmcmFtZXMgfSBmcm9tICdAZW1vdGlvbi9yZWFjdCc7XG5cbmltcG9ydCB7XG4gIENvbW1vblByb3BzQW5kQ2xhc3NOYW1lLFxuICBDU1NPYmplY3RXaXRoTGFiZWwsXG4gIEdyb3VwQmFzZSxcbn0gZnJvbSAnLi4vdHlwZXMnO1xuaW1wb3J0IHsgZ2V0U3R5bGVQcm9wcyB9IGZyb20gJy4uL3V0aWxzJztcblxuLy8gPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG4vLyBEcm9wZG93biAmIENsZWFyIEljb25zXG4vLyA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT1cblxuY29uc3QgU3ZnID0gKHtcbiAgc2l6ZSxcbiAgLi4ucHJvcHNcbn06IEpTWC5JbnRyaW5zaWNFbGVtZW50c1snc3ZnJ10gJiB7IHNpemU6IG51bWJlciB9KSA9PiAoXG4gIDxzdmdcbiAgICBoZWlnaHQ9e3NpemV9XG4gICAgd2lkdGg9e3NpemV9XG4gICAgdmlld0JveD1cIjAgMCAyMCAyMFwiXG4gICAgYXJpYS1oaWRkZW49XCJ0cnVlXCJcbiAgICBmb2N1c2FibGU9XCJmYWxzZVwiXG4gICAgY3NzPXt7XG4gICAgICBkaXNwbGF5OiAnaW5saW5lLWJsb2NrJyxcbiAgICAgIGZpbGw6ICdjdXJyZW50Q29sb3InLFxuICAgICAgbGluZUhlaWdodDogMSxcbiAgICAgIHN0cm9rZTogJ2N1cnJlbnRDb2xvcicsXG4gICAgICBzdHJva2VXaWR0aDogMCxcbiAgICB9fVxuICAgIHsuLi5wcm9wc31cbiAgLz5cbik7XG5cbmV4cG9ydCB0eXBlIENyb3NzSWNvblByb3BzID0gSlNYLkludHJpbnNpY0VsZW1lbnRzWydzdmcnXSAmIHsgc2l6ZT86IG51bWJlciB9O1xuZXhwb3J0IGNvbnN0IENyb3NzSWNvbiA9IChwcm9wczogQ3Jvc3NJY29uUHJvcHMpID0+IChcbiAgPFN2ZyBzaXplPXsyMH0gey4uLnByb3BzfT5cbiAgICA8cGF0aCBkPVwiTTE0LjM0OCAxNC44NDljLTAuNDY5IDAuNDY5LTEuMjI5IDAuNDY5LTEuNjk3IDBsLTIuNjUxLTMuMDMwLTIuNjUxIDMuMDI5Yy0wLjQ2OSAwLjQ2OS0xLjIyOSAwLjQ2OS0xLjY5NyAwLTAuNDY5LTAuNDY5LTAuNDY5LTEuMjI5IDAtMS42OTdsMi43NTgtMy4xNS0yLjc1OS0zLjE1MmMtMC40NjktMC40NjktMC40NjktMS4yMjggMC0xLjY5N3MxLjIyOC0wLjQ2OSAxLjY5NyAwbDIuNjUyIDMuMDMxIDIuNjUxLTMuMDMxYzAuNDY5LTAuNDY5IDEuMjI4LTAuNDY5IDEuNjk3IDBzMC40NjkgMS4yMjkgMCAxLjY5N2wtMi43NTggMy4xNTIgMi43NTggMy4xNWMwLjQ2OSAwLjQ2OSAwLjQ2OSAxLjIyOSAwIDEuNjk4elwiIC8+XG4gIDwvU3ZnPlxuKTtcbmV4cG9ydCB0eXBlIERvd25DaGV2cm9uUHJvcHMgPSBKU1guSW50cmluc2ljRWxlbWVudHNbJ3N2ZyddICYgeyBzaXplPzogbnVtYmVyIH07XG5leHBvcnQgY29uc3QgRG93bkNoZXZyb24gPSAocHJvcHM6IERvd25DaGV2cm9uUHJvcHMpID0+IChcbiAgPFN2ZyBzaXplPXsyMH0gey4uLnByb3BzfT5cbiAgICA8cGF0aCBkPVwiTTQuNTE2IDcuNTQ4YzAuNDM2LTAuNDQ2IDEuMDQzLTAuNDgxIDEuNTc2IDBsMy45MDggMy43NDcgMy45MDgtMy43NDdjMC41MzMtMC40ODEgMS4xNDEtMC40NDYgMS41NzQgMCAwLjQzNiAwLjQ0NSAwLjQwOCAxLjE5NyAwIDEuNjE1LTAuNDA2IDAuNDE4LTQuNjk1IDQuNTAyLTQuNjk1IDQuNTAyLTAuMjE3IDAuMjIzLTAuNTAyIDAuMzM1LTAuNzg3IDAuMzM1cy0wLjU3LTAuMTEyLTAuNzg5LTAuMzM1YzAgMC00LjI4Ny00LjA4NC00LjY5NS00LjUwMnMtMC40MzYtMS4xNyAwLTEuNjE1elwiIC8+XG4gIDwvU3ZnPlxuKTtcblxuLy8gPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG4vLyBEcm9wZG93biAmIENsZWFyIEJ1dHRvbnNcbi8vID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PVxuXG5leHBvcnQgaW50ZXJmYWNlIERyb3Bkb3duSW5kaWNhdG9yUHJvcHM8XG4gIE9wdGlvbiA9IHVua25vd24sXG4gIElzTXVsdGkgZXh0ZW5kcyBib29sZWFuID0gYm9vbGVhbixcbiAgR3JvdXAgZXh0ZW5kcyBHcm91cEJhc2U8T3B0aW9uPiA9IEdyb3VwQmFzZTxPcHRpb24+XG4+IGV4dGVuZHMgQ29tbW9uUHJvcHNBbmRDbGFzc05hbWU8T3B0aW9uLCBJc011bHRpLCBHcm91cD4ge1xuICAvKiogVGhlIGNoaWxkcmVuIHRvIGJlIHJlbmRlcmVkIGluc2lkZSB0aGUgaW5kaWNhdG9yLiAqL1xuICBjaGlsZHJlbj86IFJlYWN0Tm9kZTtcbiAgLyoqIFByb3BzIHRoYXQgd2lsbCBiZSBwYXNzZWQgb24gdG8gdGhlIGNoaWxkcmVuLiAqL1xuICBpbm5lclByb3BzOiBKU1guSW50cmluc2ljRWxlbWVudHNbJ2RpdiddO1xuICAvKiogVGhlIGZvY3VzZWQgc3RhdGUgb2YgdGhlIHNlbGVjdC4gKi9cbiAgaXNGb2N1c2VkOiBib29sZWFuO1xuICBpc0Rpc2FibGVkOiBib29sZWFuO1xufVxuXG5jb25zdCBiYXNlQ1NTID0gPFxuICBPcHRpb24sXG4gIElzTXVsdGkgZXh0ZW5kcyBib29sZWFuLFxuICBHcm91cCBleHRlbmRzIEdyb3VwQmFzZTxPcHRpb24+XG4+KFxuICB7XG4gICAgaXNGb2N1c2VkLFxuICAgIHRoZW1lOiB7XG4gICAgICBzcGFjaW5nOiB7IGJhc2VVbml0IH0sXG4gICAgICBjb2xvcnMsXG4gICAgfSxcbiAgfTpcbiAgICB8IERyb3Bkb3duSW5kaWNhdG9yUHJvcHM8T3B0aW9uLCBJc011bHRpLCBHcm91cD5cbiAgICB8IENsZWFySW5kaWNhdG9yUHJvcHM8T3B0aW9uLCBJc011bHRpLCBHcm91cD4sXG4gIHVuc3R5bGVkOiBib29sZWFuXG4pOiBDU1NPYmplY3RXaXRoTGFiZWwgPT4gKHtcbiAgbGFiZWw6ICdpbmRpY2F0b3JDb250YWluZXInLFxuICBkaXNwbGF5OiAnZmxleCcsXG4gIHRyYW5zaXRpb246ICdjb2xvciAxNTBtcycsXG4gIC4uLih1bnN0eWxlZFxuICAgID8ge31cbiAgICA6IHtcbiAgICAgICAgY29sb3I6IGlzRm9jdXNlZCA/IGNvbG9ycy5uZXV0cmFsNjAgOiBjb2xvcnMubmV1dHJhbDIwLFxuICAgICAgICBwYWRkaW5nOiBiYXNlVW5pdCAqIDIsXG4gICAgICAgICc6aG92ZXInOiB7XG4gICAgICAgICAgY29sb3I6IGlzRm9jdXNlZCA/IGNvbG9ycy5uZXV0cmFsODAgOiBjb2xvcnMubmV1dHJhbDQwLFxuICAgICAgICB9LFxuICAgICAgfSksXG59KTtcblxuZXhwb3J0IGNvbnN0IGRyb3Bkb3duSW5kaWNhdG9yQ1NTID0gYmFzZUNTUztcbmV4cG9ydCBjb25zdCBEcm9wZG93bkluZGljYXRvciA9IDxcbiAgT3B0aW9uLFxuICBJc011bHRpIGV4dGVuZHMgYm9vbGVhbixcbiAgR3JvdXAgZXh0ZW5kcyBHcm91cEJhc2U8T3B0aW9uPlxuPihcbiAgcHJvcHM6IERyb3Bkb3duSW5kaWNhdG9yUHJvcHM8T3B0aW9uLCBJc011bHRpLCBHcm91cD5cbikgPT4ge1xuICBjb25zdCB7IGNoaWxkcmVuLCBpbm5lclByb3BzIH0gPSBwcm9wcztcbiAgcmV0dXJuIChcbiAgICA8ZGl2XG4gICAgICB7Li4uZ2V0U3R5bGVQcm9wcyhwcm9wcywgJ2Ryb3Bkb3duSW5kaWNhdG9yJywge1xuICAgICAgICBpbmRpY2F0b3I6IHRydWUsXG4gICAgICAgICdkcm9wZG93bi1pbmRpY2F0b3InOiB0cnVlLFxuICAgICAgfSl9XG4gICAgICB7Li4uaW5uZXJQcm9wc31cbiAgICA+XG4gICAgICB7Y2hpbGRyZW4gfHwgPERvd25DaGV2cm9uIC8+fVxuICAgIDwvZGl2PlxuICApO1xufTtcblxuZXhwb3J0IGludGVyZmFjZSBDbGVhckluZGljYXRvclByb3BzPFxuICBPcHRpb24gPSB1bmtub3duLFxuICBJc011bHRpIGV4dGVuZHMgYm9vbGVhbiA9IGJvb2xlYW4sXG4gIEdyb3VwIGV4dGVuZHMgR3JvdXBCYXNlPE9wdGlvbj4gPSBHcm91cEJhc2U8T3B0aW9uPlxuPiBleHRlbmRzIENvbW1vblByb3BzQW5kQ2xhc3NOYW1lPE9wdGlvbiwgSXNNdWx0aSwgR3JvdXA+IHtcbiAgLyoqIFRoZSBjaGlsZHJlbiB0byBiZSByZW5kZXJlZCBpbnNpZGUgdGhlIGluZGljYXRvci4gKi9cbiAgY2hpbGRyZW4/OiBSZWFjdE5vZGU7XG4gIC8qKiBQcm9wcyB0aGF0IHdpbGwgYmUgcGFzc2VkIG9uIHRvIHRoZSBjaGlsZHJlbi4gKi9cbiAgaW5uZXJQcm9wczogSlNYLkludHJpbnNpY0VsZW1lbnRzWydkaXYnXTtcbiAgLyoqIFRoZSBmb2N1c2VkIHN0YXRlIG9mIHRoZSBzZWxlY3QuICovXG4gIGlzRm9jdXNlZDogYm9vbGVhbjtcbn1cblxuZXhwb3J0IGNvbnN0IGNsZWFySW5kaWNhdG9yQ1NTID0gYmFzZUNTUztcbmV4cG9ydCBjb25zdCBDbGVhckluZGljYXRvciA9IDxcbiAgT3B0aW9uLFxuICBJc011bHRpIGV4dGVuZHMgYm9vbGVhbixcbiAgR3JvdXAgZXh0ZW5kcyBHcm91cEJhc2U8T3B0aW9uPlxuPihcbiAgcHJvcHM6IENsZWFySW5kaWNhdG9yUHJvcHM8T3B0aW9uLCBJc011bHRpLCBHcm91cD5cbikgPT4ge1xuICBjb25zdCB7IGNoaWxkcmVuLCBpbm5lclByb3BzIH0gPSBwcm9wcztcbiAgcmV0dXJuIChcbiAgICA8ZGl2XG4gICAgICB7Li4uZ2V0U3R5bGVQcm9wcyhwcm9wcywgJ2NsZWFySW5kaWNhdG9yJywge1xuICAgICAgICBpbmRpY2F0b3I6IHRydWUsXG4gICAgICAgICdjbGVhci1pbmRpY2F0b3InOiB0cnVlLFxuICAgICAgfSl9XG4gICAgICB7Li4uaW5uZXJQcm9wc31cbiAgICA+XG4gICAgICB7Y2hpbGRyZW4gfHwgPENyb3NzSWNvbiAvPn1cbiAgICA8L2Rpdj5cbiAgKTtcbn07XG5cbi8vID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PVxuLy8gU2VwYXJhdG9yXG4vLyA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT1cblxuZXhwb3J0IGludGVyZmFjZSBJbmRpY2F0b3JTZXBhcmF0b3JQcm9wczxcbiAgT3B0aW9uID0gdW5rbm93bixcbiAgSXNNdWx0aSBleHRlbmRzIGJvb2xlYW4gPSBib29sZWFuLFxuICBHcm91cCBleHRlbmRzIEdyb3VwQmFzZTxPcHRpb24+ID0gR3JvdXBCYXNlPE9wdGlvbj5cbj4gZXh0ZW5kcyBDb21tb25Qcm9wc0FuZENsYXNzTmFtZTxPcHRpb24sIElzTXVsdGksIEdyb3VwPiB7XG4gIGlzRGlzYWJsZWQ6IGJvb2xlYW47XG4gIGlzRm9jdXNlZDogYm9vbGVhbjtcbiAgaW5uZXJQcm9wcz86IEpTWC5JbnRyaW5zaWNFbGVtZW50c1snc3BhbiddO1xufVxuXG5leHBvcnQgY29uc3QgaW5kaWNhdG9yU2VwYXJhdG9yQ1NTID0gPFxuICBPcHRpb24sXG4gIElzTXVsdGkgZXh0ZW5kcyBib29sZWFuLFxuICBHcm91cCBleHRlbmRzIEdyb3VwQmFzZTxPcHRpb24+XG4+KFxuICB7XG4gICAgaXNEaXNhYmxlZCxcbiAgICB0aGVtZToge1xuICAgICAgc3BhY2luZzogeyBiYXNlVW5pdCB9LFxuICAgICAgY29sb3JzLFxuICAgIH0sXG4gIH06IEluZGljYXRvclNlcGFyYXRvclByb3BzPE9wdGlvbiwgSXNNdWx0aSwgR3JvdXA+LFxuICB1bnN0eWxlZDogYm9vbGVhblxuKTogQ1NTT2JqZWN0V2l0aExhYmVsID0+ICh7XG4gIGxhYmVsOiAnaW5kaWNhdG9yU2VwYXJhdG9yJyxcbiAgYWxpZ25TZWxmOiAnc3RyZXRjaCcsXG4gIHdpZHRoOiAxLFxuICAuLi4odW5zdHlsZWRcbiAgICA/IHt9XG4gICAgOiB7XG4gICAgICAgIGJhY2tncm91bmRDb2xvcjogaXNEaXNhYmxlZCA/IGNvbG9ycy5uZXV0cmFsMTAgOiBjb2xvcnMubmV1dHJhbDIwLFxuICAgICAgICBtYXJnaW5Cb3R0b206IGJhc2VVbml0ICogMixcbiAgICAgICAgbWFyZ2luVG9wOiBiYXNlVW5pdCAqIDIsXG4gICAgICB9KSxcbn0pO1xuXG5leHBvcnQgY29uc3QgSW5kaWNhdG9yU2VwYXJhdG9yID0gPFxuICBPcHRpb24sXG4gIElzTXVsdGkgZXh0ZW5kcyBib29sZWFuLFxuICBHcm91cCBleHRlbmRzIEdyb3VwQmFzZTxPcHRpb24+XG4+KFxuICBwcm9wczogSW5kaWNhdG9yU2VwYXJhdG9yUHJvcHM8T3B0aW9uLCBJc011bHRpLCBHcm91cD5cbikgPT4ge1xuICBjb25zdCB7IGlubmVyUHJvcHMgfSA9IHByb3BzO1xuICByZXR1cm4gKFxuICAgIDxzcGFuXG4gICAgICB7Li4uaW5uZXJQcm9wc31cbiAgICAgIHsuLi5nZXRTdHlsZVByb3BzKHByb3BzLCAnaW5kaWNhdG9yU2VwYXJhdG9yJywge1xuICAgICAgICAnaW5kaWNhdG9yLXNlcGFyYXRvcic6IHRydWUsXG4gICAgICB9KX1cbiAgICAvPlxuICApO1xufTtcblxuLy8gPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG4vLyBMb2FkaW5nXG4vLyA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT1cblxuY29uc3QgbG9hZGluZ0RvdEFuaW1hdGlvbnMgPSBrZXlmcmFtZXNgXG4gIDAlLCA4MCUsIDEwMCUgeyBvcGFjaXR5OiAwOyB9XG4gIDQwJSB7IG9wYWNpdHk6IDE7IH1cbmA7XG5cbmV4cG9ydCBjb25zdCBsb2FkaW5nSW5kaWNhdG9yQ1NTID0gPFxuICBPcHRpb24sXG4gIElzTXVsdGkgZXh0ZW5kcyBib29sZWFuLFxuICBHcm91cCBleHRlbmRzIEdyb3VwQmFzZTxPcHRpb24+XG4+KFxuICB7XG4gICAgaXNGb2N1c2VkLFxuICAgIHNpemUsXG4gICAgdGhlbWU6IHtcbiAgICAgIGNvbG9ycyxcbiAgICAgIHNwYWNpbmc6IHsgYmFzZVVuaXQgfSxcbiAgICB9LFxuICB9OiBMb2FkaW5nSW5kaWNhdG9yUHJvcHM8T3B0aW9uLCBJc011bHRpLCBHcm91cD4sXG4gIHVuc3R5bGVkOiBib29sZWFuXG4pOiBDU1NPYmplY3RXaXRoTGFiZWwgPT4gKHtcbiAgbGFiZWw6ICdsb2FkaW5nSW5kaWNhdG9yJyxcbiAgZGlzcGxheTogJ2ZsZXgnLFxuICB0cmFuc2l0aW9uOiAnY29sb3IgMTUwbXMnLFxuICBhbGlnblNlbGY6ICdjZW50ZXInLFxuICBmb250U2l6ZTogc2l6ZSxcbiAgbGluZUhlaWdodDogMSxcbiAgbWFyZ2luUmlnaHQ6IHNpemUsXG4gIHRleHRBbGlnbjogJ2NlbnRlcicsXG4gIHZlcnRpY2FsQWxpZ246ICdtaWRkbGUnLFxuICAuLi4odW5zdHlsZWRcbiAgICA/IHt9XG4gICAgOiB7XG4gICAgICAgIGNvbG9yOiBpc0ZvY3VzZWQgPyBjb2xvcnMubmV1dHJhbDYwIDogY29sb3JzLm5ldXRyYWwyMCxcbiAgICAgICAgcGFkZGluZzogYmFzZVVuaXQgKiAyLFxuICAgICAgfSksXG59KTtcblxuaW50ZXJmYWNlIExvYWRpbmdEb3RQcm9wcyB7XG4gIGRlbGF5OiBudW1iZXI7XG4gIG9mZnNldDogYm9vbGVhbjtcbn1cbmNvbnN0IExvYWRpbmdEb3QgPSAoeyBkZWxheSwgb2Zmc2V0IH06IExvYWRpbmdEb3RQcm9wcykgPT4gKFxuICA8c3BhblxuICAgIGNzcz17e1xuICAgICAgYW5pbWF0aW9uOiBgJHtsb2FkaW5nRG90QW5pbWF0aW9uc30gMXMgZWFzZS1pbi1vdXQgJHtkZWxheX1tcyBpbmZpbml0ZTtgLFxuICAgICAgYmFja2dyb3VuZENvbG9yOiAnY3VycmVudENvbG9yJyxcbiAgICAgIGJvcmRlclJhZGl1czogJzFlbScsXG4gICAgICBkaXNwbGF5OiAnaW5saW5lLWJsb2NrJyxcbiAgICAgIG1hcmdpbkxlZnQ6IG9mZnNldCA/ICcxZW0nIDogdW5kZWZpbmVkLFxuICAgICAgaGVpZ2h0OiAnMWVtJyxcbiAgICAgIHZlcnRpY2FsQWxpZ246ICd0b3AnLFxuICAgICAgd2lkdGg6ICcxZW0nLFxuICAgIH19XG4gIC8+XG4pO1xuXG5leHBvcnQgaW50ZXJmYWNlIExvYWRpbmdJbmRpY2F0b3JQcm9wczxcbiAgT3B0aW9uID0gdW5rbm93bixcbiAgSXNNdWx0aSBleHRlbmRzIGJvb2xlYW4gPSBib29sZWFuLFxuICBHcm91cCBleHRlbmRzIEdyb3VwQmFzZTxPcHRpb24+ID0gR3JvdXBCYXNlPE9wdGlvbj5cbj4gZXh0ZW5kcyBDb21tb25Qcm9wc0FuZENsYXNzTmFtZTxPcHRpb24sIElzTXVsdGksIEdyb3VwPiB7XG4gIC8qKiBQcm9wcyB0aGF0IHdpbGwgYmUgcGFzc2VkIG9uIHRvIHRoZSBjaGlsZHJlbi4gKi9cbiAgaW5uZXJQcm9wczogSlNYLkludHJpbnNpY0VsZW1lbnRzWydkaXYnXTtcbiAgLyoqIFRoZSBmb2N1c2VkIHN0YXRlIG9mIHRoZSBzZWxlY3QuICovXG4gIGlzRm9jdXNlZDogYm9vbGVhbjtcbiAgaXNEaXNhYmxlZDogYm9vbGVhbjtcbiAgLyoqIFNldCBzaXplIG9mIHRoZSBjb250YWluZXIuICovXG4gIHNpemU6IG51bWJlcjtcbn1cbmV4cG9ydCBjb25zdCBMb2FkaW5nSW5kaWNhdG9yID0gPFxuICBPcHRpb24sXG4gIElzTXVsdGkgZXh0ZW5kcyBib29sZWFuLFxuICBHcm91cCBleHRlbmRzIEdyb3VwQmFzZTxPcHRpb24+XG4+KHtcbiAgaW5uZXJQcm9wcyxcbiAgaXNSdGwsXG4gIHNpemUgPSA0LFxuICAuLi5yZXN0UHJvcHNcbn06IExvYWRpbmdJbmRpY2F0b3JQcm9wczxPcHRpb24sIElzTXVsdGksIEdyb3VwPikgPT4ge1xuICByZXR1cm4gKFxuICAgIDxkaXZcbiAgICAgIHsuLi5nZXRTdHlsZVByb3BzKFxuICAgICAgICB7IC4uLnJlc3RQcm9wcywgaW5uZXJQcm9wcywgaXNSdGwsIHNpemUgfSxcbiAgICAgICAgJ2xvYWRpbmdJbmRpY2F0b3InLFxuICAgICAgICB7XG4gICAgICAgICAgaW5kaWNhdG9yOiB0cnVlLFxuICAgICAgICAgICdsb2FkaW5nLWluZGljYXRvcic6IHRydWUsXG4gICAgICAgIH1cbiAgICAgICl9XG4gICAgICB7Li4uaW5uZXJQcm9wc31cbiAgICA+XG4gICAgICA8TG9hZGluZ0RvdCBkZWxheT17MH0gb2Zmc2V0PXtpc1J0bH0gLz5cbiAgICAgIDxMb2FkaW5nRG90IGRlbGF5PXsxNjB9IG9mZnNldCAvPlxuICAgICAgPExvYWRpbmdEb3QgZGVsYXk9ezMyMH0gb2Zmc2V0PXshaXNSdGx9IC8+XG4gICAgPC9kaXY+XG4gICk7XG59O1xuIl19 */") 2804 }); 2805}; 2806var LoadingIndicator = function LoadingIndicator2(_ref7) { 2807 var innerProps = _ref7.innerProps, isRtl = _ref7.isRtl, _ref7$size = _ref7.size, size = _ref7$size === void 0 ? 4 : _ref7$size, restProps = _objectWithoutProperties(_ref7, _excluded2); 2808 return jsx2("div", _extends({}, getStyleProps(_objectSpread2(_objectSpread2({}, restProps), {}, { 2809 innerProps, 2810 isRtl, 2811 size 2812 }), "loadingIndicator", { 2813 indicator: true, 2814 "loading-indicator": true 2815 }), innerProps), jsx2(LoadingDot, { 2816 delay: 0, 2817 offset: isRtl 2818 }), jsx2(LoadingDot, { 2819 delay: 160, 2820 offset: true 2821 }), jsx2(LoadingDot, { 2822 delay: 320, 2823 offset: !isRtl 2824 })); 2825}; 2826var css$1 = function css2(_ref3, unstyled) { 2827 var isDisabled = _ref3.isDisabled, isFocused = _ref3.isFocused, _ref$theme = _ref3.theme, colors2 = _ref$theme.colors, borderRadius2 = _ref$theme.borderRadius, spacing2 = _ref$theme.spacing; 2828 return _objectSpread2({ 2829 label: "control", 2830 alignItems: "center", 2831 cursor: "default", 2832 display: "flex", 2833 flexWrap: "wrap", 2834 justifyContent: "space-between", 2835 minHeight: spacing2.controlHeight, 2836 outline: "0 !important", 2837 position: "relative", 2838 transition: "all 100ms" 2839 }, unstyled ? {} : { 2840 backgroundColor: isDisabled ? colors2.neutral5 : colors2.neutral0, 2841 borderColor: isDisabled ? colors2.neutral10 : isFocused ? colors2.primary : colors2.neutral20, 2842 borderRadius: borderRadius2, 2843 borderStyle: "solid", 2844 borderWidth: 1, 2845 boxShadow: isFocused ? "0 0 0 1px ".concat(colors2.primary) : void 0, 2846 "&:hover": { 2847 borderColor: isFocused ? colors2.primary : colors2.neutral30 2848 } 2849 }); 2850}; 2851var Control = function Control2(props) { 2852 var children = props.children, isDisabled = props.isDisabled, isFocused = props.isFocused, innerRef = props.innerRef, innerProps = props.innerProps, menuIsOpen = props.menuIsOpen; 2853 return jsx2("div", _extends({ 2854 ref: innerRef 2855 }, getStyleProps(props, "control", { 2856 control: true, 2857 "control--is-disabled": isDisabled, 2858 "control--is-focused": isFocused, 2859 "control--menu-is-open": menuIsOpen 2860 }), innerProps, { 2861 "aria-disabled": isDisabled || void 0 2862 }), children); 2863}; 2864var Control$1 = Control; 2865var _excluded$1 = ["data"]; 2866var groupCSS = function groupCSS2(_ref3, unstyled) { 2867 var spacing2 = _ref3.theme.spacing; 2868 return unstyled ? {} : { 2869 paddingBottom: spacing2.baseUnit * 2, 2870 paddingTop: spacing2.baseUnit * 2 2871 }; 2872}; 2873var Group = function Group2(props) { 2874 var children = props.children, cx = props.cx, getStyles = props.getStyles, getClassNames = props.getClassNames, Heading = props.Heading, headingProps = props.headingProps, innerProps = props.innerProps, label = props.label, theme = props.theme, selectProps = props.selectProps; 2875 return jsx2("div", _extends({}, getStyleProps(props, "group", { 2876 group: true 2877 }), innerProps), jsx2(Heading, _extends({}, headingProps, { 2878 selectProps, 2879 theme, 2880 getStyles, 2881 getClassNames, 2882 cx 2883 }), label), jsx2("div", null, children)); 2884}; 2885var groupHeadingCSS = function groupHeadingCSS2(_ref23, unstyled) { 2886 var _ref2$theme = _ref23.theme, colors2 = _ref2$theme.colors, spacing2 = _ref2$theme.spacing; 2887 return _objectSpread2({ 2888 label: "group", 2889 cursor: "default", 2890 display: "block" 2891 }, unstyled ? {} : { 2892 color: colors2.neutral40, 2893 fontSize: "75%", 2894 fontWeight: 500, 2895 marginBottom: "0.25em", 2896 paddingLeft: spacing2.baseUnit * 3, 2897 paddingRight: spacing2.baseUnit * 3, 2898 textTransform: "uppercase" 2899 }); 2900}; 2901var GroupHeading = function GroupHeading2(props) { 2902 var _cleanCommonProps = cleanCommonProps(props); 2903 _cleanCommonProps.data; 2904 var innerProps = _objectWithoutProperties(_cleanCommonProps, _excluded$1); 2905 return jsx2("div", _extends({}, getStyleProps(props, "groupHeading", { 2906 "group-heading": true 2907 }), innerProps)); 2908}; 2909var Group$1 = Group; 2910var _excluded3 = ["innerRef", "isDisabled", "isHidden", "inputClassName"]; 2911var inputCSS = function inputCSS2(_ref3, unstyled) { 2912 var isDisabled = _ref3.isDisabled, value = _ref3.value, _ref$theme = _ref3.theme, spacing2 = _ref$theme.spacing, colors2 = _ref$theme.colors; 2913 return _objectSpread2(_objectSpread2({ 2914 visibility: isDisabled ? "hidden" : "visible", 2915 // force css to recompute when value change due to @emotion bug. 2916 // We can remove it whenever the bug is fixed. 2917 transform: value ? "translateZ(0)" : "" 2918 }, containerStyle), unstyled ? {} : { 2919 margin: spacing2.baseUnit / 2, 2920 paddingBottom: spacing2.baseUnit / 2, 2921 paddingTop: spacing2.baseUnit / 2, 2922 color: colors2.neutral80 2923 }); 2924}; 2925var spacingStyle = { 2926 gridArea: "1 / 2", 2927 font: "inherit", 2928 minWidth: "2px", 2929 border: 0, 2930 margin: 0, 2931 outline: 0, 2932 padding: 0 2933}; 2934var containerStyle = { 2935 flex: "1 1 auto", 2936 display: "inline-grid", 2937 gridArea: "1 / 1 / 2 / 3", 2938 gridTemplateColumns: "0 min-content", 2939 "&:after": _objectSpread2({ 2940 content: 'attr(data-value) " "', 2941 visibility: "hidden", 2942 whiteSpace: "pre" 2943 }, spacingStyle) 2944}; 2945var inputStyle = function inputStyle2(isHidden) { 2946 return _objectSpread2({ 2947 label: "input", 2948 color: "inherit", 2949 background: 0, 2950 opacity: isHidden ? 0 : 1, 2951 width: "100%" 2952 }, spacingStyle); 2953}; 2954var Input = function Input2(props) { 2955 var cx = props.cx, value = props.value; 2956 var _cleanCommonProps = cleanCommonProps(props), innerRef = _cleanCommonProps.innerRef, isDisabled = _cleanCommonProps.isDisabled, isHidden = _cleanCommonProps.isHidden, inputClassName = _cleanCommonProps.inputClassName, innerProps = _objectWithoutProperties(_cleanCommonProps, _excluded3); 2957 return jsx2("div", _extends({}, getStyleProps(props, "input", { 2958 "input-container": true 2959 }), { 2960 "data-value": value || "" 2961 }), jsx2("input", _extends({ 2962 className: cx({ 2963 input: true 2964 }, inputClassName), 2965 ref: innerRef, 2966 style: inputStyle(isHidden), 2967 disabled: isDisabled 2968 }, innerProps))); 2969}; 2970var Input$1 = Input; 2971var multiValueCSS = function multiValueCSS2(_ref3, unstyled) { 2972 var _ref$theme = _ref3.theme, spacing2 = _ref$theme.spacing, borderRadius2 = _ref$theme.borderRadius, colors2 = _ref$theme.colors; 2973 return _objectSpread2({ 2974 label: "multiValue", 2975 display: "flex", 2976 minWidth: 0 2977 }, unstyled ? {} : { 2978 backgroundColor: colors2.neutral10, 2979 borderRadius: borderRadius2 / 2, 2980 margin: spacing2.baseUnit / 2 2981 }); 2982}; 2983var multiValueLabelCSS = function multiValueLabelCSS2(_ref23, unstyled) { 2984 var _ref2$theme = _ref23.theme, borderRadius2 = _ref2$theme.borderRadius, colors2 = _ref2$theme.colors, cropWithEllipsis = _ref23.cropWithEllipsis; 2985 return _objectSpread2({ 2986 overflow: "hidden", 2987 textOverflow: cropWithEllipsis || cropWithEllipsis === void 0 ? "ellipsis" : void 0, 2988 whiteSpace: "nowrap" 2989 }, unstyled ? {} : { 2990 borderRadius: borderRadius2 / 2, 2991 color: colors2.neutral80, 2992 fontSize: "85%", 2993 padding: 3, 2994 paddingLeft: 6 2995 }); 2996}; 2997var multiValueRemoveCSS = function multiValueRemoveCSS2(_ref3, unstyled) { 2998 var _ref3$theme = _ref3.theme, spacing2 = _ref3$theme.spacing, borderRadius2 = _ref3$theme.borderRadius, colors2 = _ref3$theme.colors, isFocused = _ref3.isFocused; 2999 return _objectSpread2({ 3000 alignItems: "center", 3001 display: "flex" 3002 }, unstyled ? {} : { 3003 borderRadius: borderRadius2 / 2, 3004 backgroundColor: isFocused ? colors2.dangerLight : void 0, 3005 paddingLeft: spacing2.baseUnit, 3006 paddingRight: spacing2.baseUnit, 3007 ":hover": { 3008 backgroundColor: colors2.dangerLight, 3009 color: colors2.danger 3010 } 3011 }); 3012}; 3013var MultiValueGeneric = function MultiValueGeneric2(_ref4) { 3014 var children = _ref4.children, innerProps = _ref4.innerProps; 3015 return jsx2("div", innerProps, children); 3016}; 3017var MultiValueContainer = MultiValueGeneric; 3018var MultiValueLabel = MultiValueGeneric; 3019function MultiValueRemove(_ref5) { 3020 var children = _ref5.children, innerProps = _ref5.innerProps; 3021 return jsx2("div", _extends({ 3022 role: "button" 3023 }, innerProps), children || jsx2(CrossIcon, { 3024 size: 14 3025 })); 3026} 3027var MultiValue = function MultiValue2(props) { 3028 var children = props.children, components2 = props.components, data = props.data, innerProps = props.innerProps, isDisabled = props.isDisabled, removeProps3 = props.removeProps, selectProps = props.selectProps; 3029 var Container = components2.Container, Label = components2.Label, Remove = components2.Remove; 3030 return jsx2(Container, { 3031 data, 3032 innerProps: _objectSpread2(_objectSpread2({}, getStyleProps(props, "multiValue", { 3033 "multi-value": true, 3034 "multi-value--is-disabled": isDisabled 3035 })), innerProps), 3036 selectProps 3037 }, jsx2(Label, { 3038 data, 3039 innerProps: _objectSpread2({}, getStyleProps(props, "multiValueLabel", { 3040 "multi-value__label": true 3041 })), 3042 selectProps 3043 }, children), jsx2(Remove, { 3044 data, 3045 innerProps: _objectSpread2(_objectSpread2({}, getStyleProps(props, "multiValueRemove", { 3046 "multi-value__remove": true 3047 })), {}, { 3048 "aria-label": "Remove ".concat(children || "option") 3049 }, removeProps3), 3050 selectProps 3051 })); 3052}; 3053var MultiValue$1 = MultiValue; 3054var optionCSS = function optionCSS2(_ref3, unstyled) { 3055 var isDisabled = _ref3.isDisabled, isFocused = _ref3.isFocused, isSelected = _ref3.isSelected, _ref$theme = _ref3.theme, spacing2 = _ref$theme.spacing, colors2 = _ref$theme.colors; 3056 return _objectSpread2({ 3057 label: "option", 3058 cursor: "default", 3059 display: "block", 3060 fontSize: "inherit", 3061 width: "100%", 3062 userSelect: "none", 3063 WebkitTapHighlightColor: "rgba(0, 0, 0, 0)" 3064 }, unstyled ? {} : { 3065 backgroundColor: isSelected ? colors2.primary : isFocused ? colors2.primary25 : "transparent", 3066 color: isDisabled ? colors2.neutral20 : isSelected ? colors2.neutral0 : "inherit", 3067 padding: "".concat(spacing2.baseUnit * 2, "px ").concat(spacing2.baseUnit * 3, "px"), 3068 // provide some affordance on touch devices 3069 ":active": { 3070 backgroundColor: !isDisabled ? isSelected ? colors2.primary : colors2.primary50 : void 0 3071 } 3072 }); 3073}; 3074var Option = function Option2(props) { 3075 var children = props.children, isDisabled = props.isDisabled, isFocused = props.isFocused, isSelected = props.isSelected, innerRef = props.innerRef, innerProps = props.innerProps; 3076 return jsx2("div", _extends({}, getStyleProps(props, "option", { 3077 option: true, 3078 "option--is-disabled": isDisabled, 3079 "option--is-focused": isFocused, 3080 "option--is-selected": isSelected 3081 }), { 3082 ref: innerRef, 3083 "aria-disabled": isDisabled 3084 }, innerProps), children); 3085}; 3086var Option$1 = Option; 3087var placeholderCSS = function placeholderCSS2(_ref3, unstyled) { 3088 var _ref$theme = _ref3.theme, spacing2 = _ref$theme.spacing, colors2 = _ref$theme.colors; 3089 return _objectSpread2({ 3090 label: "placeholder", 3091 gridArea: "1 / 1 / 2 / 3" 3092 }, unstyled ? {} : { 3093 color: colors2.neutral50, 3094 marginLeft: spacing2.baseUnit / 2, 3095 marginRight: spacing2.baseUnit / 2 3096 }); 3097}; 3098var Placeholder = function Placeholder2(props) { 3099 var children = props.children, innerProps = props.innerProps; 3100 return jsx2("div", _extends({}, getStyleProps(props, "placeholder", { 3101 placeholder: true 3102 }), innerProps), children); 3103}; 3104var Placeholder$1 = Placeholder; 3105var css3 = function css4(_ref3, unstyled) { 3106 var isDisabled = _ref3.isDisabled, _ref$theme = _ref3.theme, spacing2 = _ref$theme.spacing, colors2 = _ref$theme.colors; 3107 return _objectSpread2({ 3108 label: "singleValue", 3109 gridArea: "1 / 1 / 2 / 3", 3110 maxWidth: "100%", 3111 overflow: "hidden", 3112 textOverflow: "ellipsis", 3113 whiteSpace: "nowrap" 3114 }, unstyled ? {} : { 3115 color: isDisabled ? colors2.neutral40 : colors2.neutral80, 3116 marginLeft: spacing2.baseUnit / 2, 3117 marginRight: spacing2.baseUnit / 2 3118 }); 3119}; 3120var SingleValue = function SingleValue2(props) { 3121 var children = props.children, isDisabled = props.isDisabled, innerProps = props.innerProps; 3122 return jsx2("div", _extends({}, getStyleProps(props, "singleValue", { 3123 "single-value": true, 3124 "single-value--is-disabled": isDisabled 3125 }), innerProps), children); 3126}; 3127var SingleValue$1 = SingleValue; 3128var components = { 3129 ClearIndicator, 3130 Control: Control$1, 3131 DropdownIndicator, 3132 DownChevron, 3133 CrossIcon, 3134 Group: Group$1, 3135 GroupHeading, 3136 IndicatorsContainer, 3137 IndicatorSeparator, 3138 Input: Input$1, 3139 LoadingIndicator, 3140 Menu: Menu$1, 3141 MenuList, 3142 MenuPortal, 3143 LoadingMessage, 3144 NoOptionsMessage, 3145 MultiValue: MultiValue$1, 3146 MultiValueContainer, 3147 MultiValueLabel, 3148 MultiValueRemove, 3149 Option: Option$1, 3150 Placeholder: Placeholder$1, 3151 SelectContainer, 3152 SingleValue: SingleValue$1, 3153 ValueContainer 3154}; 3155var defaultComponents = function defaultComponents2(props) { 3156 return _objectSpread2(_objectSpread2({}, components), props.components); 3157}; 3158
vendor: 1,276 bytes, lines 3159-3209
3159// node_modules/.pnpm/[email protected]/node_modules/memoize-one/dist/memoize-one.esm.js 3160var safeIsNaN = Number.isNaN || function ponyfill(value) { 3161 return typeof value === "number" && value !== value; 3162}; 3163function isEqual(first, second) { 3164 if (first === second) { 3165 return true; 3166 } 3167 if (safeIsNaN(first) && safeIsNaN(second)) { 3168 return true; 3169 } 3170 return false; 3171} 3172function areInputsEqual(newInputs, lastInputs) { 3173 if (newInputs.length !== lastInputs.length) { 3174 return false; 3175 } 3176 for (var i3 = 0; i3 < newInputs.length; i3++) { 3177 if (!isEqual(newInputs[i3], lastInputs[i3])) { 3178 return false; 3179 } 3180 } 3181 return true; 3182} 3183function memoizeOne(resultFn, isEqual3) { 3184 if (isEqual3 === void 0) { 3185 isEqual3 = areInputsEqual; 3186 } 3187 var cache = null; 3188 function memoized() { 3189 var newArgs = []; 3190 for (var _i2 = 0; _i2 < arguments.length; _i2++) { 3191 newArgs[_i2] = arguments[_i2]; 3192 } 3193 if (cache && cache.lastThis === this && isEqual3(newArgs, cache.lastArgs)) { 3194 return cache.lastResult; 3195 } 3196 var lastResult = resultFn.apply(this, newArgs); 3197 cache = { 3198 lastResult, 3199 lastArgs: newArgs, 3200 lastThis: this 3201 }; 3202 return lastResult; 3203 } 3204 memoized.clear = function clear2() { 3205 cache = null; 3206 }; 3207 return memoized; 3208} 3209
vendor: 90,780 bytes, lines 3210-5494
3210// node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/react-select/dist/Select-49a62830.esm.js 3211var _ref = true ? { 3212 name: "7pg0cj-a11yText", 3213 styles: "label:a11yText;z-index:9999;border:0;clip:rect(1px, 1px, 1px, 1px);height:1px;width:1px;position:absolute;overflow:hidden;padding:0;white-space:nowrap" 3214} : { 3215 name: "1f43avz-a11yText-A11yText", 3216 styles: "label:a11yText;z-index:9999;border:0;clip:rect(1px, 1px, 1px, 1px);height:1px;width:1px;position:absolute;overflow:hidden;padding:0;white-space:nowrap;label:A11yText;", 3217 map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkExMXlUZXh0LnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFNSSIsImZpbGUiOiJBMTF5VGV4dC50c3giLCJzb3VyY2VzQ29udGVudCI6WyIvKiogQGpzeCBqc3ggKi9cbmltcG9ydCB7IGpzeCB9IGZyb20gJ0BlbW90aW9uL3JlYWN0JztcblxuLy8gQXNzaXN0aXZlIHRleHQgdG8gZGVzY3JpYmUgdmlzdWFsIGVsZW1lbnRzLiBIaWRkZW4gZm9yIHNpZ2h0ZWQgdXNlcnMuXG5jb25zdCBBMTF5VGV4dCA9IChwcm9wczogSlNYLkludHJpbnNpY0VsZW1lbnRzWydzcGFuJ10pID0+IChcbiAgPHNwYW5cbiAgICBjc3M9e3tcbiAgICAgIGxhYmVsOiAnYTExeVRleHQnLFxuICAgICAgekluZGV4OiA5OTk5LFxuICAgICAgYm9yZGVyOiAwLFxuICAgICAgY2xpcDogJ3JlY3QoMXB4LCAxcHgsIDFweCwgMXB4KScsXG4gICAgICBoZWlnaHQ6IDEsXG4gICAgICB3aWR0aDogMSxcbiAgICAgIHBvc2l0aW9uOiAnYWJzb2x1dGUnLFxuICAgICAgb3ZlcmZsb3c6ICdoaWRkZW4nLFxuICAgICAgcGFkZGluZzogMCxcbiAgICAgIHdoaXRlU3BhY2U6ICdub3dyYXAnLFxuICAgIH19XG4gICAgey4uLnByb3BzfVxuICAvPlxuKTtcblxuZXhwb3J0IGRlZmF1bHQgQTExeVRleHQ7XG4iXX0= */", 3218 toString: _EMOTION_STRINGIFIED_CSS_ERROR__$2 3219}; 3220var A11yText = function A11yText2(props) { 3221 return jsx2("span", _extends({ 3222 css: _ref 3223 }, props)); 3224}; 3225var A11yText$1 = A11yText; 3226var defaultAriaLiveMessages = { 3227 guidance: function guidance(props) { 3228 var isSearchable = props.isSearchable, isMulti = props.isMulti, tabSelectsValue = props.tabSelectsValue, context = props.context, isInitialFocus = props.isInitialFocus; 3229 switch (context) { 3230 case "menu": 3231 return "Use Up and Down to choose options, press Enter to select the currently focused option, press Escape to exit the menu".concat(tabSelectsValue ? ", press Tab to select the option and exit the menu" : "", "."); 3232 case "input": 3233 return isInitialFocus ? "".concat(props["aria-label"] || "Select", " is focused ").concat(isSearchable ? ",type to refine list" : "", ", press Down to open the menu, ").concat(isMulti ? " press left to focus selected values" : "") : ""; 3234 case "value": 3235 return "Use left and right to toggle between focused values, press Backspace to remove the currently focused value"; 3236 default: 3237 return ""; 3238 } 3239 }, 3240 onChange: function onChange(props) { 3241 var action = props.action, _props$label = props.label, label = _props$label === void 0 ? "" : _props$label, labels = props.labels, isDisabled = props.isDisabled; 3242 switch (action) { 3243 case "deselect-option": 3244 case "pop-value": 3245 case "remove-value": 3246 return "option ".concat(label, ", deselected."); 3247 case "clear": 3248 return "All selected options have been cleared."; 3249 case "initial-input-focus": 3250 return "option".concat(labels.length > 1 ? "s" : "", " ").concat(labels.join(","), ", selected."); 3251 case "select-option": 3252 return isDisabled ? "option ".concat(label, " is disabled. Select another option.") : "option ".concat(label, ", selected."); 3253 default: 3254 return ""; 3255 } 3256 }, 3257 onFocus: function onFocus(props) { 3258 var context = props.context, focused = props.focused, options2 = props.options, _props$label2 = props.label, label = _props$label2 === void 0 ? "" : _props$label2, selectValue = props.selectValue, isDisabled = props.isDisabled, isSelected = props.isSelected, isAppleDevice2 = props.isAppleDevice; 3259 var getArrayIndex = function getArrayIndex2(arr, item) { 3260 return arr && arr.length ? "".concat(arr.indexOf(item) + 1, " of ").concat(arr.length) : ""; 3261 }; 3262 if (context === "value" && selectValue) { 3263 return "value ".concat(label, " focused, ").concat(getArrayIndex(selectValue, focused), "."); 3264 } 3265 if (context === "menu" && isAppleDevice2) { 3266 var disabled = isDisabled ? " disabled" : ""; 3267 var status2 = "".concat(isSelected ? " selected" : "").concat(disabled); 3268 return "".concat(label).concat(status2, ", ").concat(getArrayIndex(options2, focused), "."); 3269 } 3270 return ""; 3271 }, 3272 onFilter: function onFilter(props) { 3273 var inputValue = props.inputValue, resultsMessage = props.resultsMessage; 3274 return "".concat(resultsMessage).concat(inputValue ? " for search term " + inputValue : "", "."); 3275 } 3276}; 3277var LiveRegion = function LiveRegion2(props) { 3278 var ariaSelection = props.ariaSelection, focusedOption = props.focusedOption, focusedValue = props.focusedValue, focusableOptions = props.focusableOptions, isFocused = props.isFocused, selectValue = props.selectValue, selectProps = props.selectProps, id = props.id, isAppleDevice2 = props.isAppleDevice; 3279 var ariaLiveMessages = selectProps.ariaLiveMessages, getOptionLabel4 = selectProps.getOptionLabel, inputValue = selectProps.inputValue, isMulti = selectProps.isMulti, isOptionDisabled3 = selectProps.isOptionDisabled, isSearchable = selectProps.isSearchable, menuIsOpen = selectProps.menuIsOpen, options2 = selectProps.options, screenReaderStatus2 = selectProps.screenReaderStatus, tabSelectsValue = selectProps.tabSelectsValue, isLoading = selectProps.isLoading; 3280 var ariaLabel = selectProps["aria-label"]; 3281 var ariaLive = selectProps["aria-live"]; 3282 var messages = (0, import_react6.useMemo)(function() { 3283 return _objectSpread2(_objectSpread2({}, defaultAriaLiveMessages), ariaLiveMessages || {}); 3284 }, [ariaLiveMessages]); 3285 var ariaSelected = (0, import_react6.useMemo)(function() { 3286 var message = ""; 3287 if (ariaSelection && messages.onChange) { 3288 var option = ariaSelection.option, selectedOptions = ariaSelection.options, removedValue = ariaSelection.removedValue, removedValues = ariaSelection.removedValues, value = ariaSelection.value; 3289 var asOption = function asOption2(val) { 3290 return !Array.isArray(val) ? val : null; 3291 }; 3292 var selected = removedValue || option || asOption(value); 3293 var label = selected ? getOptionLabel4(selected) : ""; 3294 var multiSelected = selectedOptions || removedValues || void 0; 3295 var labels = multiSelected ? multiSelected.map(getOptionLabel4) : []; 3296 var onChangeProps = _objectSpread2({ 3297 // multiSelected items are usually items that have already been selected 3298 // or set by the user as a default value so we assume they are not disabled 3299 isDisabled: selected && isOptionDisabled3(selected, selectValue), 3300 label, 3301 labels 3302 }, ariaSelection); 3303 message = messages.onChange(onChangeProps); 3304 } 3305 return message; 3306 }, [ariaSelection, messages, isOptionDisabled3, selectValue, getOptionLabel4]); 3307 var ariaFocused = (0, import_react6.useMemo)(function() { 3308 var focusMsg = ""; 3309 var focused = focusedOption || focusedValue; 3310 var isSelected = !!(focusedOption && selectValue && selectValue.includes(focusedOption)); 3311 if (focused && messages.onFocus) { 3312 var onFocusProps = { 3313 focused, 3314 label: getOptionLabel4(focused), 3315 isDisabled: isOptionDisabled3(focused, selectValue), 3316 isSelected, 3317 options: focusableOptions, 3318 context: focused === focusedOption ? "menu" : "value", 3319 selectValue, 3320 isAppleDevice: isAppleDevice2 3321 }; 3322 focusMsg = messages.onFocus(onFocusProps); 3323 } 3324 return focusMsg; 3325 }, [focusedOption, focusedValue, getOptionLabel4, isOptionDisabled3, messages, focusableOptions, selectValue, isAppleDevice2]); 3326 var ariaResults = (0, import_react6.useMemo)(function() { 3327 var resultsMsg = ""; 3328 if (menuIsOpen && options2.length && !isLoading && messages.onFilter) { 3329 var resultsMessage = screenReaderStatus2({ 3330 count: focusableOptions.length 3331 }); 3332 resultsMsg = messages.onFilter({ 3333 inputValue, 3334 resultsMessage 3335 }); 3336 } 3337 return resultsMsg; 3338 }, [focusableOptions, inputValue, menuIsOpen, messages, options2, screenReaderStatus2, isLoading]); 3339 var isInitialFocus = (ariaSelection === null || ariaSelection === void 0 ? void 0 : ariaSelection.action) === "initial-input-focus"; 3340 var ariaGuidance = (0, import_react6.useMemo)(function() { 3341 var guidanceMsg = ""; 3342 if (messages.guidance) { 3343 var context = focusedValue ? "value" : menuIsOpen ? "menu" : "input"; 3344 guidanceMsg = messages.guidance({ 3345 "aria-label": ariaLabel, 3346 context, 3347 isDisabled: focusedOption && isOptionDisabled3(focusedOption, selectValue), 3348 isMulti, 3349 isSearchable, 3350 tabSelectsValue, 3351 isInitialFocus 3352 }); 3353 } 3354 return guidanceMsg; 3355 }, [ariaLabel, focusedOption, focusedValue, isMulti, isOptionDisabled3, isSearchable, menuIsOpen, messages, selectValue, tabSelectsValue, isInitialFocus]); 3356 var ScreenReaderText = jsx2(import_react6.Fragment, null, jsx2("span", { 3357 id: "aria-selection" 3358 }, ariaSelected), jsx2("span", { 3359 id: "aria-focused" 3360 }, ariaFocused), jsx2("span", { 3361 id: "aria-results" 3362 }, ariaResults), jsx2("span", { 3363 id: "aria-guidance" 3364 }, ariaGuidance)); 3365 return jsx2(import_react6.Fragment, null, jsx2(A11yText$1, { 3366 id 3367 }, isInitialFocus && ScreenReaderText), jsx2(A11yText$1, { 3368 "aria-live": ariaLive, 3369 "aria-atomic": "false", 3370 "aria-relevant": "additions text", 3371 role: "log" 3372 }, isFocused && !isInitialFocus && ScreenReaderText)); 3373}; 3374var LiveRegion$1 = LiveRegion; 3375var diacritics = [{ 3376 base: "A", 3377 letters: "Aâ¶ï¼¡ÃÃÃẦẤẪẨÃÄÄáº°áº®áº´áº²È¦Ç ÃÇẢà ǺÇÈÈẠẬẶá¸ÄȺⱯ" 3378}, { 3379 base: "AA", 3380 letters: "ê²" 3381}, { 3382 base: "AE", 3383 letters: "ÃǼǢ" 3384}, { 3385 base: "AO", 3386 letters: "ê´" 3387}, { 3388 base: "AU", 3389 letters: "ê¶" 3390}, { 3391 base: "AV", 3392 letters: "ê¸êº" 3393}, { 3394 base: "AY", 3395 letters: "ê¼" 3396}, { 3397 base: "B", 3398 letters: "Bâ·ï¼¢á¸á¸á¸ÉÆÆ" 3399}, { 3400 base: "C", 3401 letters: "Câ¸ï¼£ÄÄÄÄÃá¸ÆÈ»ê¾" 3402}, { 3403 base: "D", 3404 letters: "Dâ¹ï¼¤á¸Äá¸á¸á¸á¸ÄÆÆÆê¹" 3405}, { 3406 base: "DZ", 3407 letters: "DZÇ" 3408}, { 3409 base: "Dz", 3410 letters: "Ç²Ç " 3411}, { 3412 base: "E", 3413 letters: "Eâºï¼¥ÃÃÃá»áº¾á»á»áº¼Äá¸á¸ÄÄÃẺÄÈÈẸá»È¨á¸Äá¸á¸ÆÆ" 3414}, { 3415 base: "F", 3416 letters: "Fâ»ï¼¦á¸Æê»" 3417}, { 3418 base: "G", 3419 letters: "Gâ¼ï¼§Ç´ÄḠÄÄ Ç¦Ä¢Ç¤Æê ê½ê¾" 3420}, { 3421 base: "H", 3422 letters: "Hâ½ï¼¨Ä¤á¸¢á¸¦ÈḤḨḪĦⱧⱵê" 3423}, { 3424 base: "I", 3425 letters: "Iâ¾ï¼©ÃÃÃĨĪĬİÃḮá»ÇÈÈá»Ä®á¸¬Æ" 3426}, { 3427 base: "J", 3428 letters: "Jâ¿ï¼ªÄ´É" 3429}, { 3430 base: "K", 3431 letters: "KâKḰǨḲĶḴÆâ±©êêêê¢" 3432}, { 3433 base: "L", 3434 letters: "LâLĿĹĽḶḸĻḼḺÅȽⱢⱠêêê" 3435}, { 3436 base: "LJ", 3437 letters: "Ç" 3438}, { 3439 base: "Lj", 3440 letters: "Ç" 3441}, { 3442 base: "M", 3443 letters: "Mâï¼á¸¾á¹á¹â±®Æ" 3444}, { 3445 base: "N", 3446 letters: "NâNǸÅÃá¹Åá¹Å á¹á¹È Æêê¤" 3447}, { 3448 base: "NJ", 3449 letters: "Ç" 3450}, { 3451 base: "Nj", 3452 letters: "Ç" 3453}, { 3454 base: "O", 3455 letters: "OâOÃÃÃá»á»á»á»Ãá¹È¬á¹Åá¹á¹ÅȮȰÃȪá»ÅÇÈÈÆ á»á»á» á»á»¢á»á»ÇªÇ¬ÃÇ¾ÆÆêê" 3456}, { 3457 base: "OI", 3458 letters: "Æ¢" 3459}, { 3460 base: "OO", 3461 letters: "ê" 3462}, { 3463 base: "OU", 3464 letters: "È¢" 3465}, { 3466 base: "P", 3467 letters: "Pâ ï¼°á¹á¹Æ¤â±£êêê" 3468}, { 3469 base: "Q", 3470 letters: "Qâï¼±êêÉ" 3471}, { 3472 base: "R", 3473 letters: "Râï¼²Åá¹ÅÈÈá¹á¹Åá¹ÉⱤêê¦ê" 3474}, { 3475 base: "S", 3476 letters: "Sâï¼³áºÅṤÅṠŠṦṢṨÈÅâ±¾ê¨ê" 3477}, { 3478 base: "T", 3479 letters: "TâTṪŤṬÈŢṰṮŦƬƮȾê" 3480}, { 3481 base: "TZ", 3482 letters: "ê¨" 3483}, { 3484 base: "U", 3485 letters: "Uâï¼µÃÃÃŨṸŪṺŬÃÇÇÇÇỦŮŰÇÈÈÆ¯á»ªá»¨á»®á»¬á»°á»¤á¹²Å²á¹¶á¹´É" 3486}, { 3487 base: "V", 3488 letters: "VâVṼṾƲêÉ " 3489}, { 3490 base: "VY", 3491 letters: "ê " 3492}, { 3493 base: "W", 3494 letters: "Wâï¼·áºáºÅ´áºáºáºâ±²" 3495}, { 3496 base: "X", 3497 letters: "XâXáºáº" 3498}, { 3499 base: "Y", 3500 letters: "YâYỲÃŶỸȲáºÅ¸á»¶á»´Æ³ÉỾ" 3501}, { 3502 base: "Z", 3503 letters: "ZâZŹáºÅ»Å½áºáºÆµÈ¤â±¿â±«ê¢" 3504}, { 3505 base: "a", 3506 letters: "aâï½áºÃ áâầấẫẩãÄÄằắẵẳȧǡäÇảåǻÇÈÈạáºáº·á¸Ä â±¥É" 3507}, { 3508 base: "aa", 3509 letters: "ê³" 3510}, { 3511 base: "ae", 3512 letters: "æǽǣ" 3513}, { 3514 base: "ao", 3515 letters: "êµ" 3516}, { 3517 base: "au", 3518 letters: "ê·" 3519}, { 3520 base: "av", 3521 letters: "ê¹ê»" 3522}, { 3523 base: "ay", 3524 letters: "ê½" 3525}, { 3526 base: "b", 3527 letters: "bâï½á¸á¸ á¸ÆÆÉ" 3528}, { 3529 base: "c", 3530 letters: "câï½ÄÄÄÄÃ§á¸ÆÈ¼ê¿â" 3531}, { 3532 base: "d", 3533 letters: "dâï½á¸Äá¸á¸á¸á¸ÄÆÉÉêº" 3534}, { 3535 base: "dz", 3536 letters: "dzÇ" 3537}, { 3538 base: "e", 3539 letters: "eâï½ Ã¨Ã©Ãªá»áº¿á» á»áº½Äá¸á¸ÄÄëẻÄÈ Èẹá»È©á¸Äá¸á¸ÉÉÇ" 3540}, { 3541 base: "f", 3542 letters: "fâï½á¸Æê¼" 3543}, { 3544 base: "g", 3545 letters: "gâï½ÇµÄḡÄÄ¡Ç§Ä£Ç¥É ê¡áµ¹ê¿" 3546}, { 3547 base: "h", 3548 letters: "hâï½Ä¥á¸£á¸§ÈḥḩḫáºÄ§â±¨â±¶É¥" 3549}, { 3550 base: "hv", 3551 letters: "Æ" 3552}, { 3553 base: "i", 3554 letters: "iâï½Ã¬ÃîĩīÄïḯá»ÇÈÈá»Ä¯á¸É¨Ä±" 3555}, { 3556 base: "j", 3557 letters: "jâï½ÄµÇ°É" 3558}, { 3559 base: "k", 3560 letters: "kâï½á¸±Ç©á¸³Ä·á¸µÆâ±ªêêê ê£" 3561}, { 3562 base: "l", 3563 letters: "lâï½ÅÄºÄ¾á¸·á¸¹Ä¼á¸½á¸»Å¿ÅÆÉ«â±¡êêê" 3564}, { 3565 base: "lj", 3566 letters: "Ç" 3567}, { 3568 base: "m", 3569 letters: "mâï½á¸¿á¹á¹É±É¯" 3570}, { 3571 base: "n", 3572 letters: "nâï½Ç¹ÅñṠÅá¹Åá¹á¹ÆÉ²Åêê¥" 3573}, { 3574 base: "nj", 3575 letters: "Ç" 3576}, { 3577 base: "o", 3578 letters: "oâï½Ã²Ã³Ã´á»á»á»á»Ãµá¹Èá¹Åá¹á¹Åȯȱöȫá»ÅÇÈÈÆ¡á»á»á»¡á»á»£á»á»Ç«ÇøǿÉêêɵ" 3579}, { 3580 base: "oi", 3581 letters: "Æ£" 3582}, { 3583 base: "ou", 3584 letters: "È£" 3585}, { 3586 base: "oo", 3587 letters: "ê" 3588}, { 3589 base: "p", 3590 letters: "pâï½á¹á¹Æ¥áµ½êêê" 3591}, { 3592 base: "q", 3593 letters: "qâ ï½Éêê" 3594}, { 3595 base: "r", 3596 letters: "râ¡ï½Åá¹ÅÈÈá¹á¹Åá¹Éɽêê§ê" 3597}, { 3598 base: "s", 3599 letters: "sâ¢ï½ÃÅá¹¥ÅṡšṧṣṩÈÅÈ¿ê©ê áº" 3600}, { 3601 base: "t", 3602 letters: "tâ£ï½á¹«áºÅ¥á¹ÈţṱṯŧÆÊⱦê" 3603}, { 3604 base: "tz", 3605 letters: "ê©" 3606}, { 3607 base: "u", 3608 letters: "uâ¤ï½Ã¹ÃºÃ»Å©á¹¹Å«á¹»ÅüÇÇÇÇủůűÇÈÈÆ°á»«á»©á»¯á»á»±á»¥á¹³Å³á¹·á¹µÊ" 3609}, { 3610 base: "v", 3611 letters: "vâ¥ï½á¹½á¹¿ÊêÊ" 3612}, { 3613 base: "vy", 3614 letters: "ê¡" 3615}, { 3616 base: "w", 3617 letters: "wâ¦ï½áºáºÅµáºáº áºáºâ±³" 3618}, { 3619 base: "x", 3620 letters: "xâ§ï½áºáº" 3621}, { 3622 base: "y", 3623 letters: "yâ¨ï½á»³Ã½Å·á»¹È³áºÃ¿á»·áºá»µÆ´Éỿ" 3624}, { 3625 base: "z", 3626 letters: "zâ©ï½ÅºáºÅ¼Å¾áºáºÆ¶È¥Éⱬê£" 3627}]; 3628var anyDiacritic = new RegExp("[" + diacritics.map(function(d2) { 3629 return d2.letters; 3630}).join("") + "]", "g"); 3631var diacriticToBase = {}; 3632for (i3 = 0; i3 < diacritics.length; i3++) { 3633 diacritic = diacritics[i3]; 3634 for (j3 = 0; j3 < diacritic.letters.length; j3++) { 3635 diacriticToBase[diacritic.letters[j3]] = diacritic.base; 3636 } 3637} 3638var diacritic; 3639var j3; 3640var i3; 3641var stripDiacritics = function stripDiacritics2(str) { 3642 return str.replace(anyDiacritic, function(match2) { 3643 return diacriticToBase[match2]; 3644 }); 3645}; 3646var memoizedStripDiacriticsForInput = memoizeOne(stripDiacritics); 3647var trimString = function trimString2(str) { 3648 return str.replace(/^\s+|\s+$/g, ""); 3649}; 3650var defaultStringify = function defaultStringify2(option) { 3651 return "".concat(option.label, " ").concat(option.value); 3652}; 3653var createFilter = function createFilter2(config) { 3654 return function(option, rawInput) { 3655 if (option.data.__isNew__) return true; 3656 var _ignoreCase$ignoreAcc = _objectSpread2({ 3657 ignoreCase: true, 3658 ignoreAccents: true, 3659 stringify: defaultStringify, 3660 trim: true, 3661 matchFrom: "any" 3662 }, config), ignoreCase = _ignoreCase$ignoreAcc.ignoreCase, ignoreAccents = _ignoreCase$ignoreAcc.ignoreAccents, stringify4 = _ignoreCase$ignoreAcc.stringify, trim2 = _ignoreCase$ignoreAcc.trim, matchFrom = _ignoreCase$ignoreAcc.matchFrom; 3663 var input = trim2 ? trimString(rawInput) : rawInput; 3664 var candidate = trim2 ? trimString(stringify4(option)) : stringify4(option); 3665 if (ignoreCase) { 3666 input = input.toLowerCase(); 3667 candidate = candidate.toLowerCase(); 3668 } 3669 if (ignoreAccents) { 3670 input = memoizedStripDiacriticsForInput(input); 3671 candidate = stripDiacritics(candidate); 3672 } 3673 return matchFrom === "start" ? candidate.substr(0, input.length) === input : candidate.indexOf(input) > -1; 3674 }; 3675}; 3676var _excluded4 = ["innerRef"]; 3677function DummyInput(_ref3) { 3678 var innerRef = _ref3.innerRef, props = _objectWithoutProperties(_ref3, _excluded4); 3679 var filteredProps = removeProps(props, "onExited", "in", "enter", "exit", "appear"); 3680 return jsx2("input", _extends({ 3681 ref: innerRef 3682 }, filteredProps, { 3683 css: css({ 3684 label: "dummyInput", 3685 // get rid of any default styles 3686 background: 0, 3687 border: 0, 3688 // important! this hides the flashing cursor 3689 caretColor: "transparent", 3690 fontSize: "inherit", 3691 gridArea: "1 / 1 / 2 / 3", 3692 outline: 0, 3693 padding: 0, 3694 // important! without `width` browsers won't allow focus 3695 width: 1, 3696 // remove cursor on desktop 3697 color: "transparent", 3698 // remove cursor on mobile whilst maintaining "scroll into view" behaviour 3699 left: -100, 3700 opacity: 0, 3701 position: "relative", 3702 transform: "scale(.01)" 3703 }, true ? "" : ";label:DummyInput;", true ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkR1bW15SW5wdXQudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXlCTSIsImZpbGUiOiJEdW1teUlucHV0LnRzeCIsInNvdXJjZXNDb250ZW50IjpbIi8qKiBAanN4IGpzeCAqL1xuaW1wb3J0IHsgUmVmIH0gZnJvbSAncmVhY3QnO1xuaW1wb3J0IHsganN4IH0gZnJvbSAnQGVtb3Rpb24vcmVhY3QnO1xuaW1wb3J0IHsgcmVtb3ZlUHJvcHMgfSBmcm9tICcuLi91dGlscyc7XG5cbmV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIER1bW15SW5wdXQoe1xuICBpbm5lclJlZixcbiAgLi4ucHJvcHNcbn06IEpTWC5JbnRyaW5zaWNFbGVtZW50c1snaW5wdXQnXSAmIHtcbiAgcmVhZG9ubHkgaW5uZXJSZWY6IFJlZjxIVE1MSW5wdXRFbGVtZW50Pjtcbn0pIHtcbiAgLy8gUmVtb3ZlIGFuaW1hdGlvbiBwcm9wcyBub3QgbWVhbnQgZm9yIEhUTUwgZWxlbWVudHNcbiAgY29uc3QgZmlsdGVyZWRQcm9wcyA9IHJlbW92ZVByb3BzKFxuICAgIHByb3BzLFxuICAgICdvbkV4aXRlZCcsXG4gICAgJ2luJyxcbiAgICAnZW50ZXInLFxuICAgICdleGl0JyxcbiAgICAnYXBwZWFyJ1xuICApO1xuXG4gIHJldHVybiAoXG4gICAgPGlucHV0XG4gICAgICByZWY9e2lubmVyUmVmfVxuICAgICAgey4uLmZpbHRlcmVkUHJvcHN9XG4gICAgICBjc3M9e3tcbiAgICAgICAgbGFiZWw6ICdkdW1teUlucHV0JyxcbiAgICAgICAgLy8gZ2V0IHJpZCBvZiBhbnkgZGVmYXVsdCBzdHlsZXNcbiAgICAgICAgYmFja2dyb3VuZDogMCxcbiAgICAgICAgYm9yZGVyOiAwLFxuICAgICAgICAvLyBpbXBvcnRhbnQhIHRoaXMgaGlkZXMgdGhlIGZsYXNoaW5nIGN1cnNvclxuICAgICAgICBjYXJldENvbG9yOiAndHJhbnNwYXJlbnQnLFxuICAgICAgICBmb250U2l6ZTogJ2luaGVyaXQnLFxuICAgICAgICBncmlkQXJlYTogJzEgLyAxIC8gMiAvIDMnLFxuICAgICAgICBvdXRsaW5lOiAwLFxuICAgICAgICBwYWRkaW5nOiAwLFxuICAgICAgICAvLyBpbXBvcnRhbnQhIHdpdGhvdXQgYHdpZHRoYCBicm93c2VycyB3b24ndCBhbGxvdyBmb2N1c1xuICAgICAgICB3aWR0aDogMSxcblxuICAgICAgICAvLyByZW1vdmUgY3Vyc29yIG9uIGRlc2t0b3BcbiAgICAgICAgY29sb3I6ICd0cmFuc3BhcmVudCcsXG5cbiAgICAgICAgLy8gcmVtb3ZlIGN1cnNvciBvbiBtb2JpbGUgd2hpbHN0IG1haW50YWluaW5nIFwic2Nyb2xsIGludG8gdmlld1wiIGJlaGF2aW91clxuICAgICAgICBsZWZ0OiAtMTAwLFxuICAgICAgICBvcGFjaXR5OiAwLFxuICAgICAgICBwb3NpdGlvbjogJ3JlbGF0aXZlJyxcbiAgICAgICAgdHJhbnNmb3JtOiAnc2NhbGUoLjAxKScsXG4gICAgICB9fVxuICAgIC8+XG4gICk7XG59XG4iXX0= */") 3704 })); 3705} 3706var cancelScroll = function cancelScroll2(event) { 3707 if (event.cancelable) event.preventDefault(); 3708 event.stopPropagation(); 3709}; 3710function useScrollCapture(_ref3) { 3711 var isEnabled = _ref3.isEnabled, onBottomArrive = _ref3.onBottomArrive, onBottomLeave = _ref3.onBottomLeave, onTopArrive = _ref3.onTopArrive, onTopLeave = _ref3.onTopLeave; 3712 var isBottom = (0, import_react6.useRef)(false); 3713 var isTop = (0, import_react6.useRef)(false); 3714 var touchStart = (0, import_react6.useRef)(0); 3715 var scrollTarget = (0, import_react6.useRef)(null); 3716 var handleEventDelta = (0, import_react6.useCallback)(function(event, delta) { 3717 if (scrollTarget.current === null) return; 3718 var _scrollTarget$current = scrollTarget.current, scrollTop = _scrollTarget$current.scrollTop, scrollHeight = _scrollTarget$current.scrollHeight, clientHeight = _scrollTarget$current.clientHeight; 3719 var target = scrollTarget.current; 3720 var isDeltaPositive = delta > 0; 3721 var availableScroll = scrollHeight - clientHeight - scrollTop; 3722 var shouldCancelScroll = false; 3723 if (availableScroll > delta && isBottom.current) { 3724 if (onBottomLeave) onBottomLeave(event); 3725 isBottom.current = false; 3726 } 3727 if (isDeltaPositive && isTop.current) { 3728 if (onTopLeave) onTopLeave(event); 3729 isTop.current = false; 3730 } 3731 if (isDeltaPositive && delta > availableScroll) { 3732 if (onBottomArrive && !isBottom.current) { 3733 onBottomArrive(event); 3734 } 3735 target.scrollTop = scrollHeight; 3736 shouldCancelScroll = true; 3737 isBottom.current = true; 3738 } else if (!isDeltaPositive && -delta > scrollTop) { 3739 if (onTopArrive && !isTop.current) { 3740 onTopArrive(event); 3741 } 3742 target.scrollTop = 0; 3743 shouldCancelScroll = true; 3744 isTop.current = true; 3745 } 3746 if (shouldCancelScroll) { 3747 cancelScroll(event); 3748 } 3749 }, [onBottomArrive, onBottomLeave, onTopArrive, onTopLeave]); 3750 var onWheel = (0, import_react6.useCallback)(function(event) { 3751 handleEventDelta(event, event.deltaY); 3752 }, [handleEventDelta]); 3753 var onTouchStart = (0, import_react6.useCallback)(function(event) { 3754 touchStart.current = event.changedTouches[0].clientY; 3755 }, []); 3756 var onTouchMove = (0, import_react6.useCallback)(function(event) { 3757 var deltaY = touchStart.current - event.changedTouches[0].clientY; 3758 handleEventDelta(event, deltaY); 3759 }, [handleEventDelta]); 3760 var startListening = (0, import_react6.useCallback)(function(el) { 3761 if (!el) return; 3762 var notPassive = supportsPassiveEvents ? { 3763 passive: false 3764 } : false; 3765 el.addEventListener("wheel", onWheel, notPassive); 3766 el.addEventListener("touchstart", onTouchStart, notPassive); 3767 el.addEventListener("touchmove", onTouchMove, notPassive); 3768 }, [onTouchMove, onTouchStart, onWheel]); 3769 var stopListening = (0, import_react6.useCallback)(function(el) { 3770 if (!el) return; 3771 el.removeEventListener("wheel", onWheel, false); 3772 el.removeEventListener("touchstart", onTouchStart, false); 3773 el.removeEventListener("touchmove", onTouchMove, false); 3774 }, [onTouchMove, onTouchStart, onWheel]); 3775 (0, import_react6.useEffect)(function() { 3776 if (!isEnabled) return; 3777 var element = scrollTarget.current; 3778 startListening(element); 3779 return function() { 3780 stopListening(element); 3781 }; 3782 }, [isEnabled, startListening, stopListening]); 3783 return function(element) { 3784 scrollTarget.current = element; 3785 }; 3786} 3787var STYLE_KEYS = ["boxSizing", "height", "overflow", "paddingRight", "position"]; 3788var LOCK_STYLES = { 3789 boxSizing: "border-box", 3790 // account for possible declaration `width: 100%;` on body 3791 overflow: "hidden", 3792 position: "relative", 3793 height: "100%" 3794}; 3795function preventTouchMove(e) { 3796 e.preventDefault(); 3797} 3798function allowTouchMove(e) { 3799 e.stopPropagation(); 3800} 3801function preventInertiaScroll() { 3802 var top = this.scrollTop; 3803 var totalScroll = this.scrollHeight; 3804 var currentScroll = top + this.offsetHeight; 3805 if (top === 0) { 3806 this.scrollTop = 1; 3807 } else if (currentScroll === totalScroll) { 3808 this.scrollTop = top - 1; 3809 } 3810} 3811function isTouchDevice() { 3812 return "ontouchstart" in window || navigator.maxTouchPoints; 3813} 3814var canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement); 3815var activeScrollLocks = 0; 3816var listenerOptions = { 3817 capture: false, 3818 passive: false 3819}; 3820function useScrollLock(_ref3) { 3821 var isEnabled = _ref3.isEnabled, _ref$accountForScroll = _ref3.accountForScrollbars, accountForScrollbars = _ref$accountForScroll === void 0 ? true : _ref$accountForScroll; 3822 var originalStyles = (0, import_react6.useRef)({}); 3823 var scrollTarget = (0, import_react6.useRef)(null); 3824 var addScrollLock = (0, import_react6.useCallback)(function(touchScrollTarget) { 3825 if (!canUseDOM) return; 3826 var target = document.body; 3827 var targetStyle = target && target.style; 3828 if (accountForScrollbars) { 3829 STYLE_KEYS.forEach(function(key) { 3830 var val = targetStyle && targetStyle[key]; 3831 originalStyles.current[key] = val; 3832 }); 3833 } 3834 if (accountForScrollbars && activeScrollLocks < 1) { 3835 var currentPadding = parseInt(originalStyles.current.paddingRight, 10) || 0; 3836 var clientWidth = document.body ? document.body.clientWidth : 0; 3837 var adjustedPadding = window.innerWidth - clientWidth + currentPadding || 0; 3838 Object.keys(LOCK_STYLES).forEach(function(key) { 3839 var val = LOCK_STYLES[key]; 3840 if (targetStyle) { 3841 targetStyle[key] = val; 3842 } 3843 }); 3844 if (targetStyle) { 3845 targetStyle.paddingRight = "".concat(adjustedPadding, "px"); 3846 } 3847 } 3848 if (target && isTouchDevice()) { 3849 target.addEventListener("touchmove", preventTouchMove, listenerOptions); 3850 if (touchScrollTarget) { 3851 touchScrollTarget.addEventListener("touchstart", preventInertiaScroll, listenerOptions); 3852 touchScrollTarget.addEventListener("touchmove", allowTouchMove, listenerOptions); 3853 } 3854 } 3855 activeScrollLocks += 1; 3856 }, [accountForScrollbars]); 3857 var removeScrollLock = (0, import_react6.useCallback)(function(touchScrollTarget) { 3858 if (!canUseDOM) return; 3859 var target = document.body; 3860 var targetStyle = target && target.style; 3861 activeScrollLocks = Math.max(activeScrollLocks - 1, 0); 3862 if (accountForScrollbars && activeScrollLocks < 1) { 3863 STYLE_KEYS.forEach(function(key) { 3864 var val = originalStyles.current[key]; 3865 if (targetStyle) { 3866 targetStyle[key] = val; 3867 } 3868 }); 3869 } 3870 if (target && isTouchDevice()) { 3871 target.removeEventListener("touchmove", preventTouchMove, listenerOptions); 3872 if (touchScrollTarget) { 3873 touchScrollTarget.removeEventListener("touchstart", preventInertiaScroll, listenerOptions); 3874 touchScrollTarget.removeEventListener("touchmove", allowTouchMove, listenerOptions); 3875 } 3876 } 3877 }, [accountForScrollbars]); 3878 (0, import_react6.useEffect)(function() { 3879 if (!isEnabled) return; 3880 var element = scrollTarget.current; 3881 addScrollLock(element); 3882 return function() { 3883 removeScrollLock(element); 3884 }; 3885 }, [isEnabled, addScrollLock, removeScrollLock]); 3886 return function(element) { 3887 scrollTarget.current = element; 3888 }; 3889} 3890var blurSelectInput = function blurSelectInput2(event) { 3891 var element = event.target; 3892 return element.ownerDocument.activeElement && element.ownerDocument.activeElement.blur(); 3893}; 3894var _ref2$1 = true ? { 3895 name: "1kfdb0e", 3896 styles: "position:fixed;left:0;bottom:0;right:0;top:0" 3897} : { 3898 name: "bp8cua-ScrollManager", 3899 styles: "position:fixed;left:0;bottom:0;right:0;top:0;label:ScrollManager;", 3900 map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIlNjcm9sbE1hbmFnZXIudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQW9EVSIsImZpbGUiOiJTY3JvbGxNYW5hZ2VyLnRzeCIsInNvdXJjZXNDb250ZW50IjpbIi8qKiBAanN4IGpzeCAqL1xuaW1wb3J0IHsganN4IH0gZnJvbSAnQGVtb3Rpb24vcmVhY3QnO1xuaW1wb3J0IHsgRnJhZ21lbnQsIFJlYWN0RWxlbWVudCwgUmVmQ2FsbGJhY2ssIE1vdXNlRXZlbnQgfSBmcm9tICdyZWFjdCc7XG5pbXBvcnQgdXNlU2Nyb2xsQ2FwdHVyZSBmcm9tICcuL3VzZVNjcm9sbENhcHR1cmUnO1xuaW1wb3J0IHVzZVNjcm9sbExvY2sgZnJvbSAnLi91c2VTY3JvbGxMb2NrJztcblxuaW50ZXJmYWNlIFByb3BzIHtcbiAgcmVhZG9ubHkgY2hpbGRyZW46IChyZWY6IFJlZkNhbGxiYWNrPEhUTUxFbGVtZW50PikgPT4gUmVhY3RFbGVtZW50O1xuICByZWFkb25seSBsb2NrRW5hYmxlZDogYm9vbGVhbjtcbiAgcmVhZG9ubHkgY2FwdHVyZUVuYWJsZWQ6IGJvb2xlYW47XG4gIHJlYWRvbmx5IG9uQm90dG9tQXJyaXZlPzogKGV2ZW50OiBXaGVlbEV2ZW50IHwgVG91Y2hFdmVudCkgPT4gdm9pZDtcbiAgcmVhZG9ubHkgb25Cb3R0b21MZWF2ZT86IChldmVudDogV2hlZWxFdmVudCB8IFRvdWNoRXZlbnQpID0+IHZvaWQ7XG4gIHJlYWRvbmx5IG9uVG9wQXJyaXZlPzogKGV2ZW50OiBXaGVlbEV2ZW50IHwgVG91Y2hFdmVudCkgPT4gdm9pZDtcbiAgcmVhZG9ubHkgb25Ub3BMZWF2ZT86IChldmVudDogV2hlZWxFdmVudCB8IFRvdWNoRXZlbnQpID0+IHZvaWQ7XG59XG5cbmNvbnN0IGJsdXJTZWxlY3RJbnB1dCA9IChldmVudDogTW91c2VFdmVudDxIVE1MRGl2RWxlbWVudD4pID0+IHtcbiAgY29uc3QgZWxlbWVudCA9IGV2ZW50LnRhcmdldCBhcyBIVE1MRGl2RWxlbWVudDtcbiAgcmV0dXJuIChcbiAgICBlbGVtZW50Lm93bmVyRG9jdW1lbnQuYWN0aXZlRWxlbWVudCAmJlxuICAgIChlbGVtZW50Lm93bmVyRG9jdW1lbnQuYWN0aXZlRWxlbWVudCBhcyBIVE1MRWxlbWVudCkuYmx1cigpXG4gICk7XG59O1xuXG5leHBvcnQgZGVmYXVsdCBmdW5jdGlvbiBTY3JvbGxNYW5hZ2VyKHtcbiAgY2hpbGRyZW4sXG4gIGxvY2tFbmFibGVkLFxuICBjYXB0dXJlRW5hYmxlZCA9IHRydWUsXG4gIG9uQm90dG9tQXJyaXZlLFxuICBvbkJvdHRvbUxlYXZlLFxuICBvblRvcEFycml2ZSxcbiAgb25Ub3BMZWF2ZSxcbn06IFByb3BzKSB7XG4gIGNvbnN0IHNldFNjcm9sbENhcHR1cmVUYXJnZXQgPSB1c2VTY3JvbGxDYXB0dXJlKHtcbiAgICBpc0VuYWJsZWQ6IGNhcHR1cmVFbmFibGVkLFxuICAgIG9uQm90dG9tQXJyaXZlLFxuICAgIG9uQm90dG9tTGVhdmUsXG4gICAgb25Ub3BBcnJpdmUsXG4gICAgb25Ub3BMZWF2ZSxcbiAgfSk7XG4gIGNvbnN0IHNldFNjcm9sbExvY2tUYXJnZXQgPSB1c2VTY3JvbGxMb2NrKHsgaXNFbmFibGVkOiBsb2NrRW5hYmxlZCB9KTtcblxuICBjb25zdCB0YXJnZXRSZWY6IFJlZkNhbGxiYWNrPEhUTUxFbGVtZW50PiA9IChlbGVtZW50KSA9PiB7XG4gICAgc2V0U2Nyb2xsQ2FwdHVyZVRhcmdldChlbGVtZW50KTtcbiAgICBzZXRTY3JvbGxMb2NrVGFyZ2V0KGVsZW1lbnQpO1xuICB9O1xuXG4gIHJldHVybiAoXG4gICAgPEZyYWdtZW50PlxuICAgICAge2xvY2tFbmFibGVkICYmIChcbiAgICAgICAgPGRpdlxuICAgICAgICAgIG9uQ2xpY2s9e2JsdXJTZWxlY3RJbnB1dH1cbiAgICAgICAgICBjc3M9e3sgcG9zaXRpb246ICdmaXhlZCcsIGxlZnQ6IDAsIGJvdHRvbTogMCwgcmlnaHQ6IDAsIHRvcDogMCB9fVxuICAgICAgICAvPlxuICAgICAgKX1cbiAgICAgIHtjaGlsZHJlbih0YXJnZXRSZWYpfVxuICAgIDwvRnJhZ21lbnQ+XG4gICk7XG59XG4iXX0= */", 3901 toString: _EMOTION_STRINGIFIED_CSS_ERROR__$1 3902}; 3903function ScrollManager(_ref3) { 3904 var children = _ref3.children, lockEnabled = _ref3.lockEnabled, _ref$captureEnabled = _ref3.captureEnabled, captureEnabled = _ref$captureEnabled === void 0 ? true : _ref$captureEnabled, onBottomArrive = _ref3.onBottomArrive, onBottomLeave = _ref3.onBottomLeave, onTopArrive = _ref3.onTopArrive, onTopLeave = _ref3.onTopLeave; 3905 var setScrollCaptureTarget = useScrollCapture({ 3906 isEnabled: captureEnabled, 3907 onBottomArrive, 3908 onBottomLeave, 3909 onTopArrive, 3910 onTopLeave 3911 }); 3912 var setScrollLockTarget = useScrollLock({ 3913 isEnabled: lockEnabled 3914 }); 3915 var targetRef = function targetRef2(element) { 3916 setScrollCaptureTarget(element); 3917 setScrollLockTarget(element); 3918 }; 3919 return jsx2(import_react6.Fragment, null, lockEnabled && jsx2("div", { 3920 onClick: blurSelectInput, 3921 css: _ref2$1 3922 }), children(targetRef)); 3923} 3924var _ref22 = true ? { 3925 name: "1a0ro4n-requiredInput", 3926 styles: "label:requiredInput;opacity:0;pointer-events:none;position:absolute;bottom:0;left:0;right:0;width:100%" 3927} : { 3928 name: "5kkxb2-requiredInput-RequiredInput", 3929 styles: "label:requiredInput;opacity:0;pointer-events:none;position:absolute;bottom:0;left:0;right:0;width:100%;label:RequiredInput;", 3930 map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIlJlcXVpcmVkSW5wdXQudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQWNJIiwiZmlsZSI6IlJlcXVpcmVkSW5wdXQudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiLyoqIEBqc3gganN4ICovXG5pbXBvcnQgeyBGb2N1c0V2ZW50SGFuZGxlciwgRnVuY3Rpb25Db21wb25lbnQgfSBmcm9tICdyZWFjdCc7XG5pbXBvcnQgeyBqc3ggfSBmcm9tICdAZW1vdGlvbi9yZWFjdCc7XG5cbmNvbnN0IFJlcXVpcmVkSW5wdXQ6IEZ1bmN0aW9uQ29tcG9uZW50PHtcbiAgcmVhZG9ubHkgbmFtZT86IHN0cmluZztcbiAgcmVhZG9ubHkgb25Gb2N1czogRm9jdXNFdmVudEhhbmRsZXI8SFRNTElucHV0RWxlbWVudD47XG59PiA9ICh7IG5hbWUsIG9uRm9jdXMgfSkgPT4gKFxuICA8aW5wdXRcbiAgICByZXF1aXJlZFxuICAgIG5hbWU9e25hbWV9XG4gICAgdGFiSW5kZXg9ey0xfVxuICAgIGFyaWEtaGlkZGVuPVwidHJ1ZVwiXG4gICAgb25Gb2N1cz17b25Gb2N1c31cbiAgICBjc3M9e3tcbiAgICAgIGxhYmVsOiAncmVxdWlyZWRJbnB1dCcsXG4gICAgICBvcGFjaXR5OiAwLFxuICAgICAgcG9pbnRlckV2ZW50czogJ25vbmUnLFxuICAgICAgcG9zaXRpb246ICdhYnNvbHV0ZScsXG4gICAgICBib3R0b206IDAsXG4gICAgICBsZWZ0OiAwLFxuICAgICAgcmlnaHQ6IDAsXG4gICAgICB3aWR0aDogJzEwMCUnLFxuICAgIH19XG4gICAgLy8gUHJldmVudCBgU3dpdGNoaW5nIGZyb20gdW5jb250cm9sbGVkIHRvIGNvbnRyb2xsZWRgIGVycm9yXG4gICAgdmFsdWU9XCJcIlxuICAgIG9uQ2hhbmdlPXsoKSA9PiB7fX1cbiAgLz5cbik7XG5cbmV4cG9ydCBkZWZhdWx0IFJlcXVpcmVkSW5wdXQ7XG4iXX0= */", 3931 toString: _EMOTION_STRINGIFIED_CSS_ERROR__ 3932}; 3933var RequiredInput = function RequiredInput2(_ref3) { 3934 var name = _ref3.name, onFocus2 = _ref3.onFocus; 3935 return jsx2("input", { 3936 required: true, 3937 name, 3938 tabIndex: -1, 3939 "aria-hidden": "true", 3940 onFocus: onFocus2, 3941 css: _ref22, 3942 value: "", 3943 onChange: function onChange2() { 3944 } 3945 }); 3946}; 3947var RequiredInput$1 = RequiredInput; 3948function testPlatform(re6) { 3949 var _window$navigator$use; 3950 return typeof window !== "undefined" && window.navigator != null ? re6.test(((_window$navigator$use = window.navigator["userAgentData"]) === null || _window$navigator$use === void 0 ? void 0 : _window$navigator$use.platform) || window.navigator.platform) : false; 3951} 3952function isIPhone() { 3953 return testPlatform(/^iPhone/i); 3954} 3955function isMac() { 3956 return testPlatform(/^Mac/i); 3957} 3958function isIPad() { 3959 return testPlatform(/^iPad/i) || // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support. 3960 isMac() && navigator.maxTouchPoints > 1; 3961} 3962function isIOS() { 3963 return isIPhone() || isIPad(); 3964} 3965function isAppleDevice() { 3966 return isMac() || isIOS(); 3967} 3968var formatGroupLabel = function formatGroupLabel2(group) { 3969 return group.label; 3970}; 3971var getOptionLabel$1 = function getOptionLabel(option) { 3972 return option.label; 3973}; 3974var getOptionValue$1 = function getOptionValue(option) { 3975 return option.value; 3976}; 3977var isOptionDisabled = function isOptionDisabled2(option) { 3978 return !!option.isDisabled; 3979}; 3980var defaultStyles = { 3981 clearIndicator: clearIndicatorCSS, 3982 container: containerCSS, 3983 control: css$1, 3984 dropdownIndicator: dropdownIndicatorCSS, 3985 group: groupCSS, 3986 groupHeading: groupHeadingCSS, 3987 indicatorsContainer: indicatorsContainerCSS, 3988 indicatorSeparator: indicatorSeparatorCSS, 3989 input: inputCSS, 3990 loadingIndicator: loadingIndicatorCSS, 3991 loadingMessage: loadingMessageCSS, 3992 menu: menuCSS, 3993 menuList: menuListCSS, 3994 menuPortal: menuPortalCSS, 3995 multiValue: multiValueCSS, 3996 multiValueLabel: multiValueLabelCSS, 3997 multiValueRemove: multiValueRemoveCSS, 3998 noOptionsMessage: noOptionsMessageCSS, 3999 option: optionCSS, 4000 placeholder: placeholderCSS, 4001 singleValue: css3, 4002 valueContainer: valueContainerCSS 4003}; 4004var colors = { 4005 primary: "#2684FF", 4006 primary75: "#4C9AFF", 4007 primary50: "#B2D4FF", 4008 primary25: "#DEEBFF", 4009 danger: "#DE350B", 4010 dangerLight: "#FFBDAD", 4011 neutral0: "hsl(0, 0%, 100%)", 4012 neutral5: "hsl(0, 0%, 95%)", 4013 neutral10: "hsl(0, 0%, 90%)", 4014 neutral20: "hsl(0, 0%, 80%)", 4015 neutral30: "hsl(0, 0%, 70%)", 4016 neutral40: "hsl(0, 0%, 60%)", 4017 neutral50: "hsl(0, 0%, 50%)", 4018 neutral60: "hsl(0, 0%, 40%)", 4019 neutral70: "hsl(0, 0%, 30%)", 4020 neutral80: "hsl(0, 0%, 20%)", 4021 neutral90: "hsl(0, 0%, 10%)" 4022}; 4023var borderRadius = 4; 4024var baseUnit = 4; 4025var controlHeight = 38; 4026var menuGutter = baseUnit * 2; 4027var spacing = { 4028 baseUnit, 4029 controlHeight, 4030 menuGutter 4031}; 4032var defaultTheme = { 4033 borderRadius, 4034 colors, 4035 spacing 4036}; 4037var defaultProps = { 4038 "aria-live": "polite", 4039 backspaceRemovesValue: true, 4040 blurInputOnSelect: isTouchCapable(), 4041 captureMenuScroll: !isTouchCapable(), 4042 classNames: {}, 4043 closeMenuOnSelect: true, 4044 closeMenuOnScroll: false, 4045 components: {}, 4046 controlShouldRenderValue: true, 4047 escapeClearsValue: false, 4048 filterOption: createFilter(), 4049 formatGroupLabel, 4050 getOptionLabel: getOptionLabel$1, 4051 getOptionValue: getOptionValue$1, 4052 isDisabled: false, 4053 isLoading: false, 4054 isMulti: false, 4055 isRtl: false, 4056 isSearchable: true, 4057 isOptionDisabled, 4058 loadingMessage: function loadingMessage() { 4059 return "Loading..."; 4060 }, 4061 maxMenuHeight: 300, 4062 minMenuHeight: 140, 4063 menuIsOpen: false, 4064 menuPlacement: "bottom", 4065 menuPosition: "absolute", 4066 menuShouldBlockScroll: false, 4067 menuShouldScrollIntoView: !isMobileDevice(), 4068 noOptionsMessage: function noOptionsMessage() { 4069 return "No options"; 4070 }, 4071 openMenuOnFocus: false, 4072 openMenuOnClick: true, 4073 options: [], 4074 pageSize: 5, 4075 placeholder: "Select...", 4076 screenReaderStatus: function screenReaderStatus(_ref3) { 4077 var count = _ref3.count; 4078 return "".concat(count, " result").concat(count !== 1 ? "s" : "", " available"); 4079 }, 4080 styles: {}, 4081 tabIndex: 0, 4082 tabSelectsValue: true, 4083 unstyled: false 4084}; 4085function toCategorizedOption(props, option, selectValue, index2) { 4086 var isDisabled = _isOptionDisabled(props, option, selectValue); 4087 var isSelected = _isOptionSelected(props, option, selectValue); 4088 var label = getOptionLabel2(props, option); 4089 var value = getOptionValue2(props, option); 4090 return { 4091 type: "option", 4092 data: option, 4093 isDisabled, 4094 isSelected, 4095 label, 4096 value, 4097 index: index2 4098 }; 4099} 4100function buildCategorizedOptions(props, selectValue) { 4101 return props.options.map(function(groupOrOption, groupOrOptionIndex) { 4102 if ("options" in groupOrOption) { 4103 var categorizedOptions = groupOrOption.options.map(function(option, optionIndex) { 4104 return toCategorizedOption(props, option, selectValue, optionIndex); 4105 }).filter(function(categorizedOption2) { 4106 return isFocusable(props, categorizedOption2); 4107 }); 4108 return categorizedOptions.length > 0 ? { 4109 type: "group", 4110 data: groupOrOption, 4111 options: categorizedOptions, 4112 index: groupOrOptionIndex 4113 } : void 0; 4114 } 4115 var categorizedOption = toCategorizedOption(props, groupOrOption, selectValue, groupOrOptionIndex); 4116 return isFocusable(props, categorizedOption) ? categorizedOption : void 0; 4117 }).filter(notNullish); 4118} 4119function buildFocusableOptionsFromCategorizedOptions(categorizedOptions) { 4120 return categorizedOptions.reduce(function(optionsAccumulator, categorizedOption) { 4121 if (categorizedOption.type === "group") { 4122 optionsAccumulator.push.apply(optionsAccumulator, _toConsumableArray(categorizedOption.options.map(function(option) { 4123 return option.data; 4124 }))); 4125 } else { 4126 optionsAccumulator.push(categorizedOption.data); 4127 } 4128 return optionsAccumulator; 4129 }, []); 4130} 4131function buildFocusableOptionsWithIds(categorizedOptions, optionId) { 4132 return categorizedOptions.reduce(function(optionsAccumulator, categorizedOption) { 4133 if (categorizedOption.type === "group") { 4134 optionsAccumulator.push.apply(optionsAccumulator, _toConsumableArray(categorizedOption.options.map(function(option) { 4135 return { 4136 data: option.data, 4137 id: "".concat(optionId, "-").concat(categorizedOption.index, "-").concat(option.index) 4138 }; 4139 }))); 4140 } else { 4141 optionsAccumulator.push({ 4142 data: categorizedOption.data, 4143 id: "".concat(optionId, "-").concat(categorizedOption.index) 4144 }); 4145 } 4146 return optionsAccumulator; 4147 }, []); 4148} 4149function buildFocusableOptions(props, selectValue) { 4150 return buildFocusableOptionsFromCategorizedOptions(buildCategorizedOptions(props, selectValue)); 4151} 4152function isFocusable(props, categorizedOption) { 4153 var _props$inputValue = props.inputValue, inputValue = _props$inputValue === void 0 ? "" : _props$inputValue; 4154 var data = categorizedOption.data, isSelected = categorizedOption.isSelected, label = categorizedOption.label, value = categorizedOption.value; 4155 return (!shouldHideSelectedOptions(props) || !isSelected) && _filterOption(props, { 4156 label, 4157 value, 4158 data 4159 }, inputValue); 4160} 4161function getNextFocusedValue(state, nextSelectValue) { 4162 var focusedValue = state.focusedValue, lastSelectValue = state.selectValue; 4163 var lastFocusedIndex = lastSelectValue.indexOf(focusedValue); 4164 if (lastFocusedIndex > -1) { 4165 var nextFocusedIndex = nextSelectValue.indexOf(focusedValue); 4166 if (nextFocusedIndex > -1) { 4167 return focusedValue; 4168 } else if (lastFocusedIndex < nextSelectValue.length) { 4169 return nextSelectValue[lastFocusedIndex]; 4170 } 4171 } 4172 return null; 4173} 4174function getNextFocusedOption(state, options2) { 4175 var lastFocusedOption = state.focusedOption; 4176 return lastFocusedOption && options2.indexOf(lastFocusedOption) > -1 ? lastFocusedOption : options2[0]; 4177} 4178var getFocusedOptionId = function getFocusedOptionId2(focusableOptionsWithIds, focusedOption) { 4179 var _focusableOptionsWith; 4180 var focusedOptionId = (_focusableOptionsWith = focusableOptionsWithIds.find(function(option) { 4181 return option.data === focusedOption; 4182 })) === null || _focusableOptionsWith === void 0 ? void 0 : _focusableOptionsWith.id; 4183 return focusedOptionId || null; 4184}; 4185var getOptionLabel2 = function getOptionLabel3(props, data) { 4186 return props.getOptionLabel(data); 4187}; 4188var getOptionValue2 = function getOptionValue3(props, data) { 4189 return props.getOptionValue(data); 4190}; 4191function _isOptionDisabled(props, option, selectValue) { 4192 return typeof props.isOptionDisabled === "function" ? props.isOptionDisabled(option, selectValue) : false; 4193} 4194function _isOptionSelected(props, option, selectValue) { 4195 if (selectValue.indexOf(option) > -1) return true; 4196 if (typeof props.isOptionSelected === "function") { 4197 return props.isOptionSelected(option, selectValue); 4198 } 4199 var candidate = getOptionValue2(props, option); 4200 return selectValue.some(function(i3) { 4201 return getOptionValue2(props, i3) === candidate; 4202 }); 4203} 4204function _filterOption(props, option, inputValue) { 4205 return props.filterOption ? props.filterOption(option, inputValue) : true; 4206} 4207var shouldHideSelectedOptions = function shouldHideSelectedOptions2(props) { 4208 var hideSelectedOptions = props.hideSelectedOptions, isMulti = props.isMulti; 4209 if (hideSelectedOptions === void 0) return isMulti; 4210 return hideSelectedOptions; 4211}; 4212var instanceId = 1; 4213var Select = function(_Component) { 4214 _inherits(Select3, _Component); 4215 var _super = _createSuper(Select3); 4216 function Select3(_props) { 4217 var _this; 4218 _classCallCheck(this, Select3); 4219 _this = _super.call(this, _props); 4220 _this.state = { 4221 ariaSelection: null, 4222 focusedOption: null, 4223 focusedOptionId: null, 4224 focusableOptionsWithIds: [], 4225 focusedValue: null, 4226 inputIsHidden: false, 4227 isFocused: false, 4228 selectValue: [], 4229 clearFocusValueOnUpdate: false, 4230 prevWasFocused: false, 4231 inputIsHiddenAfterUpdate: void 0, 4232 prevProps: void 0, 4233 instancePrefix: "" 4234 }; 4235 _this.blockOptionHover = false; 4236 _this.isComposing = false; 4237 _this.commonProps = void 0; 4238 _this.initialTouchX = 0; 4239 _this.initialTouchY = 0; 4240 _this.openAfterFocus = false; 4241 _this.scrollToFocusedOptionOnUpdate = false; 4242 _this.userIsDragging = void 0; 4243 _this.isAppleDevice = isAppleDevice(); 4244 _this.controlRef = null; 4245 _this.getControlRef = function(ref) { 4246 _this.controlRef = ref; 4247 }; 4248 _this.focusedOptionRef = null; 4249 _this.getFocusedOptionRef = function(ref) { 4250 _this.focusedOptionRef = ref; 4251 }; 4252 _this.menuListRef = null; 4253 _this.getMenuListRef = function(ref) { 4254 _this.menuListRef = ref; 4255 }; 4256 _this.inputRef = null; 4257 _this.getInputRef = function(ref) { 4258 _this.inputRef = ref; 4259 }; 4260 _this.focus = _this.focusInput; 4261 _this.blur = _this.blurInput; 4262 _this.onChange = function(newValue, actionMeta) { 4263 var _this$props = _this.props, onChange2 = _this$props.onChange, name = _this$props.name; 4264 actionMeta.name = name; 4265 _this.ariaOnChange(newValue, actionMeta); 4266 onChange2(newValue, actionMeta); 4267 }; 4268 _this.setValue = function(newValue, action, option) { 4269 var _this$props2 = _this.props, closeMenuOnSelect = _this$props2.closeMenuOnSelect, isMulti = _this$props2.isMulti, inputValue = _this$props2.inputValue; 4270 _this.onInputChange("", { 4271 action: "set-value", 4272 prevInputValue: inputValue 4273 }); 4274 if (closeMenuOnSelect) { 4275 _this.setState({ 4276 inputIsHiddenAfterUpdate: !isMulti 4277 }); 4278 _this.onMenuClose(); 4279 } 4280 _this.setState({ 4281 clearFocusValueOnUpdate: true 4282 }); 4283 _this.onChange(newValue, { 4284 action, 4285 option 4286 }); 4287 }; 4288 _this.selectOption = function(newValue) { 4289 var _this$props3 = _this.props, blurInputOnSelect = _this$props3.blurInputOnSelect, isMulti = _this$props3.isMulti, name = _this$props3.name; 4290 var selectValue = _this.state.selectValue; 4291 var deselected = isMulti && _this.isOptionSelected(newValue, selectValue); 4292 var isDisabled = _this.isOptionDisabled(newValue, selectValue); 4293 if (deselected) { 4294 var candidate = _this.getOptionValue(newValue); 4295 _this.setValue(multiValueAsValue(selectValue.filter(function(i3) { 4296 return _this.getOptionValue(i3) !== candidate; 4297 })), "deselect-option", newValue); 4298 } else if (!isDisabled) { 4299 if (isMulti) { 4300 _this.setValue(multiValueAsValue([].concat(_toConsumableArray(selectValue), [newValue])), "select-option", newValue); 4301 } else { 4302 _this.setValue(singleValueAsValue(newValue), "select-option"); 4303 } 4304 } else { 4305 _this.ariaOnChange(singleValueAsValue(newValue), { 4306 action: "select-option", 4307 option: newValue, 4308 name 4309 }); 4310 return; 4311 } 4312 if (blurInputOnSelect) { 4313 _this.blurInput(); 4314 } 4315 }; 4316 _this.removeValue = function(removedValue) { 4317 var isMulti = _this.props.isMulti; 4318 var selectValue = _this.state.selectValue; 4319 var candidate = _this.getOptionValue(removedValue); 4320 var newValueArray = selectValue.filter(function(i3) { 4321 return _this.getOptionValue(i3) !== candidate; 4322 }); 4323 var newValue = valueTernary(isMulti, newValueArray, newValueArray[0] || null); 4324 _this.onChange(newValue, { 4325 action: "remove-value", 4326 removedValue 4327 }); 4328 _this.focusInput(); 4329 }; 4330 _this.clearValue = function() { 4331 var selectValue = _this.state.selectValue; 4332 _this.onChange(valueTernary(_this.props.isMulti, [], null), { 4333 action: "clear", 4334 removedValues: selectValue 4335 }); 4336 }; 4337 _this.popValue = function() { 4338 var isMulti = _this.props.isMulti; 4339 var selectValue = _this.state.selectValue; 4340 var lastSelectedValue = selectValue[selectValue.length - 1]; 4341 var newValueArray = selectValue.slice(0, selectValue.length - 1); 4342 var newValue = valueTernary(isMulti, newValueArray, newValueArray[0] || null); 4343 _this.onChange(newValue, { 4344 action: "pop-value", 4345 removedValue: lastSelectedValue 4346 }); 4347 }; 4348 _this.getFocusedOptionId = function(focusedOption) { 4349 return getFocusedOptionId(_this.state.focusableOptionsWithIds, focusedOption); 4350 }; 4351 _this.getFocusableOptionsWithIds = function() { 4352 return buildFocusableOptionsWithIds(buildCategorizedOptions(_this.props, _this.state.selectValue), _this.getElementId("option")); 4353 }; 4354 _this.getValue = function() { 4355 return _this.state.selectValue; 4356 }; 4357 _this.cx = function() { 4358 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 4359 args[_key] = arguments[_key]; 4360 } 4361 return classNames.apply(void 0, [_this.props.classNamePrefix].concat(args)); 4362 }; 4363 _this.getOptionLabel = function(data) { 4364 return getOptionLabel2(_this.props, data); 4365 }; 4366 _this.getOptionValue = function(data) { 4367 return getOptionValue2(_this.props, data); 4368 }; 4369 _this.getStyles = function(key, props) { 4370 var unstyled = _this.props.unstyled; 4371 var base = defaultStyles[key](props, unstyled); 4372 base.boxSizing = "border-box"; 4373 var custom = _this.props.styles[key]; 4374 return custom ? custom(base, props) : base; 4375 }; 4376 _this.getClassNames = function(key, props) { 4377 var _this$props$className, _this$props$className2; 4378 return (_this$props$className = (_this$props$className2 = _this.props.classNames)[key]) === null || _this$props$className === void 0 ? void 0 : _this$props$className.call(_this$props$className2, props); 4379 }; 4380 _this.getElementId = function(element) { 4381 return "".concat(_this.state.instancePrefix, "-").concat(element); 4382 }; 4383 _this.getComponents = function() { 4384 return defaultComponents(_this.props); 4385 }; 4386 _this.buildCategorizedOptions = function() { 4387 return buildCategorizedOptions(_this.props, _this.state.selectValue); 4388 }; 4389 _this.getCategorizedOptions = function() { 4390 return _this.props.menuIsOpen ? _this.buildCategorizedOptions() : []; 4391 }; 4392 _this.buildFocusableOptions = function() { 4393 return buildFocusableOptionsFromCategorizedOptions(_this.buildCategorizedOptions()); 4394 }; 4395 _this.getFocusableOptions = function() { 4396 return _this.props.menuIsOpen ? _this.buildFocusableOptions() : []; 4397 }; 4398 _this.ariaOnChange = function(value, actionMeta) { 4399 _this.setState({ 4400 ariaSelection: _objectSpread2({ 4401 value 4402 }, actionMeta) 4403 }); 4404 }; 4405 _this.onMenuMouseDown = function(event) { 4406 if (event.button !== 0) { 4407 return; 4408 } 4409 event.stopPropagation(); 4410 event.preventDefault(); 4411 _this.focusInput(); 4412 }; 4413 _this.onMenuMouseMove = function(event) { 4414 _this.blockOptionHover = false; 4415 }; 4416 _this.onControlMouseDown = function(event) { 4417 if (event.defaultPrevented) { 4418 return; 4419 } 4420 var openMenuOnClick = _this.props.openMenuOnClick; 4421 if (!_this.state.isFocused) { 4422 if (openMenuOnClick) { 4423 _this.openAfterFocus = true; 4424 } 4425 _this.focusInput(); 4426 } else if (!_this.props.menuIsOpen) { 4427 if (openMenuOnClick) { 4428 _this.openMenu("first"); 4429 } 4430 } else { 4431 if (event.target.tagName !== "INPUT" && event.target.tagName !== "TEXTAREA") { 4432 _this.onMenuClose(); 4433 } 4434 } 4435 if (event.target.tagName !== "INPUT" && event.target.tagName !== "TEXTAREA") { 4436 event.preventDefault(); 4437 } 4438 }; 4439 _this.onDropdownIndicatorMouseDown = function(event) { 4440 if (event && event.type === "mousedown" && event.button !== 0) { 4441 return; 4442 } 4443 if (_this.props.isDisabled) return; 4444 var _this$props4 = _this.props, isMulti = _this$props4.isMulti, menuIsOpen = _this$props4.menuIsOpen; 4445 _this.focusInput(); 4446 if (menuIsOpen) { 4447 _this.setState({ 4448 inputIsHiddenAfterUpdate: !isMulti 4449 }); 4450 _this.onMenuClose(); 4451 } else { 4452 _this.openMenu("first"); 4453 } 4454 event.preventDefault(); 4455 }; 4456 _this.onClearIndicatorMouseDown = function(event) { 4457 if (event && event.type === "mousedown" && event.button !== 0) { 4458 return; 4459 } 4460 _this.clearValue(); 4461 event.preventDefault(); 4462 _this.openAfterFocus = false; 4463 if (event.type === "touchend") { 4464 _this.focusInput(); 4465 } else { 4466 setTimeout(function() { 4467 return _this.focusInput(); 4468 }); 4469 } 4470 }; 4471 _this.onScroll = function(event) { 4472 if (typeof _this.props.closeMenuOnScroll === "boolean") { 4473 if (event.target instanceof HTMLElement && isDocumentElement(event.target)) { 4474 _this.props.onMenuClose(); 4475 } 4476 } else if (typeof _this.props.closeMenuOnScroll === "function") { 4477 if (_this.props.closeMenuOnScroll(event)) { 4478 _this.props.onMenuClose(); 4479 } 4480 } 4481 }; 4482 _this.onCompositionStart = function() { 4483 _this.isComposing = true; 4484 }; 4485 _this.onCompositionEnd = function() { 4486 _this.isComposing = false; 4487 }; 4488 _this.onTouchStart = function(_ref23) { 4489 var touches = _ref23.touches; 4490 var touch = touches && touches.item(0); 4491 if (!touch) { 4492 return; 4493 } 4494 _this.initialTouchX = touch.clientX; 4495 _this.initialTouchY = touch.clientY; 4496 _this.userIsDragging = false; 4497 }; 4498 _this.onTouchMove = function(_ref3) { 4499 var touches = _ref3.touches; 4500 var touch = touches && touches.item(0); 4501 if (!touch) { 4502 return; 4503 } 4504 var deltaX = Math.abs(touch.clientX - _this.initialTouchX); 4505 var deltaY = Math.abs(touch.clientY - _this.initialTouchY); 4506 var moveThreshold = 5; 4507 _this.userIsDragging = deltaX > moveThreshold || deltaY > moveThreshold; 4508 }; 4509 _this.onTouchEnd = function(event) { 4510 if (_this.userIsDragging) return; 4511 if (_this.controlRef && !_this.controlRef.contains(event.target) && _this.menuListRef && !_this.menuListRef.contains(event.target)) { 4512 _this.blurInput(); 4513 } 4514 _this.initialTouchX = 0; 4515 _this.initialTouchY = 0; 4516 }; 4517 _this.onControlTouchEnd = function(event) { 4518 if (_this.userIsDragging) return; 4519 _this.onControlMouseDown(event); 4520 }; 4521 _this.onClearIndicatorTouchEnd = function(event) { 4522 if (_this.userIsDragging) return; 4523 _this.onClearIndicatorMouseDown(event); 4524 }; 4525 _this.onDropdownIndicatorTouchEnd = function(event) { 4526 if (_this.userIsDragging) return; 4527 _this.onDropdownIndicatorMouseDown(event); 4528 }; 4529 _this.handleInputChange = function(event) { 4530 var prevInputValue = _this.props.inputValue; 4531 var inputValue = event.currentTarget.value; 4532 _this.setState({ 4533 inputIsHiddenAfterUpdate: false 4534 }); 4535 _this.onInputChange(inputValue, { 4536 action: "input-change", 4537 prevInputValue 4538 }); 4539 if (!_this.props.menuIsOpen) { 4540 _this.onMenuOpen(); 4541 } 4542 }; 4543 _this.onInputFocus = function(event) { 4544 if (_this.props.onFocus) { 4545 _this.props.onFocus(event); 4546 } 4547 _this.setState({ 4548 inputIsHiddenAfterUpdate: false, 4549 isFocused: true 4550 }); 4551 if (_this.openAfterFocus || _this.props.openMenuOnFocus) { 4552 _this.openMenu("first"); 4553 } 4554 _this.openAfterFocus = false; 4555 }; 4556 _this.onInputBlur = function(event) { 4557 var prevInputValue = _this.props.inputValue; 4558 if (_this.menuListRef && _this.menuListRef.contains(document.activeElement)) { 4559 _this.inputRef.focus(); 4560 return; 4561 } 4562 if (_this.props.onBlur) { 4563 _this.props.onBlur(event); 4564 } 4565 _this.onInputChange("", { 4566 action: "input-blur", 4567 prevInputValue 4568 }); 4569 _this.onMenuClose(); 4570 _this.setState({ 4571 focusedValue: null, 4572 isFocused: false 4573 }); 4574 }; 4575 _this.onOptionHover = function(focusedOption) { 4576 if (_this.blockOptionHover || _this.state.focusedOption === focusedOption) { 4577 return; 4578 } 4579 var options2 = _this.getFocusableOptions(); 4580 var focusedOptionIndex = options2.indexOf(focusedOption); 4581 _this.setState({ 4582 focusedOption, 4583 focusedOptionId: focusedOptionIndex > -1 ? _this.getFocusedOptionId(focusedOption) : null 4584 }); 4585 }; 4586 _this.shouldHideSelectedOptions = function() { 4587 return shouldHideSelectedOptions(_this.props); 4588 }; 4589 _this.onValueInputFocus = function(e) { 4590 e.preventDefault(); 4591 e.stopPropagation(); 4592 _this.focus(); 4593 }; 4594 _this.onKeyDown = function(event) { 4595 var _this$props5 = _this.props, isMulti = _this$props5.isMulti, backspaceRemovesValue = _this$props5.backspaceRemovesValue, escapeClearsValue = _this$props5.escapeClearsValue, inputValue = _this$props5.inputValue, isClearable = _this$props5.isClearable, isDisabled = _this$props5.isDisabled, menuIsOpen = _this$props5.menuIsOpen, onKeyDown = _this$props5.onKeyDown, tabSelectsValue = _this$props5.tabSelectsValue, openMenuOnFocus = _this$props5.openMenuOnFocus; 4596 var _this$state = _this.state, focusedOption = _this$state.focusedOption, focusedValue = _this$state.focusedValue, selectValue = _this$state.selectValue; 4597 if (isDisabled) return; 4598 if (typeof onKeyDown === "function") { 4599 onKeyDown(event); 4600 if (event.defaultPrevented) { 4601 return; 4602 } 4603 } 4604 _this.blockOptionHover = true; 4605 switch (event.key) { 4606 case "ArrowLeft": 4607 if (!isMulti || inputValue) return; 4608 _this.focusValue("previous"); 4609 break; 4610 case "ArrowRight": 4611 if (!isMulti || inputValue) return; 4612 _this.focusValue("next"); 4613 break; 4614 case "Delete": 4615 case "Backspace": 4616 if (inputValue) return; 4617 if (focusedValue) { 4618 _this.removeValue(focusedValue); 4619 } else { 4620 if (!backspaceRemovesValue) return; 4621 if (isMulti) { 4622 _this.popValue(); 4623 } else if (isClearable) { 4624 _this.clearValue(); 4625 } 4626 } 4627 break; 4628 case "Tab": 4629 if (_this.isComposing) return; 4630 if (event.shiftKey || !menuIsOpen || !tabSelectsValue || !focusedOption || // don't capture the event if the menu opens on focus and the focused 4631 // option is already selected; it breaks the flow of navigation 4632 openMenuOnFocus && _this.isOptionSelected(focusedOption, selectValue)) { 4633 return; 4634 } 4635 _this.selectOption(focusedOption); 4636 break; 4637 case "Enter": 4638 if (event.keyCode === 229) { 4639 break; 4640 } 4641 if (menuIsOpen) { 4642 if (!focusedOption) return; 4643 if (_this.isComposing) return; 4644 _this.selectOption(focusedOption); 4645 break; 4646 } 4647 return; 4648 case "Escape": 4649 if (menuIsOpen) { 4650 _this.setState({ 4651 inputIsHiddenAfterUpdate: false 4652 }); 4653 _this.onInputChange("", { 4654 action: "menu-close", 4655 prevInputValue: inputValue 4656 }); 4657 _this.onMenuClose(); 4658 } else if (isClearable && escapeClearsValue) { 4659 _this.clearValue(); 4660 } 4661 break; 4662 case " ": 4663 if (inputValue) { 4664 return; 4665 } 4666 if (!menuIsOpen) { 4667 _this.openMenu("first"); 4668 break; 4669 } 4670 if (!focusedOption) return; 4671 _this.selectOption(focusedOption); 4672 break; 4673 case "ArrowUp": 4674 if (menuIsOpen) { 4675 _this.focusOption("up"); 4676 } else { 4677 _this.openMenu("last"); 4678 } 4679 break; 4680 case "ArrowDown": 4681 if (menuIsOpen) { 4682 _this.focusOption("down"); 4683 } else { 4684 _this.openMenu("first"); 4685 } 4686 break; 4687 case "PageUp": 4688 if (!menuIsOpen) return; 4689 _this.focusOption("pageup"); 4690 break; 4691 case "PageDown": 4692 if (!menuIsOpen) return; 4693 _this.focusOption("pagedown"); 4694 break; 4695 case "Home": 4696 if (!menuIsOpen) return; 4697 _this.focusOption("first"); 4698 break; 4699 case "End": 4700 if (!menuIsOpen) return; 4701 _this.focusOption("last"); 4702 break; 4703 default: 4704 return; 4705 } 4706 event.preventDefault(); 4707 }; 4708 _this.state.instancePrefix = "react-select-" + (_this.props.instanceId || ++instanceId); 4709 _this.state.selectValue = cleanValue(_props.value); 4710 if (_props.menuIsOpen && _this.state.selectValue.length) { 4711 var focusableOptionsWithIds = _this.getFocusableOptionsWithIds(); 4712 var focusableOptions = _this.buildFocusableOptions(); 4713 var optionIndex = focusableOptions.indexOf(_this.state.selectValue[0]); 4714 _this.state.focusableOptionsWithIds = focusableOptionsWithIds; 4715 _this.state.focusedOption = focusableOptions[optionIndex]; 4716 _this.state.focusedOptionId = getFocusedOptionId(focusableOptionsWithIds, focusableOptions[optionIndex]); 4717 } 4718 return _this; 4719 } 4720 _createClass(Select3, [{ 4721 key: "componentDidMount", 4722 value: function componentDidMount() { 4723 this.startListeningComposition(); 4724 this.startListeningToTouch(); 4725 if (this.props.closeMenuOnScroll && document && document.addEventListener) { 4726 document.addEventListener("scroll", this.onScroll, true); 4727 } 4728 if (this.props.autoFocus) { 4729 this.focusInput(); 4730 } 4731 if (this.props.menuIsOpen && this.state.focusedOption && this.menuListRef && this.focusedOptionRef) { 4732 scrollIntoView(this.menuListRef, this.focusedOptionRef); 4733 } 4734 } 4735 }, { 4736 key: "componentDidUpdate", 4737 value: function componentDidUpdate(prevProps) { 4738 var _this$props6 = this.props, isDisabled = _this$props6.isDisabled, menuIsOpen = _this$props6.menuIsOpen; 4739 var isFocused = this.state.isFocused; 4740 if ( 4741 // ensure focus is restored correctly when the control becomes enabled 4742 isFocused && !isDisabled && prevProps.isDisabled || // ensure focus is on the Input when the menu opens 4743 isFocused && menuIsOpen && !prevProps.menuIsOpen 4744 ) { 4745 this.focusInput(); 4746 } 4747 if (isFocused && isDisabled && !prevProps.isDisabled) { 4748 this.setState({ 4749 isFocused: false 4750 }, this.onMenuClose); 4751 } else if (!isFocused && !isDisabled && prevProps.isDisabled && this.inputRef === document.activeElement) { 4752 this.setState({ 4753 isFocused: true 4754 }); 4755 } 4756 if (this.menuListRef && this.focusedOptionRef && this.scrollToFocusedOptionOnUpdate) { 4757 scrollIntoView(this.menuListRef, this.focusedOptionRef); 4758 this.scrollToFocusedOptionOnUpdate = false; 4759 } 4760 } 4761 }, { 4762 key: "componentWillUnmount", 4763 value: function componentWillUnmount() { 4764 this.stopListeningComposition(); 4765 this.stopListeningToTouch(); 4766 document.removeEventListener("scroll", this.onScroll, true); 4767 } 4768 // ============================== 4769 // Consumer Handlers 4770 // ============================== 4771 }, { 4772 key: "onMenuOpen", 4773 value: function onMenuOpen() { 4774 this.props.onMenuOpen(); 4775 } 4776 }, { 4777 key: "onMenuClose", 4778 value: function onMenuClose() { 4779 this.onInputChange("", { 4780 action: "menu-close", 4781 prevInputValue: this.props.inputValue 4782 }); 4783 this.props.onMenuClose(); 4784 } 4785 }, { 4786 key: "onInputChange", 4787 value: function onInputChange(newValue, actionMeta) { 4788 this.props.onInputChange(newValue, actionMeta); 4789 } 4790 // ============================== 4791 // Methods 4792 // ============================== 4793 }, { 4794 key: "focusInput", 4795 value: function focusInput() { 4796 if (!this.inputRef) return; 4797 this.inputRef.focus(); 4798 } 4799 }, { 4800 key: "blurInput", 4801 value: function blurInput() { 4802 if (!this.inputRef) return; 4803 this.inputRef.blur(); 4804 } 4805 // aliased for consumers 4806 }, { 4807 key: "openMenu", 4808 value: function openMenu(focusOption) { 4809 var _this2 = this; 4810 var _this$state2 = this.state, selectValue = _this$state2.selectValue, isFocused = _this$state2.isFocused; 4811 var focusableOptions = this.buildFocusableOptions(); 4812 var openAtIndex = focusOption === "first" ? 0 : focusableOptions.length - 1; 4813 if (!this.props.isMulti) { 4814 var selectedIndex = focusableOptions.indexOf(selectValue[0]); 4815 if (selectedIndex > -1) { 4816 openAtIndex = selectedIndex; 4817 } 4818 } 4819 this.scrollToFocusedOptionOnUpdate = !(isFocused && this.menuListRef); 4820 this.setState({ 4821 inputIsHiddenAfterUpdate: false, 4822 focusedValue: null, 4823 focusedOption: focusableOptions[openAtIndex], 4824 focusedOptionId: this.getFocusedOptionId(focusableOptions[openAtIndex]) 4825 }, function() { 4826 return _this2.onMenuOpen(); 4827 }); 4828 } 4829 }, { 4830 key: "focusValue", 4831 value: function focusValue(direction) { 4832 var _this$state3 = this.state, selectValue = _this$state3.selectValue, focusedValue = _this$state3.focusedValue; 4833 if (!this.props.isMulti) return; 4834 this.setState({ 4835 focusedOption: null 4836 }); 4837 var focusedIndex = selectValue.indexOf(focusedValue); 4838 if (!focusedValue) { 4839 focusedIndex = -1; 4840 } 4841 var lastIndex = selectValue.length - 1; 4842 var nextFocus = -1; 4843 if (!selectValue.length) return; 4844 switch (direction) { 4845 case "previous": 4846 if (focusedIndex === 0) { 4847 nextFocus = 0; 4848 } else if (focusedIndex === -1) { 4849 nextFocus = lastIndex; 4850 } else { 4851 nextFocus = focusedIndex - 1; 4852 } 4853 break; 4854 case "next": 4855 if (focusedIndex > -1 && focusedIndex < lastIndex) { 4856 nextFocus = focusedIndex + 1; 4857 } 4858 break; 4859 } 4860 this.setState({ 4861 inputIsHidden: nextFocus !== -1, 4862 focusedValue: selectValue[nextFocus] 4863 }); 4864 } 4865 }, { 4866 key: "focusOption", 4867 value: function focusOption() { 4868 var direction = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "first"; 4869 var pageSize = this.props.pageSize; 4870 var focusedOption = this.state.focusedOption; 4871 var options2 = this.getFocusableOptions(); 4872 if (!options2.length) return; 4873 var nextFocus = 0; 4874 var focusedIndex = options2.indexOf(focusedOption); 4875 if (!focusedOption) { 4876 focusedIndex = -1; 4877 } 4878 if (direction === "up") { 4879 nextFocus = focusedIndex > 0 ? focusedIndex - 1 : options2.length - 1; 4880 } else if (direction === "down") { 4881 nextFocus = (focusedIndex + 1) % options2.length; 4882 } else if (direction === "pageup") { 4883 nextFocus = focusedIndex - pageSize; 4884 if (nextFocus < 0) nextFocus = 0; 4885 } else if (direction === "pagedown") { 4886 nextFocus = focusedIndex + pageSize; 4887 if (nextFocus > options2.length - 1) nextFocus = options2.length - 1; 4888 } else if (direction === "last") { 4889 nextFocus = options2.length - 1; 4890 } 4891 this.scrollToFocusedOptionOnUpdate = true; 4892 this.setState({ 4893 focusedOption: options2[nextFocus], 4894 focusedValue: null, 4895 focusedOptionId: this.getFocusedOptionId(options2[nextFocus]) 4896 }); 4897 } 4898 }, { 4899 key: "getTheme", 4900 value: ( 4901 // ============================== 4902 // Getters 4903 // ============================== 4904 function getTheme3() { 4905 if (!this.props.theme) { 4906 return defaultTheme; 4907 } 4908 if (typeof this.props.theme === "function") { 4909 return this.props.theme(defaultTheme); 4910 } 4911 return _objectSpread2(_objectSpread2({}, defaultTheme), this.props.theme); 4912 } 4913 ) 4914 }, { 4915 key: "getCommonProps", 4916 value: function getCommonProps() { 4917 var clearValue = this.clearValue, cx = this.cx, getStyles = this.getStyles, getClassNames = this.getClassNames, getValue = this.getValue, selectOption = this.selectOption, setValue = this.setValue, props = this.props; 4918 var isMulti = props.isMulti, isRtl = props.isRtl, options2 = props.options; 4919 var hasValue = this.hasValue(); 4920 return { 4921 clearValue, 4922 cx, 4923 getStyles, 4924 getClassNames, 4925 getValue, 4926 hasValue, 4927 isMulti, 4928 isRtl, 4929 options: options2, 4930 selectOption, 4931 selectProps: props, 4932 setValue, 4933 theme: this.getTheme() 4934 }; 4935 } 4936 }, { 4937 key: "hasValue", 4938 value: function hasValue() { 4939 var selectValue = this.state.selectValue; 4940 return selectValue.length > 0; 4941 } 4942 }, { 4943 key: "hasOptions", 4944 value: function hasOptions() { 4945 return !!this.getFocusableOptions().length; 4946 } 4947 }, { 4948 key: "isClearable", 4949 value: function isClearable() { 4950 var _this$props7 = this.props, isClearable2 = _this$props7.isClearable, isMulti = _this$props7.isMulti; 4951 if (isClearable2 === void 0) return isMulti; 4952 return isClearable2; 4953 } 4954 }, { 4955 key: "isOptionDisabled", 4956 value: function isOptionDisabled3(option, selectValue) { 4957 return _isOptionDisabled(this.props, option, selectValue); 4958 } 4959 }, { 4960 key: "isOptionSelected", 4961 value: function isOptionSelected(option, selectValue) { 4962 return _isOptionSelected(this.props, option, selectValue); 4963 } 4964 }, { 4965 key: "filterOption", 4966 value: function filterOption(option, inputValue) { 4967 return _filterOption(this.props, option, inputValue); 4968 } 4969 }, { 4970 key: "formatOptionLabel", 4971 value: function formatOptionLabel(data, context) { 4972 if (typeof this.props.formatOptionLabel === "function") { 4973 var _inputValue = this.props.inputValue; 4974 var _selectValue = this.state.selectValue; 4975 return this.props.formatOptionLabel(data, { 4976 context, 4977 inputValue: _inputValue, 4978 selectValue: _selectValue 4979 }); 4980 } else { 4981 return this.getOptionLabel(data); 4982 } 4983 } 4984 }, { 4985 key: "formatGroupLabel", 4986 value: function formatGroupLabel3(data) { 4987 return this.props.formatGroupLabel(data); 4988 } 4989 // ============================== 4990 // Mouse Handlers 4991 // ============================== 4992 }, { 4993 key: "startListeningComposition", 4994 value: ( 4995 // ============================== 4996 // Composition Handlers 4997 // ============================== 4998 function startListeningComposition() { 4999 if (document && document.addEventListener) { 5000 document.addEventListener("compositionstart", this.onCompositionStart, false); 5001 document.addEventListener("compositionend", this.onCompositionEnd, false); 5002 } 5003 } 5004 ) 5005 }, { 5006 key: "stopListeningComposition", 5007 value: function stopListeningComposition() { 5008 if (document && document.removeEventListener) { 5009 document.removeEventListener("compositionstart", this.onCompositionStart); 5010 document.removeEventListener("compositionend", this.onCompositionEnd); 5011 } 5012 } 5013 }, { 5014 key: "startListeningToTouch", 5015 value: ( 5016 // ============================== 5017 // Touch Handlers 5018 // ============================== 5019 function startListeningToTouch() { 5020 if (document && document.addEventListener) { 5021 document.addEventListener("touchstart", this.onTouchStart, false); 5022 document.addEventListener("touchmove", this.onTouchMove, false); 5023 document.addEventListener("touchend", this.onTouchEnd, false); 5024 } 5025 } 5026 ) 5027 }, { 5028 key: "stopListeningToTouch", 5029 value: function stopListeningToTouch() { 5030 if (document && document.removeEventListener) { 5031 document.removeEventListener("touchstart", this.onTouchStart); 5032 document.removeEventListener("touchmove", this.onTouchMove); 5033 document.removeEventListener("touchend", this.onTouchEnd); 5034 } 5035 } 5036 }, { 5037 key: "renderInput", 5038 value: ( 5039 // ============================== 5040 // Renderers 5041 // ============================== 5042 function renderInput() { 5043 var _this$props8 = this.props, isDisabled = _this$props8.isDisabled, isSearchable = _this$props8.isSearchable, inputId = _this$props8.inputId, inputValue = _this$props8.inputValue, tabIndex = _this$props8.tabIndex, form = _this$props8.form, menuIsOpen = _this$props8.menuIsOpen, required = _this$props8.required; 5044 var _this$getComponents = this.getComponents(), Input3 = _this$getComponents.Input; 5045 var _this$state4 = this.state, inputIsHidden = _this$state4.inputIsHidden, ariaSelection = _this$state4.ariaSelection; 5046 var commonProps = this.commonProps; 5047 var id = inputId || this.getElementId("input"); 5048 var ariaAttributes = _objectSpread2(_objectSpread2(_objectSpread2({ 5049 "aria-autocomplete": "list", 5050 "aria-expanded": menuIsOpen, 5051 "aria-haspopup": true, 5052 "aria-errormessage": this.props["aria-errormessage"], 5053 "aria-invalid": this.props["aria-invalid"], 5054 "aria-label": this.props["aria-label"], 5055 "aria-labelledby": this.props["aria-labelledby"], 5056 "aria-required": required, 5057 role: "combobox", 5058 "aria-activedescendant": this.isAppleDevice ? void 0 : this.state.focusedOptionId || "" 5059 }, menuIsOpen && { 5060 "aria-controls": this.getElementId("listbox") 5061 }), !isSearchable && { 5062 "aria-readonly": true 5063 }), this.hasValue() ? (ariaSelection === null || ariaSelection === void 0 ? void 0 : ariaSelection.action) === "initial-input-focus" && { 5064 "aria-describedby": this.getElementId("live-region") 5065 } : { 5066 "aria-describedby": this.getElementId("placeholder") 5067 }); 5068 if (!isSearchable) { 5069 return React8.createElement(DummyInput, _extends({ 5070 id, 5071 innerRef: this.getInputRef, 5072 onBlur: this.onInputBlur, 5073 onChange: noop, 5074 onFocus: this.onInputFocus, 5075 disabled: isDisabled, 5076 tabIndex, 5077 inputMode: "none", 5078 form, 5079 value: "" 5080 }, ariaAttributes)); 5081 } 5082 return React8.createElement(Input3, _extends({}, commonProps, { 5083 autoCapitalize: "none", 5084 autoComplete: "off", 5085 autoCorrect: "off", 5086 id, 5087 innerRef: this.getInputRef, 5088 isDisabled, 5089 isHidden: inputIsHidden, 5090 onBlur: this.onInputBlur, 5091 onChange: this.handleInputChange, 5092 onFocus: this.onInputFocus, 5093 spellCheck: "false", 5094 tabIndex, 5095 form, 5096 type: "text", 5097 value: inputValue 5098 }, ariaAttributes)); 5099 } 5100 ) 5101 }, { 5102 key: "renderPlaceholderOrValue", 5103 value: function renderPlaceholderOrValue() { 5104 var _this3 = this; 5105 var _this$getComponents2 = this.getComponents(), MultiValue3 = _this$getComponents2.MultiValue, MultiValueContainer2 = _this$getComponents2.MultiValueContainer, MultiValueLabel2 = _this$getComponents2.MultiValueLabel, MultiValueRemove2 = _this$getComponents2.MultiValueRemove, SingleValue3 = _this$getComponents2.SingleValue, Placeholder3 = _this$getComponents2.Placeholder; 5106 var commonProps = this.commonProps; 5107 var _this$props9 = this.props, controlShouldRenderValue = _this$props9.controlShouldRenderValue, isDisabled = _this$props9.isDisabled, isMulti = _this$props9.isMulti, inputValue = _this$props9.inputValue, placeholder = _this$props9.placeholder; 5108 var _this$state5 = this.state, selectValue = _this$state5.selectValue, focusedValue = _this$state5.focusedValue, isFocused = _this$state5.isFocused; 5109 if (!this.hasValue() || !controlShouldRenderValue) { 5110 return inputValue ? null : React8.createElement(Placeholder3, _extends({}, commonProps, { 5111 key: "placeholder", 5112 isDisabled, 5113 isFocused, 5114 innerProps: { 5115 id: this.getElementId("placeholder") 5116 } 5117 }), placeholder); 5118 } 5119 if (isMulti) { 5120 return selectValue.map(function(opt, index2) { 5121 var isOptionFocused = opt === focusedValue; 5122 var key = "".concat(_this3.getOptionLabel(opt), "-").concat(_this3.getOptionValue(opt)); 5123 return React8.createElement(MultiValue3, _extends({}, commonProps, { 5124 components: { 5125 Container: MultiValueContainer2, 5126 Label: MultiValueLabel2, 5127 Remove: MultiValueRemove2 5128 }, 5129 isFocused: isOptionFocused, 5130 isDisabled, 5131 key, 5132 index: index2, 5133 removeProps: { 5134 onClick: function onClick() { 5135 return _this3.removeValue(opt); 5136 }, 5137 onTouchEnd: function onTouchEnd() { 5138 return _this3.removeValue(opt); 5139 }, 5140 onMouseDown: function onMouseDown(e) { 5141 e.preventDefault(); 5142 } 5143 }, 5144 data: opt 5145 }), _this3.formatOptionLabel(opt, "value")); 5146 }); 5147 } 5148 if (inputValue) { 5149 return null; 5150 } 5151 var singleValue = selectValue[0]; 5152 return React8.createElement(SingleValue3, _extends({}, commonProps, { 5153 data: singleValue, 5154 isDisabled 5155 }), this.formatOptionLabel(singleValue, "value")); 5156 } 5157 }, { 5158 key: "renderClearIndicator", 5159 value: function renderClearIndicator() { 5160 var _this$getComponents3 = this.getComponents(), ClearIndicator4 = _this$getComponents3.ClearIndicator; 5161 var commonProps = this.commonProps; 5162 var _this$props10 = this.props, isDisabled = _this$props10.isDisabled, isLoading = _this$props10.isLoading; 5163 var isFocused = this.state.isFocused; 5164 if (!this.isClearable() || !ClearIndicator4 || isDisabled || !this.hasValue() || isLoading) { 5165 return null; 5166 } 5167 var innerProps = { 5168 onMouseDown: this.onClearIndicatorMouseDown, 5169 onTouchEnd: this.onClearIndicatorTouchEnd, 5170 "aria-hidden": "true" 5171 }; 5172 return React8.createElement(ClearIndicator4, _extends({}, commonProps, { 5173 innerProps, 5174 isFocused 5175 })); 5176 } 5177 }, { 5178 key: "renderLoadingIndicator", 5179 value: function renderLoadingIndicator() { 5180 var _this$getComponents4 = this.getComponents(), LoadingIndicator3 = _this$getComponents4.LoadingIndicator; 5181 var commonProps = this.commonProps; 5182 var _this$props11 = this.props, isDisabled = _this$props11.isDisabled, isLoading = _this$props11.isLoading; 5183 var isFocused = this.state.isFocused; 5184 if (!LoadingIndicator3 || !isLoading) return null; 5185 var innerProps = { 5186 "aria-hidden": "true" 5187 }; 5188 return React8.createElement(LoadingIndicator3, _extends({}, commonProps, { 5189 innerProps, 5190 isDisabled, 5191 isFocused 5192 })); 5193 } 5194 }, { 5195 key: "renderIndicatorSeparator", 5196 value: function renderIndicatorSeparator() { 5197 var _this$getComponents5 = this.getComponents(), DropdownIndicator4 = _this$getComponents5.DropdownIndicator, IndicatorSeparator3 = _this$getComponents5.IndicatorSeparator; 5198 if (!DropdownIndicator4 || !IndicatorSeparator3) return null; 5199 var commonProps = this.commonProps; 5200 var isDisabled = this.props.isDisabled; 5201 var isFocused = this.state.isFocused; 5202 return React8.createElement(IndicatorSeparator3, _extends({}, commonProps, { 5203 isDisabled, 5204 isFocused 5205 })); 5206 } 5207 }, { 5208 key: "renderDropdownIndicator", 5209 value: function renderDropdownIndicator() { 5210 var _this$getComponents6 = this.getComponents(), DropdownIndicator4 = _this$getComponents6.DropdownIndicator; 5211 if (!DropdownIndicator4) return null; 5212 var commonProps = this.commonProps; 5213 var isDisabled = this.props.isDisabled; 5214 var isFocused = this.state.isFocused; 5215 var innerProps = { 5216 onMouseDown: this.onDropdownIndicatorMouseDown, 5217 onTouchEnd: this.onDropdownIndicatorTouchEnd, 5218 "aria-hidden": "true" 5219 }; 5220 return React8.createElement(DropdownIndicator4, _extends({}, commonProps, { 5221 innerProps, 5222 isDisabled, 5223 isFocused 5224 })); 5225 } 5226 }, { 5227 key: "renderMenu", 5228 value: function renderMenu() { 5229 var _this4 = this; 5230 var _this$getComponents7 = this.getComponents(), Group3 = _this$getComponents7.Group, GroupHeading3 = _this$getComponents7.GroupHeading, Menu4 = _this$getComponents7.Menu, MenuList3 = _this$getComponents7.MenuList, MenuPortal3 = _this$getComponents7.MenuPortal, LoadingMessage3 = _this$getComponents7.LoadingMessage, NoOptionsMessage3 = _this$getComponents7.NoOptionsMessage, Option4 = _this$getComponents7.Option; 5231 var commonProps = this.commonProps; 5232 var focusedOption = this.state.focusedOption; 5233 var _this$props12 = this.props, captureMenuScroll = _this$props12.captureMenuScroll, inputValue = _this$props12.inputValue, isLoading = _this$props12.isLoading, loadingMessage2 = _this$props12.loadingMessage, minMenuHeight = _this$props12.minMenuHeight, maxMenuHeight = _this$props12.maxMenuHeight, menuIsOpen = _this$props12.menuIsOpen, menuPlacement = _this$props12.menuPlacement, menuPosition = _this$props12.menuPosition, menuPortalTarget = _this$props12.menuPortalTarget, menuShouldBlockScroll = _this$props12.menuShouldBlockScroll, menuShouldScrollIntoView = _this$props12.menuShouldScrollIntoView, noOptionsMessage2 = _this$props12.noOptionsMessage, onMenuScrollToTop = _this$props12.onMenuScrollToTop, onMenuScrollToBottom = _this$props12.onMenuScrollToBottom; 5234 if (!menuIsOpen) return null; 5235 var render3 = function render4(props, id) { 5236 var type = props.type, data = props.data, isDisabled = props.isDisabled, isSelected = props.isSelected, label = props.label, value = props.value; 5237 var isFocused = focusedOption === data; 5238 var onHover = isDisabled ? void 0 : function() { 5239 return _this4.onOptionHover(data); 5240 }; 5241 var onSelect = isDisabled ? void 0 : function() { 5242 return _this4.selectOption(data); 5243 }; 5244 var optionId = "".concat(_this4.getElementId("option"), "-").concat(id); 5245 var innerProps = { 5246 id: optionId, 5247 onClick: onSelect, 5248 onMouseMove: onHover, 5249 onMouseOver: onHover, 5250 tabIndex: -1, 5251 role: "option", 5252 "aria-selected": _this4.isAppleDevice ? void 0 : isSelected 5253 // is not supported on Apple devices 5254 }; 5255 return React8.createElement(Option4, _extends({}, commonProps, { 5256 innerProps, 5257 data, 5258 isDisabled, 5259 isSelected, 5260 key: optionId, 5261 label, 5262 type, 5263 value, 5264 isFocused, 5265 innerRef: isFocused ? _this4.getFocusedOptionRef : void 0 5266 }), _this4.formatOptionLabel(props.data, "menu")); 5267 }; 5268 var menuUI; 5269 if (this.hasOptions()) { 5270 menuUI = this.getCategorizedOptions().map(function(item) { 5271 if (item.type === "group") { 5272 var _data = item.data, options2 = item.options, groupIndex = item.index; 5273 var groupId = "".concat(_this4.getElementId("group"), "-").concat(groupIndex); 5274 var headingId = "".concat(groupId, "-heading"); 5275 return React8.createElement(Group3, _extends({}, commonProps, { 5276 key: groupId, 5277 data: _data, 5278 options: options2, 5279 Heading: GroupHeading3, 5280 headingProps: { 5281 id: headingId, 5282 data: item.data 5283 }, 5284 label: _this4.formatGroupLabel(item.data) 5285 }), item.options.map(function(option) { 5286 return render3(option, "".concat(groupIndex, "-").concat(option.index)); 5287 })); 5288 } else if (item.type === "option") { 5289 return render3(item, "".concat(item.index)); 5290 } 5291 }); 5292 } else if (isLoading) { 5293 var message = loadingMessage2({ 5294 inputValue 5295 }); 5296 if (message === null) return null; 5297 menuUI = React8.createElement(LoadingMessage3, commonProps, message); 5298 } else { 5299 var _message = noOptionsMessage2({ 5300 inputValue 5301 }); 5302 if (_message === null) return null; 5303 menuUI = React8.createElement(NoOptionsMessage3, commonProps, _message); 5304 } 5305 var menuPlacementProps = { 5306 minMenuHeight, 5307 maxMenuHeight, 5308 menuPlacement, 5309 menuPosition, 5310 menuShouldScrollIntoView 5311 }; 5312 var menuElement = React8.createElement(MenuPlacer, _extends({}, commonProps, menuPlacementProps), function(_ref4) { 5313 var ref = _ref4.ref, _ref4$placerProps = _ref4.placerProps, placement = _ref4$placerProps.placement, maxHeight = _ref4$placerProps.maxHeight; 5314 return React8.createElement(Menu4, _extends({}, commonProps, menuPlacementProps, { 5315 innerRef: ref, 5316 innerProps: { 5317 onMouseDown: _this4.onMenuMouseDown, 5318 onMouseMove: _this4.onMenuMouseMove 5319 }, 5320 isLoading, 5321 placement 5322 }), React8.createElement(ScrollManager, { 5323 captureEnabled: captureMenuScroll, 5324 onTopArrive: onMenuScrollToTop, 5325 onBottomArrive: onMenuScrollToBottom, 5326 lockEnabled: menuShouldBlockScroll 5327 }, function(scrollTargetRef) { 5328 return React8.createElement(MenuList3, _extends({}, commonProps, { 5329 innerRef: function innerRef(instance) { 5330 _this4.getMenuListRef(instance); 5331 scrollTargetRef(instance); 5332 }, 5333 innerProps: { 5334 role: "listbox", 5335 "aria-multiselectable": commonProps.isMulti, 5336 id: _this4.getElementId("listbox") 5337 }, 5338 isLoading, 5339 maxHeight, 5340 focusedOption 5341 }), menuUI); 5342 })); 5343 }); 5344 return menuPortalTarget || menuPosition === "fixed" ? React8.createElement(MenuPortal3, _extends({}, commonProps, { 5345 appendTo: menuPortalTarget, 5346 controlElement: this.controlRef, 5347 menuPlacement, 5348 menuPosition 5349 }), menuElement) : menuElement; 5350 } 5351 }, { 5352 key: "renderFormField", 5353 value: function renderFormField() { 5354 var _this5 = this; 5355 var _this$props13 = this.props, delimiter2 = _this$props13.delimiter, isDisabled = _this$props13.isDisabled, isMulti = _this$props13.isMulti, name = _this$props13.name, required = _this$props13.required; 5356 var selectValue = this.state.selectValue; 5357 if (required && !this.hasValue() && !isDisabled) { 5358 return React8.createElement(RequiredInput$1, { 5359 name, 5360 onFocus: this.onValueInputFocus 5361 }); 5362 } 5363 if (!name || isDisabled) return; 5364 if (isMulti) { 5365 if (delimiter2) { 5366 var value = selectValue.map(function(opt) { 5367 return _this5.getOptionValue(opt); 5368 }).join(delimiter2); 5369 return React8.createElement("input", { 5370 name, 5371 type: "hidden", 5372 value 5373 }); 5374 } else { 5375 var input = selectValue.length > 0 ? selectValue.map(function(opt, i3) { 5376 return React8.createElement("input", { 5377 key: "i-".concat(i3), 5378 name, 5379 type: "hidden", 5380 value: _this5.getOptionValue(opt) 5381 }); 5382 }) : React8.createElement("input", { 5383 name, 5384 type: "hidden", 5385 value: "" 5386 }); 5387 return React8.createElement("div", null, input); 5388 } 5389 } else { 5390 var _value2 = selectValue[0] ? this.getOptionValue(selectValue[0]) : ""; 5391 return React8.createElement("input", { 5392 name, 5393 type: "hidden", 5394 value: _value2 5395 }); 5396 } 5397 } 5398 }, { 5399 key: "renderLiveRegion", 5400 value: function renderLiveRegion() { 5401 var commonProps = this.commonProps; 5402 var _this$state6 = this.state, ariaSelection = _this$state6.ariaSelection, focusedOption = _this$state6.focusedOption, focusedValue = _this$state6.focusedValue, isFocused = _this$state6.isFocused, selectValue = _this$state6.selectValue; 5403 var focusableOptions = this.getFocusableOptions(); 5404 return React8.createElement(LiveRegion$1, _extends({}, commonProps, { 5405 id: this.getElementId("live-region"), 5406 ariaSelection, 5407 focusedOption, 5408 focusedValue, 5409 isFocused, 5410 selectValue, 5411 focusableOptions, 5412 isAppleDevice: this.isAppleDevice 5413 })); 5414 } 5415 }, { 5416 key: "render", 5417 value: function render3() { 5418 var _this$getComponents8 = this.getComponents(), Control3 = _this$getComponents8.Control, IndicatorsContainer3 = _this$getComponents8.IndicatorsContainer, SelectContainer3 = _this$getComponents8.SelectContainer, ValueContainer3 = _this$getComponents8.ValueContainer; 5419 var _this$props14 = this.props, className = _this$props14.className, id = _this$props14.id, isDisabled = _this$props14.isDisabled, menuIsOpen = _this$props14.menuIsOpen; 5420 var isFocused = this.state.isFocused; 5421 var commonProps = this.commonProps = this.getCommonProps(); 5422 return React8.createElement(SelectContainer3, _extends({}, commonProps, { 5423 className, 5424 innerProps: { 5425 id, 5426 onKeyDown: this.onKeyDown 5427 }, 5428 isDisabled, 5429 isFocused 5430 }), this.renderLiveRegion(), React8.createElement(Control3, _extends({}, commonProps, { 5431 innerRef: this.getControlRef, 5432 innerProps: { 5433 onMouseDown: this.onControlMouseDown, 5434 onTouchEnd: this.onControlTouchEnd 5435 }, 5436 isDisabled, 5437 isFocused, 5438 menuIsOpen 5439 }), React8.createElement(ValueContainer3, _extends({}, commonProps, { 5440 isDisabled 5441 }), this.renderPlaceholderOrValue(), this.renderInput()), React8.createElement(IndicatorsContainer3, _extends({}, commonProps, { 5442 isDisabled 5443 }), this.renderClearIndicator(), this.renderLoadingIndicator(), this.renderIndicatorSeparator(), this.renderDropdownIndicator())), this.renderMenu(), this.renderFormField()); 5444 } 5445 }], [{ 5446 key: "getDerivedStateFromProps", 5447 value: function getDerivedStateFromProps(props, state) { 5448 var prevProps = state.prevProps, clearFocusValueOnUpdate = state.clearFocusValueOnUpdate, inputIsHiddenAfterUpdate = state.inputIsHiddenAfterUpdate, ariaSelection = state.ariaSelection, isFocused = state.isFocused, prevWasFocused = state.prevWasFocused, instancePrefix = state.instancePrefix; 5449 var options2 = props.options, value = props.value, menuIsOpen = props.menuIsOpen, inputValue = props.inputValue, isMulti = props.isMulti; 5450 var selectValue = cleanValue(value); 5451 var newMenuOptionsState = {}; 5452 if (prevProps && (value !== prevProps.value || options2 !== prevProps.options || menuIsOpen !== prevProps.menuIsOpen || inputValue !== prevProps.inputValue)) { 5453 var focusableOptions = menuIsOpen ? buildFocusableOptions(props, selectValue) : []; 5454 var focusableOptionsWithIds = menuIsOpen ? buildFocusableOptionsWithIds(buildCategorizedOptions(props, selectValue), "".concat(instancePrefix, "-option")) : []; 5455 var focusedValue = clearFocusValueOnUpdate ? getNextFocusedValue(state, selectValue) : null; 5456 var focusedOption = getNextFocusedOption(state, focusableOptions); 5457 var focusedOptionId = getFocusedOptionId(focusableOptionsWithIds, focusedOption); 5458 newMenuOptionsState = { 5459 selectValue, 5460 focusedOption, 5461 focusedOptionId, 5462 focusableOptionsWithIds, 5463 focusedValue, 5464 clearFocusValueOnUpdate: false 5465 }; 5466 } 5467 var newInputIsHiddenState = inputIsHiddenAfterUpdate != null && props !== prevProps ? { 5468 inputIsHidden: inputIsHiddenAfterUpdate, 5469 inputIsHiddenAfterUpdate: void 0 5470 } : {}; 5471 var newAriaSelection = ariaSelection; 5472 var hasKeptFocus = isFocused && prevWasFocused; 5473 if (isFocused && !hasKeptFocus) { 5474 newAriaSelection = { 5475 value: valueTernary(isMulti, selectValue, selectValue[0] || null), 5476 options: selectValue, 5477 action: "initial-input-focus" 5478 }; 5479 hasKeptFocus = !prevWasFocused; 5480 } 5481 if ((ariaSelection === null || ariaSelection === void 0 ? void 0 : ariaSelection.action) === "initial-input-focus") { 5482 newAriaSelection = null; 5483 } 5484 return _objectSpread2(_objectSpread2(_objectSpread2({}, newMenuOptionsState), newInputIsHiddenState), {}, { 5485 prevProps: props, 5486 ariaSelection: newAriaSelection, 5487 prevWasFocused: hasKeptFocus 5488 }); 5489 } 5490 }]); 5491 return Select3; 5492}(import_react6.Component); 5493Select.defaultProps = defaultProps; 5494
vendor: 470 bytes, lines 5495-5504
5495// node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/react-select/dist/react-select.esm.js 5496var import_react_dom2 = __toESM(require_react_dom()); 5497var StateManagedSelect = (0, import_react8.forwardRef)(function(props, ref) { 5498 var baseSelectProps = useStateManager(props); 5499 return React9.createElement(Select, _extends({ 5500 ref 5501 }, baseSelectProps)); 5502}); 5503var StateManagedSelect$1 = StateManagedSelect; 5504
vendor: 2,006 bytes, lines 5505-5565
5505// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/SelectTree/Option.mjs 5506var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1); 5507var import_react10 = __toESM(require_react(), 1); 5508var ToggleButton = dt(Flex)` 5509 align-self: flex-end; 5510 height: 2.2rem; 5511 width: 2.8rem; 5512 5513 &:hover, 5514 &:focus { 5515 background-color: ${({ theme }) => theme.colors.primary200}; 5516 } 5517`; 5518var Option3 = ({ children, data, selectProps, ...props }) => { 5519 const { formatMessage } = useIntl(); 5520 const { depth, value, children: options2 } = data; 5521 const { maxDisplayDepth, openValues, onOptionToggle } = selectProps; 5522 const isOpen = openValues.includes(value); 5523 const Icon = isOpen ? ForwardRef$2i : ForwardRef$2l; 5524 return (0, import_jsx_runtime2.jsx)(components.Option, { 5525 data, 5526 selectProps, 5527 ...props, 5528 children: (0, import_jsx_runtime2.jsxs)(Flex, { 5529 alignItems: "start", 5530 children: [ 5531 (0, import_jsx_runtime2.jsx)(Typography, { 5532 textColor: "neutral800", 5533 ellipsis: true, 5534 children: (0, import_jsx_runtime2.jsx)("span", { 5535 style: { 5536 paddingLeft: `${Math.min(depth, maxDisplayDepth) * 14}px` 5537 }, 5538 children 5539 }) 5540 }), 5541 options2 && (options2 == null ? void 0 : options2.length) > 0 && (0, import_jsx_runtime2.jsx)(ToggleButton, { 5542 "aria-label": formatMessage({ 5543 id: "app.utils.toggle", 5544 defaultMessage: "Toggle" 5545 }), 5546 tag: "button", 5547 alignItems: "center", 5548 hasRadius: true, 5549 justifyContent: "center", 5550 marginLeft: "auto", 5551 onClick: (event) => { 5552 event.preventDefault(); 5553 event.stopPropagation(); 5554 onOptionToggle(value); 5555 }, 5556 children: (0, import_jsx_runtime2.jsx)(Icon, { 5557 width: "1.4rem", 5558 fill: "neutral500" 5559 }) 5560 }) 5561 ] 5562 }) 5563 }); 5564}; 5565
vendor: 671 bytes, lines 5566-5586
5566// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/SelectTree/utils/flattenTree.mjs 5567function flattenTree(tree, parent = null, depth = 0, path = "") { 5568 return tree.flatMap((item) => { 5569 const newPath = item.value ? `${path}/${item.value}` : path; 5570 return item.children ? [ 5571 { 5572 ...item, 5573 parent: parent == null ? void 0 : parent.value, 5574 depth, 5575 path: newPath 5576 }, 5577 ...flattenTree(item.children, item, depth + 1, newPath) 5578 ] : { 5579 ...item, 5580 depth, 5581 parent: parent == null ? void 0 : parent.value, 5582 path: newPath 5583 }; 5584 }); 5585} 5586
vendor: 678 bytes, lines 5587-5607
5587// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/SelectTree/utils/getOpenValues.mjs 5588function getOpenValues(options2, defaultValue = {}) { 5589 const values = []; 5590 const { value } = defaultValue; 5591 const option = options2.find((option2) => option2.value === value); 5592 if (!option) { 5593 return values; 5594 } 5595 values.push(option.value); 5596 let { parent } = option; 5597 while (parent !== void 0) { 5598 const option2 = options2.find(({ value: value2 }) => value2 === parent); 5599 if (!option2) { 5600 break; 5601 } 5602 values.push(option2.value); 5603 parent = option2.parent; 5604 } 5605 return values.reverse(); 5606} 5607
vendor: 439 bytes, lines 5608-5616
5608// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/SelectTree/utils/getValuesToClose.mjs 5609function getValuesToClose(options2, value) { 5610 const optionForValue = options2.find((option) => option.value === value); 5611 if (!optionForValue) { 5612 return []; 5613 } 5614 return options2.filter((option) => option.depth >= optionForValue.depth).map((option) => option.value); 5615} 5616
vendor: 6,887 bytes, lines 5617-5860
5617// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/SelectTree/SelectTree.mjs 5618var hasParent = (option) => !option.parent; 5619var SelectTree = ({ options: defaultOptions, maxDisplayDepth = 5, defaultValue, ...props }) => { 5620 const flatDefaultOptions = React10.useMemo(() => flattenTree(defaultOptions), [ 5621 defaultOptions 5622 ]); 5623 const optionsFiltered = React10.useMemo(() => flatDefaultOptions.filter(hasParent), [ 5624 flatDefaultOptions 5625 ]); 5626 const [options2, setOptions] = React10.useState(optionsFiltered); 5627 const [openValues, setOpenValues] = React10.useState(getOpenValues(flatDefaultOptions, defaultValue)); 5628 React10.useEffect(() => { 5629 if (openValues.length === 0) { 5630 setOptions(flatDefaultOptions.filter((option) => option.parent === void 0)); 5631 } else { 5632 const allOpenValues = openValues.reduce((acc, value) => { 5633 const options3 = flatDefaultOptions.filter((option) => option.value === value || option.parent === value); 5634 options3.forEach((option) => { 5635 const values = getOpenValues(flatDefaultOptions, option); 5636 acc = [ 5637 ...acc, 5638 ...values 5639 ]; 5640 }); 5641 return acc; 5642 }, []); 5643 const nextOptions = flatDefaultOptions.filter((option) => allOpenValues.includes(option.value)); 5644 setOptions(nextOptions); 5645 } 5646 }, [ 5647 openValues, 5648 flatDefaultOptions, 5649 optionsFiltered 5650 ]); 5651 const handleToggle = (value) => { 5652 if (openValues.includes(value)) { 5653 const valuesToClose = getValuesToClose(flatDefaultOptions, value); 5654 setOpenValues((prev2) => prev2.filter((prevData) => !valuesToClose.includes(prevData))); 5655 } else { 5656 setOpenValues((prev2) => [ 5657 ...prev2, 5658 value 5659 ]); 5660 } 5661 }; 5662 return (0, import_jsx_runtime3.jsx)(Select2, { 5663 components: { 5664 Option: Option3 5665 }, 5666 options: options2, 5667 defaultValue, 5668 isSearchable: false, 5669 /* -- custom props, used by the Option component */ 5670 maxDisplayDepth, 5671 openValues, 5672 onOptionToggle: handleToggle, 5673 ...props 5674 }); 5675}; 5676var Select2 = ({ components: components2 = {}, styles = {}, error, ariaErrorMessage, ...props }) => { 5677 const theme = nt(); 5678 const customStyles = getSelectStyles(theme, error); 5679 return (0, import_jsx_runtime3.jsx)(StateManagedSelect$1, { 5680 menuPosition: "fixed", 5681 components: { 5682 ...components2, 5683 ClearIndicator: ClearIndicator3, 5684 DropdownIndicator: DropdownIndicator3, 5685 IndicatorSeparator: () => null, 5686 LoadingIndicator: () => null 5687 }, 5688 "aria-errormessage": error && ariaErrorMessage, 5689 "aria-invalid": !!error, 5690 styles: { 5691 ...customStyles, 5692 ...styles 5693 }, 5694 ...props 5695 }); 5696}; 5697var IconBox = dt(Box)` 5698 background: transparent; 5699 border: none; 5700 position: relative; 5701 z-index: 1; 5702 5703 svg { 5704 height: 1.1rem; 5705 width: 1.1rem; 5706 } 5707 5708 svg path { 5709 fill: ${({ theme }) => theme.colors.neutral600}; 5710 } 5711`; 5712var ClearIndicator3 = (props) => { 5713 const Component2 = components.ClearIndicator; 5714 return (0, import_jsx_runtime3.jsx)(Component2, { 5715 ...props, 5716 children: (0, import_jsx_runtime3.jsx)(IconBox, { 5717 tag: "button", 5718 type: "button", 5719 children: (0, import_jsx_runtime3.jsx)(ForwardRef$26, {}) 5720 }) 5721 }); 5722}; 5723var CarretBox = dt(IconBox)` 5724 display: flex; 5725 background: none; 5726 border: none; 5727 5728 svg { 5729 width: 0.9rem; 5730 } 5731`; 5732var DropdownIndicator3 = ({ innerProps }) => { 5733 return (0, import_jsx_runtime3.jsx)(CarretBox, { 5734 paddingRight: 3, 5735 ...innerProps, 5736 children: (0, import_jsx_runtime3.jsx)(ForwardRef$2v, {}) 5737 }); 5738}; 5739var getSelectStyles = (theme, error) => { 5740 return { 5741 clearIndicator: (base) => ({ 5742 ...base, 5743 padding: 0, 5744 paddingRight: theme.spaces[3] 5745 }), 5746 container: (base) => ({ 5747 ...base, 5748 background: theme.colors.neutral0, 5749 lineHeight: "normal" 5750 }), 5751 control(base, state) { 5752 let borderColor = theme.colors.neutral200; 5753 let boxShadowColor = void 0; 5754 let backgroundColor = void 0; 5755 if (state.isFocused) { 5756 borderColor = theme.colors.primary600; 5757 boxShadowColor = theme.colors.primary600; 5758 } else if (error) { 5759 borderColor = theme.colors.danger600; 5760 } 5761 if (state.isDisabled) { 5762 backgroundColor = `${theme.colors.neutral150} !important`; 5763 } 5764 return { 5765 ...base, 5766 fontSize: theme.fontSizes[2], 5767 height: 40, 5768 border: `1px solid ${borderColor} !important`, 5769 outline: 0, 5770 backgroundColor, 5771 borderRadius: theme.borderRadius, 5772 boxShadow: boxShadowColor ? `${boxShadowColor} 0px 0px 0px 2px` : "" 5773 }; 5774 }, 5775 indicatorsContainer: (base) => ({ 5776 ...base, 5777 padding: 0, 5778 paddingRight: theme.spaces[3] 5779 }), 5780 input: (base) => ({ 5781 ...base, 5782 margin: 0, 5783 padding: 0, 5784 color: theme.colors.neutral800, 5785 gridTemplateColumns: "0 100%" 5786 }), 5787 menuPortal: (base) => ({ 5788 ...base, 5789 zIndex: theme.zIndices.dialog, 5790 pointerEvents: "auto" 5791 }), 5792 menu(base) { 5793 return { 5794 ...base, 5795 width: "100%", 5796 marginTop: theme.spaces[1], 5797 backgroundColor: theme.colors.neutral0, 5798 color: theme.colors.neutral800, 5799 borderRadius: theme.borderRadius, 5800 border: `1px solid ${theme.colors.neutral200}`, 5801 boxShadow: theme.shadows.tableShadow, 5802 fontSize: theme.fontSizes[2], 5803 zIndex: 2 5804 }; 5805 }, 5806 menuList: (base) => ({ 5807 ...base, 5808 paddingLeft: theme.spaces[1], 5809 paddingTop: theme.spaces[1], 5810 paddingRight: theme.spaces[1], 5811 paddingBottom: theme.spaces[1] 5812 }), 5813 // eslint-disable-next-line @typescript-eslint/no-explicit-any 5814 option(base, state) { 5815 let backgroundColor = base == null ? void 0 : base.backgroundColor; 5816 if (state.isFocused || state.isSelected) { 5817 backgroundColor = theme.colors.primary100; 5818 } 5819 return { 5820 ...base, 5821 color: theme.colors.neutral800, 5822 lineHeight: theme.spaces[5], 5823 backgroundColor, 5824 borderRadius: theme.borderRadius, 5825 "&:active": { 5826 backgroundColor: theme.colors.primary100 5827 } 5828 }; 5829 }, 5830 placeholder: (base) => ({ 5831 ...base, 5832 color: theme.colors.neutral600, 5833 marginLeft: 0, 5834 overflow: "hidden", 5835 textOverflow: "ellipsis", 5836 whiteSpace: "nowrap", 5837 maxWidth: "80%" 5838 }), 5839 singleValue(base, state) { 5840 let color = theme.colors.neutral800; 5841 if (state.isDisabled) { 5842 color = theme.colors.neutral600; 5843 } 5844 return { 5845 ...base, 5846 marginLeft: 0, 5847 color 5848 }; 5849 }, 5850 valueContainer: (base) => ({ 5851 ...base, 5852 cursor: "pointer", 5853 padding: 0, 5854 paddingLeft: theme.spaces[4], 5855 marginLeft: 0, 5856 marginRight: 0 5857 }) 5858 }; 5859}; 5860
vendor: 521 bytes, lines 5861-5874
5861// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EditAssetDialog/DialogHeader.mjs 5862var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1); 5863var DialogHeader = () => { 5864 const { formatMessage } = useIntl(); 5865 return (0, import_jsx_runtime4.jsx)(Modal.Header, { 5866 children: (0, import_jsx_runtime4.jsx)(Modal.Title, { 5867 children: formatMessage({ 5868 id: "global.details", 5869 defaultMessage: "Details" 5870 }) 5871 }) 5872 }); 5873}; 5874
vendor: 389 bytes, lines 5875-5879
5875// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EditAssetDialog/PreviewBox/PreviewBox.mjs 5876var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1); 5877var React14 = __toESM(require_react(), 1); 5878import cropperjscss from "/admin/node_modules/.pnpm/[email protected]/node_modules/cropperjs/dist/cropper.css?raw"; 5879
vendor: 181 bytes, lines 5880-5882
5880// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/hooks/useCropImg.mjs 5881var React11 = __toESM(require_react(), 1); 5882
vendor: 94,061 bytes, lines 5883-8600
5883// node_modules/.pnpm/[email protected]/node_modules/cropperjs/dist/cropper.esm.js 5884function ownKeys(e, r10) { 5885 var t2 = Object.keys(e); 5886 if (Object.getOwnPropertySymbols) { 5887 var o2 = Object.getOwnPropertySymbols(e); 5888 r10 && (o2 = o2.filter(function(r11) { 5889 return Object.getOwnPropertyDescriptor(e, r11).enumerable; 5890 })), t2.push.apply(t2, o2); 5891 } 5892 return t2; 5893} 5894function _objectSpread22(e) { 5895 for (var r10 = 1; r10 < arguments.length; r10++) { 5896 var t2 = null != arguments[r10] ? arguments[r10] : {}; 5897 r10 % 2 ? ownKeys(Object(t2), true).forEach(function(r11) { 5898 _defineProperty2(e, r11, t2[r11]); 5899 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t2)) : ownKeys(Object(t2)).forEach(function(r11) { 5900 Object.defineProperty(e, r11, Object.getOwnPropertyDescriptor(t2, r11)); 5901 }); 5902 } 5903 return e; 5904} 5905function _typeof2(o2) { 5906 "@babel/helpers - typeof"; 5907 return _typeof2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o3) { 5908 return typeof o3; 5909 } : function(o3) { 5910 return o3 && "function" == typeof Symbol && o3.constructor === Symbol && o3 !== Symbol.prototype ? "symbol" : typeof o3; 5911 }, _typeof2(o2); 5912} 5913function _classCallCheck2(instance, Constructor) { 5914 if (!(instance instanceof Constructor)) { 5915 throw new TypeError("Cannot call a class as a function"); 5916 } 5917} 5918function _defineProperties(target, props) { 5919 for (var i3 = 0; i3 < props.length; i3++) { 5920 var descriptor = props[i3]; 5921 descriptor.enumerable = descriptor.enumerable || false; 5922 descriptor.configurable = true; 5923 if ("value" in descriptor) descriptor.writable = true; 5924 Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); 5925 } 5926} 5927function _createClass2(Constructor, protoProps, staticProps) { 5928 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 5929 if (staticProps) _defineProperties(Constructor, staticProps); 5930 Object.defineProperty(Constructor, "prototype", { 5931 writable: false 5932 }); 5933 return Constructor; 5934} 5935function _defineProperty2(obj, key, value) { 5936 key = _toPropertyKey(key); 5937 if (key in obj) { 5938 Object.defineProperty(obj, key, { 5939 value, 5940 enumerable: true, 5941 configurable: true, 5942 writable: true 5943 }); 5944 } else { 5945 obj[key] = value; 5946 } 5947 return obj; 5948} 5949function _toConsumableArray2(arr) { 5950 return _arrayWithoutHoles2(arr) || _iterableToArray2(arr) || _unsupportedIterableToArray2(arr) || _nonIterableSpread2(); 5951} 5952function _arrayWithoutHoles2(arr) { 5953 if (Array.isArray(arr)) return _arrayLikeToArray2(arr); 5954} 5955function _iterableToArray2(iter) { 5956 if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); 5957} 5958function _unsupportedIterableToArray2(o2, minLen) { 5959 if (!o2) return; 5960 if (typeof o2 === "string") return _arrayLikeToArray2(o2, minLen); 5961 var n2 = Object.prototype.toString.call(o2).slice(8, -1); 5962 if (n2 === "Object" && o2.constructor) n2 = o2.constructor.name; 5963 if (n2 === "Map" || n2 === "Set") return Array.from(o2); 5964 if (n2 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2)) return _arrayLikeToArray2(o2, minLen); 5965} 5966function _arrayLikeToArray2(arr, len) { 5967 if (len == null || len > arr.length) len = arr.length; 5968 for (var i3 = 0, arr2 = new Array(len); i3 < len; i3++) arr2[i3] = arr[i3]; 5969 return arr2; 5970} 5971function _nonIterableSpread2() { 5972 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 5973} 5974function _toPrimitive(input, hint) { 5975 if (typeof input !== "object" || input === null) return input; 5976 var prim = input[Symbol.toPrimitive]; 5977 if (prim !== void 0) { 5978 var res = prim.call(input, hint || "default"); 5979 if (typeof res !== "object") return res; 5980 throw new TypeError("@@toPrimitive must return a primitive value."); 5981 } 5982 return (hint === "string" ? String : Number)(input); 5983} 5984function _toPropertyKey(arg) { 5985 var key = _toPrimitive(arg, "string"); 5986 return typeof key === "symbol" ? key : String(key); 5987} 5988var IS_BROWSER = typeof window !== "undefined" && typeof window.document !== "undefined"; 5989var WINDOW = IS_BROWSER ? window : {}; 5990var IS_TOUCH_DEVICE = IS_BROWSER && WINDOW.document.documentElement ? "ontouchstart" in WINDOW.document.documentElement : false; 5991var HAS_POINTER_EVENT = IS_BROWSER ? "PointerEvent" in WINDOW : false; 5992var NAMESPACE = "cropper"; 5993var ACTION_ALL = "all"; 5994var ACTION_CROP = "crop"; 5995var ACTION_MOVE = "move"; 5996var ACTION_ZOOM = "zoom"; 5997var ACTION_EAST = "e"; 5998var ACTION_WEST = "w"; 5999var ACTION_SOUTH = "s"; 6000var ACTION_NORTH = "n"; 6001var ACTION_NORTH_EAST = "ne"; 6002var ACTION_NORTH_WEST = "nw"; 6003var ACTION_SOUTH_EAST = "se"; 6004var ACTION_SOUTH_WEST = "sw"; 6005var CLASS_CROP = "".concat(NAMESPACE, "-crop"); 6006var CLASS_DISABLED = "".concat(NAMESPACE, "-disabled"); 6007var CLASS_HIDDEN = "".concat(NAMESPACE, "-hidden"); 6008var CLASS_HIDE = "".concat(NAMESPACE, "-hide"); 6009var CLASS_INVISIBLE = "".concat(NAMESPACE, "-invisible"); 6010var CLASS_MODAL = "".concat(NAMESPACE, "-modal"); 6011var CLASS_MOVE = "".concat(NAMESPACE, "-move"); 6012var DATA_ACTION = "".concat(NAMESPACE, "Action"); 6013var DATA_PREVIEW = "".concat(NAMESPACE, "Preview"); 6014var DRAG_MODE_CROP = "crop"; 6015var DRAG_MODE_MOVE = "move"; 6016var DRAG_MODE_NONE = "none"; 6017var EVENT_CROP = "crop"; 6018var EVENT_CROP_END = "cropend"; 6019var EVENT_CROP_MOVE = "cropmove"; 6020var EVENT_CROP_START = "cropstart"; 6021var EVENT_DBLCLICK = "dblclick"; 6022var EVENT_TOUCH_START = IS_TOUCH_DEVICE ? "touchstart" : "mousedown"; 6023var EVENT_TOUCH_MOVE = IS_TOUCH_DEVICE ? "touchmove" : "mousemove"; 6024var EVENT_TOUCH_END = IS_TOUCH_DEVICE ? "touchend touchcancel" : "mouseup"; 6025var EVENT_POINTER_DOWN = HAS_POINTER_EVENT ? "pointerdown" : EVENT_TOUCH_START; 6026var EVENT_POINTER_MOVE = HAS_POINTER_EVENT ? "pointermove" : EVENT_TOUCH_MOVE; 6027var EVENT_POINTER_UP = HAS_POINTER_EVENT ? "pointerup pointercancel" : EVENT_TOUCH_END; 6028var EVENT_READY = "ready"; 6029var EVENT_RESIZE = "resize"; 6030var EVENT_WHEEL = "wheel"; 6031var EVENT_ZOOM = "zoom"; 6032var MIME_TYPE_JPEG = "image/jpeg"; 6033var REGEXP_ACTIONS = /^e|w|s|n|se|sw|ne|nw|all|crop|move|zoom$/; 6034var REGEXP_DATA_URL = /^data:/; 6035var REGEXP_DATA_URL_JPEG = /^data:image\/jpeg;base64,/; 6036var REGEXP_TAG_NAME = /^img|canvas$/i; 6037var MIN_CONTAINER_WIDTH = 200; 6038var MIN_CONTAINER_HEIGHT = 100; 6039var DEFAULTS = { 6040 // Define the view mode of the cropper 6041 viewMode: 0, 6042 // 0, 1, 2, 3 6043 // Define the dragging mode of the cropper 6044 dragMode: DRAG_MODE_CROP, 6045 // 'crop', 'move' or 'none' 6046 // Define the initial aspect ratio of the crop box 6047 initialAspectRatio: NaN, 6048 // Define the aspect ratio of the crop box 6049 aspectRatio: NaN, 6050 // An object with the previous cropping result data 6051 data: null, 6052 // A selector for adding extra containers to preview 6053 preview: "", 6054 // Re-render the cropper when resize the window 6055 responsive: true, 6056 // Restore the cropped area after resize the window 6057 restore: true, 6058 // Check if the current image is a cross-origin image 6059 checkCrossOrigin: true, 6060 // Check the current image's Exif Orientation information 6061 checkOrientation: true, 6062 // Show the black modal 6063 modal: true, 6064 // Show the dashed lines for guiding 6065 guides: true, 6066 // Show the center indicator for guiding 6067 center: true, 6068 // Show the white modal to highlight the crop box 6069 highlight: true, 6070 // Show the grid background 6071 background: true, 6072 // Enable to crop the image automatically when initialize 6073 autoCrop: true, 6074 // Define the percentage of automatic cropping area when initializes 6075 autoCropArea: 0.8, 6076 // Enable to move the image 6077 movable: true, 6078 // Enable to rotate the image 6079 rotatable: true, 6080 // Enable to scale the image 6081 scalable: true, 6082 // Enable to zoom the image 6083 zoomable: true, 6084 // Enable to zoom the image by dragging touch 6085 zoomOnTouch: true, 6086 // Enable to zoom the image by wheeling mouse 6087 zoomOnWheel: true, 6088 // Define zoom ratio when zoom the image by wheeling mouse 6089 wheelZoomRatio: 0.1, 6090 // Enable to move the crop box 6091 cropBoxMovable: true, 6092 // Enable to resize the crop box 6093 cropBoxResizable: true, 6094 // Toggle drag mode between "crop" and "move" when click twice on the cropper 6095 toggleDragModeOnDblclick: true, 6096 // Size limitation 6097 minCanvasWidth: 0, 6098 minCanvasHeight: 0, 6099 minCropBoxWidth: 0, 6100 minCropBoxHeight: 0, 6101 minContainerWidth: MIN_CONTAINER_WIDTH, 6102 minContainerHeight: MIN_CONTAINER_HEIGHT, 6103 // Shortcuts of events 6104 ready: null, 6105 cropstart: null, 6106 cropmove: null, 6107 cropend: null, 6108 crop: null, 6109 zoom: null 6110}; 6111var TEMPLATE = '<div class="cropper-container" touch-action="none"><div class="cropper-wrap-box"><div class="cropper-canvas"></div></div><div class="cropper-drag-box"></div><div class="cropper-crop-box"><span class="cropper-view-box"></span><span class="cropper-dashed dashed-h"></span><span class="cropper-dashed dashed-v"></span><span class="cropper-center"></span><span class="cropper-face"></span><span class="cropper-line line-e" data-cropper-action="e"></span><span class="cropper-line line-n" data-cropper-action="n"></span><span class="cropper-line line-w" data-cropper-action="w"></span><span class="cropper-line line-s" data-cropper-action="s"></span><span class="cropper-point point-e" data-cropper-action="e"></span><span class="cropper-point point-n" data-cropper-action="n"></span><span class="cropper-point point-w" data-cropper-action="w"></span><span class="cropper-point point-s" data-cropper-action="s"></span><span class="cropper-point point-ne" data-cropper-action="ne"></span><span class="cropper-point point-nw" data-cropper-action="nw"></span><span class="cropper-point point-sw" data-cropper-action="sw"></span><span class="cropper-point point-se" data-cropper-action="se"></span></div></div>'; 6112var isNaN2 = Number.isNaN || WINDOW.isNaN; 6113function isNumber(value) { 6114 return typeof value === "number" && !isNaN2(value); 6115} 6116var isPositiveNumber = function isPositiveNumber2(value) { 6117 return value > 0 && value < Infinity; 6118}; 6119function isUndefined(value) { 6120 return typeof value === "undefined"; 6121} 6122function isObject(value) { 6123 return _typeof2(value) === "object" && value !== null; 6124} 6125var hasOwnProperty = Object.prototype.hasOwnProperty; 6126function isPlainObject(value) { 6127 if (!isObject(value)) { 6128 return false; 6129 } 6130 try { 6131 var _constructor = value.constructor; 6132 var prototype = _constructor.prototype; 6133 return _constructor && prototype && hasOwnProperty.call(prototype, "isPrototypeOf"); 6134 } catch (error) { 6135 return false; 6136 } 6137} 6138function isFunction(value) { 6139 return typeof value === "function"; 6140} 6141var slice2 = Array.prototype.slice; 6142function toArray(value) { 6143 return Array.from ? Array.from(value) : slice2.call(value); 6144} 6145function forEach(data, callback) { 6146 if (data && isFunction(callback)) { 6147 if (Array.isArray(data) || isNumber(data.length)) { 6148 toArray(data).forEach(function(value, key) { 6149 callback.call(data, value, key, data); 6150 }); 6151 } else if (isObject(data)) { 6152 Object.keys(data).forEach(function(key) { 6153 callback.call(data, data[key], key, data); 6154 }); 6155 } 6156 } 6157 return data; 6158} 6159var assign2 = Object.assign || function assign3(target) { 6160 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 6161 args[_key - 1] = arguments[_key]; 6162 } 6163 if (isObject(target) && args.length > 0) { 6164 args.forEach(function(arg) { 6165 if (isObject(arg)) { 6166 Object.keys(arg).forEach(function(key) { 6167 target[key] = arg[key]; 6168 }); 6169 } 6170 }); 6171 } 6172 return target; 6173}; 6174var REGEXP_DECIMALS = /\.\d*(?:0|9){12}\d*$/; 6175function normalizeDecimalNumber(value) { 6176 var times = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1e11; 6177 return REGEXP_DECIMALS.test(value) ? Math.round(value * times) / times : value; 6178} 6179var REGEXP_SUFFIX = /^width|height|left|top|marginLeft|marginTop$/; 6180function setStyle(element, styles) { 6181 var style = element.style; 6182 forEach(styles, function(value, property) { 6183 if (REGEXP_SUFFIX.test(property) && isNumber(value)) { 6184 value = "".concat(value, "px"); 6185 } 6186 style[property] = value; 6187 }); 6188} 6189function hasClass(element, value) { 6190 return element.classList ? element.classList.contains(value) : element.className.indexOf(value) > -1; 6191} 6192function addClass(element, value) { 6193 if (!value) { 6194 return; 6195 } 6196 if (isNumber(element.length)) { 6197 forEach(element, function(elem) { 6198 addClass(elem, value); 6199 }); 6200 return; 6201 } 6202 if (element.classList) { 6203 element.classList.add(value); 6204 return; 6205 } 6206 var className = element.className.trim(); 6207 if (!className) { 6208 element.className = value; 6209 } else if (className.indexOf(value) < 0) { 6210 element.className = "".concat(className, " ").concat(value); 6211 } 6212} 6213function removeClass(element, value) { 6214 if (!value) { 6215 return; 6216 } 6217 if (isNumber(element.length)) { 6218 forEach(element, function(elem) { 6219 removeClass(elem, value); 6220 }); 6221 return; 6222 } 6223 if (element.classList) { 6224 element.classList.remove(value); 6225 return; 6226 } 6227 if (element.className.indexOf(value) >= 0) { 6228 element.className = element.className.replace(value, ""); 6229 } 6230} 6231function toggleClass(element, value, added) { 6232 if (!value) { 6233 return; 6234 } 6235 if (isNumber(element.length)) { 6236 forEach(element, function(elem) { 6237 toggleClass(elem, value, added); 6238 }); 6239 return; 6240 } 6241 if (added) { 6242 addClass(element, value); 6243 } else { 6244 removeClass(element, value); 6245 } 6246} 6247var REGEXP_CAMEL_CASE = /([a-z\d])([A-Z])/g; 6248function toParamCase(value) { 6249 return value.replace(REGEXP_CAMEL_CASE, "$1-$2").toLowerCase(); 6250} 6251function getData(element, name) { 6252 if (isObject(element[name])) { 6253 return element[name]; 6254 } 6255 if (element.dataset) { 6256 return element.dataset[name]; 6257 } 6258 return element.getAttribute("data-".concat(toParamCase(name))); 6259} 6260function setData(element, name, data) { 6261 if (isObject(data)) { 6262 element[name] = data; 6263 } else if (element.dataset) { 6264 element.dataset[name] = data; 6265 } else { 6266 element.setAttribute("data-".concat(toParamCase(name)), data); 6267 } 6268} 6269function removeData(element, name) { 6270 if (isObject(element[name])) { 6271 try { 6272 delete element[name]; 6273 } catch (error) { 6274 element[name] = void 0; 6275 } 6276 } else if (element.dataset) { 6277 try { 6278 delete element.dataset[name]; 6279 } catch (error) { 6280 element.dataset[name] = void 0; 6281 } 6282 } else { 6283 element.removeAttribute("data-".concat(toParamCase(name))); 6284 } 6285} 6286var REGEXP_SPACES = /\s\s*/; 6287var onceSupported = function() { 6288 var supported = false; 6289 if (IS_BROWSER) { 6290 var once = false; 6291 var listener = function listener2() { 6292 }; 6293 var options2 = Object.defineProperty({}, "once", { 6294 get: function get() { 6295 supported = true; 6296 return once; 6297 }, 6298 /** 6299 * This setter can fix a `TypeError` in strict mode 6300 * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Getter_only} 6301 * @param {boolean} value - The value to set 6302 */ 6303 set: function set(value) { 6304 once = value; 6305 } 6306 }); 6307 WINDOW.addEventListener("test", listener, options2); 6308 WINDOW.removeEventListener("test", listener, options2); 6309 } 6310 return supported; 6311}(); 6312function removeListener(element, type, listener) { 6313 var options2 = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}; 6314 var handler = listener; 6315 type.trim().split(REGEXP_SPACES).forEach(function(event) { 6316 if (!onceSupported) { 6317 var listeners = element.listeners; 6318 if (listeners && listeners[event] && listeners[event][listener]) { 6319 handler = listeners[event][listener]; 6320 delete listeners[event][listener]; 6321 if (Object.keys(listeners[event]).length === 0) { 6322 delete listeners[event]; 6323 } 6324 if (Object.keys(listeners).length === 0) { 6325 delete element.listeners; 6326 } 6327 } 6328 } 6329 element.removeEventListener(event, handler, options2); 6330 }); 6331} 6332function addListener(element, type, listener) { 6333 var options2 = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}; 6334 var _handler = listener; 6335 type.trim().split(REGEXP_SPACES).forEach(function(event) { 6336 if (options2.once && !onceSupported) { 6337 var _element$listeners = element.listeners, listeners = _element$listeners === void 0 ? {} : _element$listeners; 6338 _handler = function handler() { 6339 delete listeners[event][listener]; 6340 element.removeEventListener(event, _handler, options2); 6341 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 6342 args[_key2] = arguments[_key2]; 6343 } 6344 listener.apply(element, args); 6345 }; 6346 if (!listeners[event]) { 6347 listeners[event] = {}; 6348 } 6349 if (listeners[event][listener]) { 6350 element.removeEventListener(event, listeners[event][listener], options2); 6351 } 6352 listeners[event][listener] = _handler; 6353 element.listeners = listeners; 6354 } 6355 element.addEventListener(event, _handler, options2); 6356 }); 6357} 6358function dispatchEvent(element, type, data) { 6359 var event; 6360 if (isFunction(Event) && isFunction(CustomEvent)) { 6361 event = new CustomEvent(type, { 6362 detail: data, 6363 bubbles: true, 6364 cancelable: true 6365 }); 6366 } else { 6367 event = document.createEvent("CustomEvent"); 6368 event.initCustomEvent(type, true, true, data); 6369 } 6370 return element.dispatchEvent(event); 6371} 6372function getOffset(element) { 6373 var box = element.getBoundingClientRect(); 6374 return { 6375 left: box.left + (window.pageXOffset - document.documentElement.clientLeft), 6376 top: box.top + (window.pageYOffset - document.documentElement.clientTop) 6377 }; 6378} 6379var location2 = WINDOW.location; 6380var REGEXP_ORIGINS = /^(\w+:)\/\/([^:/?#]*):?(\d*)/i; 6381function isCrossOriginURL(url) { 6382 var parts = url.match(REGEXP_ORIGINS); 6383 return parts !== null && (parts[1] !== location2.protocol || parts[2] !== location2.hostname || parts[3] !== location2.port); 6384} 6385function addTimestamp(url) { 6386 var timestamp = "timestamp=".concat((/* @__PURE__ */ new Date()).getTime()); 6387 return url + (url.indexOf("?") === -1 ? "?" : "&") + timestamp; 6388} 6389function getTransforms(_ref3) { 6390 var rotate2 = _ref3.rotate, scaleX2 = _ref3.scaleX, scaleY2 = _ref3.scaleY, translateX = _ref3.translateX, translateY = _ref3.translateY; 6391 var values = []; 6392 if (isNumber(translateX) && translateX !== 0) { 6393 values.push("translateX(".concat(translateX, "px)")); 6394 } 6395 if (isNumber(translateY) && translateY !== 0) { 6396 values.push("translateY(".concat(translateY, "px)")); 6397 } 6398 if (isNumber(rotate2) && rotate2 !== 0) { 6399 values.push("rotate(".concat(rotate2, "deg)")); 6400 } 6401 if (isNumber(scaleX2) && scaleX2 !== 1) { 6402 values.push("scaleX(".concat(scaleX2, ")")); 6403 } 6404 if (isNumber(scaleY2) && scaleY2 !== 1) { 6405 values.push("scaleY(".concat(scaleY2, ")")); 6406 } 6407 var transform = values.length ? values.join(" ") : "none"; 6408 return { 6409 WebkitTransform: transform, 6410 msTransform: transform, 6411 transform 6412 }; 6413} 6414function getMaxZoomRatio(pointers) { 6415 var pointers2 = _objectSpread22({}, pointers); 6416 var maxRatio = 0; 6417 forEach(pointers, function(pointer, pointerId) { 6418 delete pointers2[pointerId]; 6419 forEach(pointers2, function(pointer2) { 6420 var x1 = Math.abs(pointer.startX - pointer2.startX); 6421 var y1 = Math.abs(pointer.startY - pointer2.startY); 6422 var x2 = Math.abs(pointer.endX - pointer2.endX); 6423 var y22 = Math.abs(pointer.endY - pointer2.endY); 6424 var z1 = Math.sqrt(x1 * x1 + y1 * y1); 6425 var z22 = Math.sqrt(x2 * x2 + y22 * y22); 6426 var ratio = (z22 - z1) / z1; 6427 if (Math.abs(ratio) > Math.abs(maxRatio)) { 6428 maxRatio = ratio; 6429 } 6430 }); 6431 }); 6432 return maxRatio; 6433} 6434function getPointer(_ref23, endOnly) { 6435 var pageX = _ref23.pageX, pageY = _ref23.pageY; 6436 var end = { 6437 endX: pageX, 6438 endY: pageY 6439 }; 6440 return endOnly ? end : _objectSpread22({ 6441 startX: pageX, 6442 startY: pageY 6443 }, end); 6444} 6445function getPointersCenter(pointers) { 6446 var pageX = 0; 6447 var pageY = 0; 6448 var count = 0; 6449 forEach(pointers, function(_ref3) { 6450 var startX = _ref3.startX, startY = _ref3.startY; 6451 pageX += startX; 6452 pageY += startY; 6453 count += 1; 6454 }); 6455 pageX /= count; 6456 pageY /= count; 6457 return { 6458 pageX, 6459 pageY 6460 }; 6461} 6462function getAdjustedSizes(_ref4) { 6463 var aspectRatio = _ref4.aspectRatio, height = _ref4.height, width = _ref4.width; 6464 var type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "contain"; 6465 var isValidWidth = isPositiveNumber(width); 6466 var isValidHeight = isPositiveNumber(height); 6467 if (isValidWidth && isValidHeight) { 6468 var adjustedWidth = height * aspectRatio; 6469 if (type === "contain" && adjustedWidth > width || type === "cover" && adjustedWidth < width) { 6470 height = width / aspectRatio; 6471 } else { 6472 width = height * aspectRatio; 6473 } 6474 } else if (isValidWidth) { 6475 height = width / aspectRatio; 6476 } else if (isValidHeight) { 6477 width = height * aspectRatio; 6478 } 6479 return { 6480 width, 6481 height 6482 }; 6483} 6484function getRotatedSizes(_ref5) { 6485 var width = _ref5.width, height = _ref5.height, degree = _ref5.degree; 6486 degree = Math.abs(degree) % 180; 6487 if (degree === 90) { 6488 return { 6489 width: height, 6490 height: width 6491 }; 6492 } 6493 var arc = degree % 90 * Math.PI / 180; 6494 var sinArc = Math.sin(arc); 6495 var cosArc = Math.cos(arc); 6496 var newWidth = width * cosArc + height * sinArc; 6497 var newHeight = width * sinArc + height * cosArc; 6498 return degree > 90 ? { 6499 width: newHeight, 6500 height: newWidth 6501 } : { 6502 width: newWidth, 6503 height: newHeight 6504 }; 6505} 6506function getSourceCanvas(image, _ref6, _ref7, _ref8) { 6507 var imageAspectRatio = _ref6.aspectRatio, imageNaturalWidth = _ref6.naturalWidth, imageNaturalHeight = _ref6.naturalHeight, _ref6$rotate = _ref6.rotate, rotate2 = _ref6$rotate === void 0 ? 0 : _ref6$rotate, _ref6$scaleX = _ref6.scaleX, scaleX2 = _ref6$scaleX === void 0 ? 1 : _ref6$scaleX, _ref6$scaleY = _ref6.scaleY, scaleY2 = _ref6$scaleY === void 0 ? 1 : _ref6$scaleY; 6508 var aspectRatio = _ref7.aspectRatio, naturalWidth = _ref7.naturalWidth, naturalHeight = _ref7.naturalHeight; 6509 var _ref8$fillColor = _ref8.fillColor, fillColor = _ref8$fillColor === void 0 ? "transparent" : _ref8$fillColor, _ref8$imageSmoothingE = _ref8.imageSmoothingEnabled, imageSmoothingEnabled = _ref8$imageSmoothingE === void 0 ? true : _ref8$imageSmoothingE, _ref8$imageSmoothingQ = _ref8.imageSmoothingQuality, imageSmoothingQuality = _ref8$imageSmoothingQ === void 0 ? "low" : _ref8$imageSmoothingQ, _ref8$maxWidth = _ref8.maxWidth, maxWidth = _ref8$maxWidth === void 0 ? Infinity : _ref8$maxWidth, _ref8$maxHeight = _ref8.maxHeight, maxHeight = _ref8$maxHeight === void 0 ? Infinity : _ref8$maxHeight, _ref8$minWidth = _ref8.minWidth, minWidth = _ref8$minWidth === void 0 ? 0 : _ref8$minWidth, _ref8$minHeight = _ref8.minHeight, minHeight = _ref8$minHeight === void 0 ? 0 : _ref8$minHeight; 6510 var canvas = document.createElement("canvas"); 6511 var context = canvas.getContext("2d"); 6512 var maxSizes = getAdjustedSizes({ 6513 aspectRatio, 6514 width: maxWidth, 6515 height: maxHeight 6516 }); 6517 var minSizes = getAdjustedSizes({ 6518 aspectRatio, 6519 width: minWidth, 6520 height: minHeight 6521 }, "cover"); 6522 var width = Math.min(maxSizes.width, Math.max(minSizes.width, naturalWidth)); 6523 var height = Math.min(maxSizes.height, Math.max(minSizes.height, naturalHeight)); 6524 var destMaxSizes = getAdjustedSizes({ 6525 aspectRatio: imageAspectRatio, 6526 width: maxWidth, 6527 height: maxHeight 6528 }); 6529 var destMinSizes = getAdjustedSizes({ 6530 aspectRatio: imageAspectRatio, 6531 width: minWidth, 6532 height: minHeight 6533 }, "cover"); 6534 var destWidth = Math.min(destMaxSizes.width, Math.max(destMinSizes.width, imageNaturalWidth)); 6535 var destHeight = Math.min(destMaxSizes.height, Math.max(destMinSizes.height, imageNaturalHeight)); 6536 var params = [-destWidth / 2, -destHeight / 2, destWidth, destHeight]; 6537 canvas.width = normalizeDecimalNumber(width); 6538 canvas.height = normalizeDecimalNumber(height); 6539 context.fillStyle = fillColor; 6540 context.fillRect(0, 0, width, height); 6541 context.save(); 6542 context.translate(width / 2, height / 2); 6543 context.rotate(rotate2 * Math.PI / 180); 6544 context.scale(scaleX2, scaleY2); 6545 context.imageSmoothingEnabled = imageSmoothingEnabled; 6546 context.imageSmoothingQuality = imageSmoothingQuality; 6547 context.drawImage.apply(context, [image].concat(_toConsumableArray2(params.map(function(param) { 6548 return Math.floor(normalizeDecimalNumber(param)); 6549 })))); 6550 context.restore(); 6551 return canvas; 6552} 6553var fromCharCode = String.fromCharCode; 6554function getStringFromCharCode(dataView, start, length2) { 6555 var str = ""; 6556 length2 += start; 6557 for (var i3 = start; i3 < length2; i3 += 1) { 6558 str += fromCharCode(dataView.getUint8(i3)); 6559 } 6560 return str; 6561} 6562var REGEXP_DATA_URL_HEAD = /^data:.*,/; 6563function dataURLToArrayBuffer(dataURL) { 6564 var base64 = dataURL.replace(REGEXP_DATA_URL_HEAD, ""); 6565 var binary = atob(base64); 6566 var arrayBuffer = new ArrayBuffer(binary.length); 6567 var uint8 = new Uint8Array(arrayBuffer); 6568 forEach(uint8, function(value, i3) { 6569 uint8[i3] = binary.charCodeAt(i3); 6570 }); 6571 return arrayBuffer; 6572} 6573function arrayBufferToDataURL(arrayBuffer, mimeType) { 6574 var chunks = []; 6575 var chunkSize = 8192; 6576 var uint8 = new Uint8Array(arrayBuffer); 6577 while (uint8.length > 0) { 6578 chunks.push(fromCharCode.apply(null, toArray(uint8.subarray(0, chunkSize)))); 6579 uint8 = uint8.subarray(chunkSize); 6580 } 6581 return "data:".concat(mimeType, ";base64,").concat(btoa(chunks.join(""))); 6582} 6583function resetAndGetOrientation(arrayBuffer) { 6584 var dataView = new DataView(arrayBuffer); 6585 var orientation; 6586 try { 6587 var littleEndian; 6588 var app1Start; 6589 var ifdStart; 6590 if (dataView.getUint8(0) === 255 && dataView.getUint8(1) === 216) { 6591 var length2 = dataView.byteLength; 6592 var offset = 2; 6593 while (offset + 1 < length2) { 6594 if (dataView.getUint8(offset) === 255 && dataView.getUint8(offset + 1) === 225) { 6595 app1Start = offset; 6596 break; 6597 } 6598 offset += 1; 6599 } 6600 } 6601 if (app1Start) { 6602 var exifIDCode = app1Start + 4; 6603 var tiffOffset = app1Start + 10; 6604 if (getStringFromCharCode(dataView, exifIDCode, 4) === "Exif") { 6605 var endianness = dataView.getUint16(tiffOffset); 6606 littleEndian = endianness === 18761; 6607 if (littleEndian || endianness === 19789) { 6608 if (dataView.getUint16(tiffOffset + 2, littleEndian) === 42) { 6609 var firstIFDOffset = dataView.getUint32(tiffOffset + 4, littleEndian); 6610 if (firstIFDOffset >= 8) { 6611 ifdStart = tiffOffset + firstIFDOffset; 6612 } 6613 } 6614 } 6615 } 6616 } 6617 if (ifdStart) { 6618 var _length = dataView.getUint16(ifdStart, littleEndian); 6619 var _offset; 6620 var i3; 6621 for (i3 = 0; i3 < _length; i3 += 1) { 6622 _offset = ifdStart + i3 * 12 + 2; 6623 if (dataView.getUint16(_offset, littleEndian) === 274) { 6624 _offset += 8; 6625 orientation = dataView.getUint16(_offset, littleEndian); 6626 dataView.setUint16(_offset, 1, littleEndian); 6627 break; 6628 } 6629 } 6630 } 6631 } catch (error) { 6632 orientation = 1; 6633 } 6634 return orientation; 6635} 6636function parseOrientation(orientation) { 6637 var rotate2 = 0; 6638 var scaleX2 = 1; 6639 var scaleY2 = 1; 6640 switch (orientation) { 6641 case 2: 6642 scaleX2 = -1; 6643 break; 6644 case 3: 6645 rotate2 = -180; 6646 break; 6647 case 4: 6648 scaleY2 = -1; 6649 break; 6650 case 5: 6651 rotate2 = 90; 6652 scaleY2 = -1; 6653 break; 6654 case 6: 6655 rotate2 = 90; 6656 break; 6657 case 7: 6658 rotate2 = 90; 6659 scaleX2 = -1; 6660 break; 6661 case 8: 6662 rotate2 = -90; 6663 break; 6664 } 6665 return { 6666 rotate: rotate2, 6667 scaleX: scaleX2, 6668 scaleY: scaleY2 6669 }; 6670} 6671var render = { 6672 render: function render2() { 6673 this.initContainer(); 6674 this.initCanvas(); 6675 this.initCropBox(); 6676 this.renderCanvas(); 6677 if (this.cropped) { 6678 this.renderCropBox(); 6679 } 6680 }, 6681 initContainer: function initContainer() { 6682 var element = this.element, options2 = this.options, container = this.container, cropper = this.cropper; 6683 var minWidth = Number(options2.minContainerWidth); 6684 var minHeight = Number(options2.minContainerHeight); 6685 addClass(cropper, CLASS_HIDDEN); 6686 removeClass(element, CLASS_HIDDEN); 6687 var containerData = { 6688 width: Math.max(container.offsetWidth, minWidth >= 0 ? minWidth : MIN_CONTAINER_WIDTH), 6689 height: Math.max(container.offsetHeight, minHeight >= 0 ? minHeight : MIN_CONTAINER_HEIGHT) 6690 }; 6691 this.containerData = containerData; 6692 setStyle(cropper, { 6693 width: containerData.width, 6694 height: containerData.height 6695 }); 6696 addClass(element, CLASS_HIDDEN); 6697 removeClass(cropper, CLASS_HIDDEN); 6698 }, 6699 // Canvas (image wrapper) 6700 initCanvas: function initCanvas() { 6701 var containerData = this.containerData, imageData = this.imageData; 6702 var viewMode = this.options.viewMode; 6703 var rotated = Math.abs(imageData.rotate) % 180 === 90; 6704 var naturalWidth = rotated ? imageData.naturalHeight : imageData.naturalWidth; 6705 var naturalHeight = rotated ? imageData.naturalWidth : imageData.naturalHeight; 6706 var aspectRatio = naturalWidth / naturalHeight; 6707 var canvasWidth = containerData.width; 6708 var canvasHeight = containerData.height; 6709 if (containerData.height * aspectRatio > containerData.width) { 6710 if (viewMode === 3) { 6711 canvasWidth = containerData.height * aspectRatio; 6712 } else { 6713 canvasHeight = containerData.width / aspectRatio; 6714 } 6715 } else if (viewMode === 3) { 6716 canvasHeight = containerData.width / aspectRatio; 6717 } else { 6718 canvasWidth = containerData.height * aspectRatio; 6719 } 6720 var canvasData = { 6721 aspectRatio, 6722 naturalWidth, 6723 naturalHeight, 6724 width: canvasWidth, 6725 height: canvasHeight 6726 }; 6727 this.canvasData = canvasData; 6728 this.limited = viewMode === 1 || viewMode === 2; 6729 this.limitCanvas(true, true); 6730 canvasData.width = Math.min(Math.max(canvasData.width, canvasData.minWidth), canvasData.maxWidth); 6731 canvasData.height = Math.min(Math.max(canvasData.height, canvasData.minHeight), canvasData.maxHeight); 6732 canvasData.left = (containerData.width - canvasData.width) / 2; 6733 canvasData.top = (containerData.height - canvasData.height) / 2; 6734 canvasData.oldLeft = canvasData.left; 6735 canvasData.oldTop = canvasData.top; 6736 this.initialCanvasData = assign2({}, canvasData); 6737 }, 6738 limitCanvas: function limitCanvas(sizeLimited, positionLimited) { 6739 var options2 = this.options, containerData = this.containerData, canvasData = this.canvasData, cropBoxData = this.cropBoxData; 6740 var viewMode = options2.viewMode; 6741 var aspectRatio = canvasData.aspectRatio; 6742 var cropped = this.cropped && cropBoxData; 6743 if (sizeLimited) { 6744 var minCanvasWidth = Number(options2.minCanvasWidth) || 0; 6745 var minCanvasHeight = Number(options2.minCanvasHeight) || 0; 6746 if (viewMode > 1) { 6747 minCanvasWidth = Math.max(minCanvasWidth, containerData.width); 6748 minCanvasHeight = Math.max(minCanvasHeight, containerData.height); 6749 if (viewMode === 3) { 6750 if (minCanvasHeight * aspectRatio > minCanvasWidth) { 6751 minCanvasWidth = minCanvasHeight * aspectRatio; 6752 } else { 6753 minCanvasHeight = minCanvasWidth / aspectRatio; 6754 } 6755 } 6756 } else if (viewMode > 0) { 6757 if (minCanvasWidth) { 6758 minCanvasWidth = Math.max(minCanvasWidth, cropped ? cropBoxData.width : 0); 6759 } else if (minCanvasHeight) { 6760 minCanvasHeight = Math.max(minCanvasHeight, cropped ? cropBoxData.height : 0); 6761 } else if (cropped) { 6762 minCanvasWidth = cropBoxData.width; 6763 minCanvasHeight = cropBoxData.height; 6764 if (minCanvasHeight * aspectRatio > minCanvasWidth) { 6765 minCanvasWidth = minCanvasHeight * aspectRatio; 6766 } else { 6767 minCanvasHeight = minCanvasWidth / aspectRatio; 6768 } 6769 } 6770 } 6771 var _getAdjustedSizes = getAdjustedSizes({ 6772 aspectRatio, 6773 width: minCanvasWidth, 6774 height: minCanvasHeight 6775 }); 6776 minCanvasWidth = _getAdjustedSizes.width; 6777 minCanvasHeight = _getAdjustedSizes.height; 6778 canvasData.minWidth = minCanvasWidth; 6779 canvasData.minHeight = minCanvasHeight; 6780 canvasData.maxWidth = Infinity; 6781 canvasData.maxHeight = Infinity; 6782 } 6783 if (positionLimited) { 6784 if (viewMode > (cropped ? 0 : 1)) { 6785 var newCanvasLeft = containerData.width - canvasData.width; 6786 var newCanvasTop = containerData.height - canvasData.height; 6787 canvasData.minLeft = Math.min(0, newCanvasLeft); 6788 canvasData.minTop = Math.min(0, newCanvasTop); 6789 canvasData.maxLeft = Math.max(0, newCanvasLeft); 6790 canvasData.maxTop = Math.max(0, newCanvasTop); 6791 if (cropped && this.limited) { 6792 canvasData.minLeft = Math.min(cropBoxData.left, cropBoxData.left + (cropBoxData.width - canvasData.width)); 6793 canvasData.minTop = Math.min(cropBoxData.top, cropBoxData.top + (cropBoxData.height - canvasData.height)); 6794 canvasData.maxLeft = cropBoxData.left; 6795 canvasData.maxTop = cropBoxData.top; 6796 if (viewMode === 2) { 6797 if (canvasData.width >= containerData.width) { 6798 canvasData.minLeft = Math.min(0, newCanvasLeft); 6799 canvasData.maxLeft = Math.max(0, newCanvasLeft); 6800 } 6801 if (canvasData.height >= containerData.height) { 6802 canvasData.minTop = Math.min(0, newCanvasTop); 6803 canvasData.maxTop = Math.max(0, newCanvasTop); 6804 } 6805 } 6806 } 6807 } else { 6808 canvasData.minLeft = -canvasData.width; 6809 canvasData.minTop = -canvasData.height; 6810 canvasData.maxLeft = containerData.width; 6811 canvasData.maxTop = containerData.height; 6812 } 6813 } 6814 }, 6815 renderCanvas: function renderCanvas(changed, transformed) { 6816 var canvasData = this.canvasData, imageData = this.imageData; 6817 if (transformed) { 6818 var _getRotatedSizes = getRotatedSizes({ 6819 width: imageData.naturalWidth * Math.abs(imageData.scaleX || 1), 6820 height: imageData.naturalHeight * Math.abs(imageData.scaleY || 1), 6821 degree: imageData.rotate || 0 6822 }), naturalWidth = _getRotatedSizes.width, naturalHeight = _getRotatedSizes.height; 6823 var width = canvasData.width * (naturalWidth / canvasData.naturalWidth); 6824 var height = canvasData.height * (naturalHeight / canvasData.naturalHeight); 6825 canvasData.left -= (width - canvasData.width) / 2; 6826 canvasData.top -= (height - canvasData.height) / 2; 6827 canvasData.width = width; 6828 canvasData.height = height; 6829 canvasData.aspectRatio = naturalWidth / naturalHeight; 6830 canvasData.naturalWidth = naturalWidth; 6831 canvasData.naturalHeight = naturalHeight; 6832 this.limitCanvas(true, false); 6833 } 6834 if (canvasData.width > canvasData.maxWidth || canvasData.width < canvasData.minWidth) { 6835 canvasData.left = canvasData.oldLeft; 6836 } 6837 if (canvasData.height > canvasData.maxHeight || canvasData.height < canvasData.minHeight) { 6838 canvasData.top = canvasData.oldTop; 6839 } 6840 canvasData.width = Math.min(Math.max(canvasData.width, canvasData.minWidth), canvasData.maxWidth); 6841 canvasData.height = Math.min(Math.max(canvasData.height, canvasData.minHeight), canvasData.maxHeight); 6842 this.limitCanvas(false, true); 6843 canvasData.left = Math.min(Math.max(canvasData.left, canvasData.minLeft), canvasData.maxLeft); 6844 canvasData.top = Math.min(Math.max(canvasData.top, canvasData.minTop), canvasData.maxTop); 6845 canvasData.oldLeft = canvasData.left; 6846 canvasData.oldTop = canvasData.top; 6847 setStyle(this.canvas, assign2({ 6848 width: canvasData.width, 6849 height: canvasData.height 6850 }, getTransforms({ 6851 translateX: canvasData.left, 6852 translateY: canvasData.top 6853 }))); 6854 this.renderImage(changed); 6855 if (this.cropped && this.limited) { 6856 this.limitCropBox(true, true); 6857 } 6858 }, 6859 renderImage: function renderImage(changed) { 6860 var canvasData = this.canvasData, imageData = this.imageData; 6861 var width = imageData.naturalWidth * (canvasData.width / canvasData.naturalWidth); 6862 var height = imageData.naturalHeight * (canvasData.height / canvasData.naturalHeight); 6863 assign2(imageData, { 6864 width, 6865 height, 6866 left: (canvasData.width - width) / 2, 6867 top: (canvasData.height - height) / 2 6868 }); 6869 setStyle(this.image, assign2({ 6870 width: imageData.width, 6871 height: imageData.height 6872 }, getTransforms(assign2({ 6873 translateX: imageData.left, 6874 translateY: imageData.top 6875 }, imageData)))); 6876 if (changed) { 6877 this.output(); 6878 } 6879 }, 6880 initCropBox: function initCropBox() { 6881 var options2 = this.options, canvasData = this.canvasData; 6882 var aspectRatio = options2.aspectRatio || options2.initialAspectRatio; 6883 var autoCropArea = Number(options2.autoCropArea) || 0.8; 6884 var cropBoxData = { 6885 width: canvasData.width, 6886 height: canvasData.height 6887 }; 6888 if (aspectRatio) { 6889 if (canvasData.height * aspectRatio > canvasData.width) { 6890 cropBoxData.height = cropBoxData.width / aspectRatio; 6891 } else { 6892 cropBoxData.width = cropBoxData.height * aspectRatio; 6893 } 6894 } 6895 this.cropBoxData = cropBoxData; 6896 this.limitCropBox(true, true); 6897 cropBoxData.width = Math.min(Math.max(cropBoxData.width, cropBoxData.minWidth), cropBoxData.maxWidth); 6898 cropBoxData.height = Math.min(Math.max(cropBoxData.height, cropBoxData.minHeight), cropBoxData.maxHeight); 6899 cropBoxData.width = Math.max(cropBoxData.minWidth, cropBoxData.width * autoCropArea); 6900 cropBoxData.height = Math.max(cropBoxData.minHeight, cropBoxData.height * autoCropArea); 6901 cropBoxData.left = canvasData.left + (canvasData.width - cropBoxData.width) / 2; 6902 cropBoxData.top = canvasData.top + (canvasData.height - cropBoxData.height) / 2; 6903 cropBoxData.oldLeft = cropBoxData.left; 6904 cropBoxData.oldTop = cropBoxData.top; 6905 this.initialCropBoxData = assign2({}, cropBoxData); 6906 }, 6907 limitCropBox: function limitCropBox(sizeLimited, positionLimited) { 6908 var options2 = this.options, containerData = this.containerData, canvasData = this.canvasData, cropBoxData = this.cropBoxData, limited = this.limited; 6909 var aspectRatio = options2.aspectRatio; 6910 if (sizeLimited) { 6911 var minCropBoxWidth = Number(options2.minCropBoxWidth) || 0; 6912 var minCropBoxHeight = Number(options2.minCropBoxHeight) || 0; 6913 var maxCropBoxWidth = limited ? Math.min(containerData.width, canvasData.width, canvasData.width + canvasData.left, containerData.width - canvasData.left) : containerData.width; 6914 var maxCropBoxHeight = limited ? Math.min(containerData.height, canvasData.height, canvasData.height + canvasData.top, containerData.height - canvasData.top) : containerData.height; 6915 minCropBoxWidth = Math.min(minCropBoxWidth, containerData.width); 6916 minCropBoxHeight = Math.min(minCropBoxHeight, containerData.height); 6917 if (aspectRatio) { 6918 if (minCropBoxWidth && minCropBoxHeight) { 6919 if (minCropBoxHeight * aspectRatio > minCropBoxWidth) { 6920 minCropBoxHeight = minCropBoxWidth / aspectRatio; 6921 } else { 6922 minCropBoxWidth = minCropBoxHeight * aspectRatio; 6923 } 6924 } else if (minCropBoxWidth) { 6925 minCropBoxHeight = minCropBoxWidth / aspectRatio; 6926 } else if (minCropBoxHeight) { 6927 minCropBoxWidth = minCropBoxHeight * aspectRatio; 6928 } 6929 if (maxCropBoxHeight * aspectRatio > maxCropBoxWidth) { 6930 maxCropBoxHeight = maxCropBoxWidth / aspectRatio; 6931 } else { 6932 maxCropBoxWidth = maxCropBoxHeight * aspectRatio; 6933 } 6934 } 6935 cropBoxData.minWidth = Math.min(minCropBoxWidth, maxCropBoxWidth); 6936 cropBoxData.minHeight = Math.min(minCropBoxHeight, maxCropBoxHeight); 6937 cropBoxData.maxWidth = maxCropBoxWidth; 6938 cropBoxData.maxHeight = maxCropBoxHeight; 6939 } 6940 if (positionLimited) { 6941 if (limited) { 6942 cropBoxData.minLeft = Math.max(0, canvasData.left); 6943 cropBoxData.minTop = Math.max(0, canvasData.top); 6944 cropBoxData.maxLeft = Math.min(containerData.width, canvasData.left + canvasData.width) - cropBoxData.width; 6945 cropBoxData.maxTop = Math.min(containerData.height, canvasData.top + canvasData.height) - cropBoxData.height; 6946 } else { 6947 cropBoxData.minLeft = 0; 6948 cropBoxData.minTop = 0; 6949 cropBoxData.maxLeft = containerData.width - cropBoxData.width; 6950 cropBoxData.maxTop = containerData.height - cropBoxData.height; 6951 } 6952 } 6953 }, 6954 renderCropBox: function renderCropBox() { 6955 var options2 = this.options, containerData = this.containerData, cropBoxData = this.cropBoxData; 6956 if (cropBoxData.width > cropBoxData.maxWidth || cropBoxData.width < cropBoxData.minWidth) { 6957 cropBoxData.left = cropBoxData.oldLeft; 6958 } 6959 if (cropBoxData.height > cropBoxData.maxHeight || cropBoxData.height < cropBoxData.minHeight) { 6960 cropBoxData.top = cropBoxData.oldTop; 6961 } 6962 cropBoxData.width = Math.min(Math.max(cropBoxData.width, cropBoxData.minWidth), cropBoxData.maxWidth); 6963 cropBoxData.height = Math.min(Math.max(cropBoxData.height, cropBoxData.minHeight), cropBoxData.maxHeight); 6964 this.limitCropBox(false, true); 6965 cropBoxData.left = Math.min(Math.max(cropBoxData.left, cropBoxData.minLeft), cropBoxData.maxLeft); 6966 cropBoxData.top = Math.min(Math.max(cropBoxData.top, cropBoxData.minTop), cropBoxData.maxTop); 6967 cropBoxData.oldLeft = cropBoxData.left; 6968 cropBoxData.oldTop = cropBoxData.top; 6969 if (options2.movable && options2.cropBoxMovable) { 6970 setData(this.face, DATA_ACTION, cropBoxData.width >= containerData.width && cropBoxData.height >= containerData.height ? ACTION_MOVE : ACTION_ALL); 6971 } 6972 setStyle(this.cropBox, assign2({ 6973 width: cropBoxData.width, 6974 height: cropBoxData.height 6975 }, getTransforms({ 6976 translateX: cropBoxData.left, 6977 translateY: cropBoxData.top 6978 }))); 6979 if (this.cropped && this.limited) { 6980 this.limitCanvas(true, true); 6981 } 6982 if (!this.disabled) { 6983 this.output(); 6984 } 6985 }, 6986 output: function output() { 6987 this.preview(); 6988 dispatchEvent(this.element, EVENT_CROP, this.getData()); 6989 } 6990}; 6991var preview = { 6992 initPreview: function initPreview() { 6993 var element = this.element, crossOrigin = this.crossOrigin; 6994 var preview3 = this.options.preview; 6995 var url = crossOrigin ? this.crossOriginUrl : this.url; 6996 var alt = element.alt || "The image to preview"; 6997 var image = document.createElement("img"); 6998 if (crossOrigin) { 6999 image.crossOrigin = crossOrigin; 7000 } 7001 image.src = url; 7002 image.alt = alt; 7003 this.viewBox.appendChild(image); 7004 this.viewBoxImage = image; 7005 if (!preview3) { 7006 return; 7007 } 7008 var previews = preview3; 7009 if (typeof preview3 === "string") { 7010 previews = element.ownerDocument.querySelectorAll(preview3); 7011 } else if (preview3.querySelector) { 7012 previews = [preview3]; 7013 } 7014 this.previews = previews; 7015 forEach(previews, function(el) { 7016 var img = document.createElement("img"); 7017 setData(el, DATA_PREVIEW, { 7018 width: el.offsetWidth, 7019 height: el.offsetHeight, 7020 html: el.innerHTML 7021 }); 7022 if (crossOrigin) { 7023 img.crossOrigin = crossOrigin; 7024 } 7025 img.src = url; 7026 img.alt = alt; 7027 img.style.cssText = 'display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;"'; 7028 el.innerHTML = ""; 7029 el.appendChild(img); 7030 }); 7031 }, 7032 resetPreview: function resetPreview() { 7033 forEach(this.previews, function(element) { 7034 var data = getData(element, DATA_PREVIEW); 7035 setStyle(element, { 7036 width: data.width, 7037 height: data.height 7038 }); 7039 element.innerHTML = data.html; 7040 removeData(element, DATA_PREVIEW); 7041 }); 7042 }, 7043 preview: function preview2() { 7044 var imageData = this.imageData, canvasData = this.canvasData, cropBoxData = this.cropBoxData; 7045 var cropBoxWidth = cropBoxData.width, cropBoxHeight = cropBoxData.height; 7046 var width = imageData.width, height = imageData.height; 7047 var left = cropBoxData.left - canvasData.left - imageData.left; 7048 var top = cropBoxData.top - canvasData.top - imageData.top; 7049 if (!this.cropped || this.disabled) { 7050 return; 7051 } 7052 setStyle(this.viewBoxImage, assign2({ 7053 width, 7054 height 7055 }, getTransforms(assign2({ 7056 translateX: -left, 7057 translateY: -top 7058 }, imageData)))); 7059 forEach(this.previews, function(element) { 7060 var data = getData(element, DATA_PREVIEW); 7061 var originalWidth = data.width; 7062 var originalHeight = data.height; 7063 var newWidth = originalWidth; 7064 var newHeight = originalHeight; 7065 var ratio = 1; 7066 if (cropBoxWidth) { 7067 ratio = originalWidth / cropBoxWidth; 7068 newHeight = cropBoxHeight * ratio; 7069 } 7070 if (cropBoxHeight && newHeight > originalHeight) { 7071 ratio = originalHeight / cropBoxHeight; 7072 newWidth = cropBoxWidth * ratio; 7073 newHeight = originalHeight; 7074 } 7075 setStyle(element, { 7076 width: newWidth, 7077 height: newHeight 7078 }); 7079 setStyle(element.getElementsByTagName("img")[0], assign2({ 7080 width: width * ratio, 7081 height: height * ratio 7082 }, getTransforms(assign2({ 7083 translateX: -left * ratio, 7084 translateY: -top * ratio 7085 }, imageData)))); 7086 }); 7087 } 7088}; 7089var events = { 7090 bind: function bind() { 7091 var element = this.element, options2 = this.options, cropper = this.cropper; 7092 if (isFunction(options2.cropstart)) { 7093 addListener(element, EVENT_CROP_START, options2.cropstart); 7094 } 7095 if (isFunction(options2.cropmove)) { 7096 addListener(element, EVENT_CROP_MOVE, options2.cropmove); 7097 } 7098 if (isFunction(options2.cropend)) { 7099 addListener(element, EVENT_CROP_END, options2.cropend); 7100 } 7101 if (isFunction(options2.crop)) { 7102 addListener(element, EVENT_CROP, options2.crop); 7103 } 7104 if (isFunction(options2.zoom)) { 7105 addListener(element, EVENT_ZOOM, options2.zoom); 7106 } 7107 addListener(cropper, EVENT_POINTER_DOWN, this.onCropStart = this.cropStart.bind(this)); 7108 if (options2.zoomable && options2.zoomOnWheel) { 7109 addListener(cropper, EVENT_WHEEL, this.onWheel = this.wheel.bind(this), { 7110 passive: false, 7111 capture: true 7112 }); 7113 } 7114 if (options2.toggleDragModeOnDblclick) { 7115 addListener(cropper, EVENT_DBLCLICK, this.onDblclick = this.dblclick.bind(this)); 7116 } 7117 addListener(element.ownerDocument, EVENT_POINTER_MOVE, this.onCropMove = this.cropMove.bind(this)); 7118 addListener(element.ownerDocument, EVENT_POINTER_UP, this.onCropEnd = this.cropEnd.bind(this)); 7119 if (options2.responsive) { 7120 addListener(window, EVENT_RESIZE, this.onResize = this.resize.bind(this)); 7121 } 7122 }, 7123 unbind: function unbind() { 7124 var element = this.element, options2 = this.options, cropper = this.cropper; 7125 if (isFunction(options2.cropstart)) { 7126 removeListener(element, EVENT_CROP_START, options2.cropstart); 7127 } 7128 if (isFunction(options2.cropmove)) { 7129 removeListener(element, EVENT_CROP_MOVE, options2.cropmove); 7130 } 7131 if (isFunction(options2.cropend)) { 7132 removeListener(element, EVENT_CROP_END, options2.cropend); 7133 } 7134 if (isFunction(options2.crop)) { 7135 removeListener(element, EVENT_CROP, options2.crop); 7136 } 7137 if (isFunction(options2.zoom)) { 7138 removeListener(element, EVENT_ZOOM, options2.zoom); 7139 } 7140 removeListener(cropper, EVENT_POINTER_DOWN, this.onCropStart); 7141 if (options2.zoomable && options2.zoomOnWheel) { 7142 removeListener(cropper, EVENT_WHEEL, this.onWheel, { 7143 passive: false, 7144 capture: true 7145 }); 7146 } 7147 if (options2.toggleDragModeOnDblclick) { 7148 removeListener(cropper, EVENT_DBLCLICK, this.onDblclick); 7149 } 7150 removeListener(element.ownerDocument, EVENT_POINTER_MOVE, this.onCropMove); 7151 removeListener(element.ownerDocument, EVENT_POINTER_UP, this.onCropEnd); 7152 if (options2.responsive) { 7153 removeListener(window, EVENT_RESIZE, this.onResize); 7154 } 7155 } 7156}; 7157var handlers = { 7158 resize: function resize() { 7159 if (this.disabled) { 7160 return; 7161 } 7162 var options2 = this.options, container = this.container, containerData = this.containerData; 7163 var ratioX = container.offsetWidth / containerData.width; 7164 var ratioY = container.offsetHeight / containerData.height; 7165 var ratio = Math.abs(ratioX - 1) > Math.abs(ratioY - 1) ? ratioX : ratioY; 7166 if (ratio !== 1) { 7167 var canvasData; 7168 var cropBoxData; 7169 if (options2.restore) { 7170 canvasData = this.getCanvasData(); 7171 cropBoxData = this.getCropBoxData(); 7172 } 7173 this.render(); 7174 if (options2.restore) { 7175 this.setCanvasData(forEach(canvasData, function(n2, i3) { 7176 canvasData[i3] = n2 * ratio; 7177 })); 7178 this.setCropBoxData(forEach(cropBoxData, function(n2, i3) { 7179 cropBoxData[i3] = n2 * ratio; 7180 })); 7181 } 7182 } 7183 }, 7184 dblclick: function dblclick() { 7185 if (this.disabled || this.options.dragMode === DRAG_MODE_NONE) { 7186 return; 7187 } 7188 this.setDragMode(hasClass(this.dragBox, CLASS_CROP) ? DRAG_MODE_MOVE : DRAG_MODE_CROP); 7189 }, 7190 wheel: function wheel(event) { 7191 var _this = this; 7192 var ratio = Number(this.options.wheelZoomRatio) || 0.1; 7193 var delta = 1; 7194 if (this.disabled) { 7195 return; 7196 } 7197 event.preventDefault(); 7198 if (this.wheeling) { 7199 return; 7200 } 7201 this.wheeling = true; 7202 setTimeout(function() { 7203 _this.wheeling = false; 7204 }, 50); 7205 if (event.deltaY) { 7206 delta = event.deltaY > 0 ? 1 : -1; 7207 } else if (event.wheelDelta) { 7208 delta = -event.wheelDelta / 120; 7209 } else if (event.detail) { 7210 delta = event.detail > 0 ? 1 : -1; 7211 } 7212 this.zoom(-delta * ratio, event); 7213 }, 7214 cropStart: function cropStart(event) { 7215 var buttons = event.buttons, button = event.button; 7216 if (this.disabled || (event.type === "mousedown" || event.type === "pointerdown" && event.pointerType === "mouse") && // No primary button (Usually the left button) 7217 (isNumber(buttons) && buttons !== 1 || isNumber(button) && button !== 0 || event.ctrlKey)) { 7218 return; 7219 } 7220 var options2 = this.options, pointers = this.pointers; 7221 var action; 7222 if (event.changedTouches) { 7223 forEach(event.changedTouches, function(touch) { 7224 pointers[touch.identifier] = getPointer(touch); 7225 }); 7226 } else { 7227 pointers[event.pointerId || 0] = getPointer(event); 7228 } 7229 if (Object.keys(pointers).length > 1 && options2.zoomable && options2.zoomOnTouch) { 7230 action = ACTION_ZOOM; 7231 } else { 7232 action = getData(event.target, DATA_ACTION); 7233 } 7234 if (!REGEXP_ACTIONS.test(action)) { 7235 return; 7236 } 7237 if (dispatchEvent(this.element, EVENT_CROP_START, { 7238 originalEvent: event, 7239 action 7240 }) === false) { 7241 return; 7242 } 7243 event.preventDefault(); 7244 this.action = action; 7245 this.cropping = false; 7246 if (action === ACTION_CROP) { 7247 this.cropping = true; 7248 addClass(this.dragBox, CLASS_MODAL); 7249 } 7250 }, 7251 cropMove: function cropMove(event) { 7252 var action = this.action; 7253 if (this.disabled || !action) { 7254 return; 7255 } 7256 var pointers = this.pointers; 7257 event.preventDefault(); 7258 if (dispatchEvent(this.element, EVENT_CROP_MOVE, { 7259 originalEvent: event, 7260 action 7261 }) === false) { 7262 return; 7263 } 7264 if (event.changedTouches) { 7265 forEach(event.changedTouches, function(touch) { 7266 assign2(pointers[touch.identifier] || {}, getPointer(touch, true)); 7267 }); 7268 } else { 7269 assign2(pointers[event.pointerId || 0] || {}, getPointer(event, true)); 7270 } 7271 this.change(event); 7272 }, 7273 cropEnd: function cropEnd(event) { 7274 if (this.disabled) { 7275 return; 7276 } 7277 var action = this.action, pointers = this.pointers; 7278 if (event.changedTouches) { 7279 forEach(event.changedTouches, function(touch) { 7280 delete pointers[touch.identifier]; 7281 }); 7282 } else { 7283 delete pointers[event.pointerId || 0]; 7284 } 7285 if (!action) { 7286 return; 7287 } 7288 event.preventDefault(); 7289 if (!Object.keys(pointers).length) { 7290 this.action = ""; 7291 } 7292 if (this.cropping) { 7293 this.cropping = false; 7294 toggleClass(this.dragBox, CLASS_MODAL, this.cropped && this.options.modal); 7295 } 7296 dispatchEvent(this.element, EVENT_CROP_END, { 7297 originalEvent: event, 7298 action 7299 }); 7300 } 7301}; 7302var change = { 7303 change: function change2(event) { 7304 var options2 = this.options, canvasData = this.canvasData, containerData = this.containerData, cropBoxData = this.cropBoxData, pointers = this.pointers; 7305 var action = this.action; 7306 var aspectRatio = options2.aspectRatio; 7307 var left = cropBoxData.left, top = cropBoxData.top, width = cropBoxData.width, height = cropBoxData.height; 7308 var right = left + width; 7309 var bottom = top + height; 7310 var minLeft = 0; 7311 var minTop = 0; 7312 var maxWidth = containerData.width; 7313 var maxHeight = containerData.height; 7314 var renderable = true; 7315 var offset; 7316 if (!aspectRatio && event.shiftKey) { 7317 aspectRatio = width && height ? width / height : 1; 7318 } 7319 if (this.limited) { 7320 minLeft = cropBoxData.minLeft; 7321 minTop = cropBoxData.minTop; 7322 maxWidth = minLeft + Math.min(containerData.width, canvasData.width, canvasData.left + canvasData.width); 7323 maxHeight = minTop + Math.min(containerData.height, canvasData.height, canvasData.top + canvasData.height); 7324 } 7325 var pointer = pointers[Object.keys(pointers)[0]]; 7326 var range = { 7327 x: pointer.endX - pointer.startX, 7328 y: pointer.endY - pointer.startY 7329 }; 7330 var check = function check2(side) { 7331 switch (side) { 7332 case ACTION_EAST: 7333 if (right + range.x > maxWidth) { 7334 range.x = maxWidth - right; 7335 } 7336 break; 7337 case ACTION_WEST: 7338 if (left + range.x < minLeft) { 7339 range.x = minLeft - left; 7340 } 7341 break; 7342 case ACTION_NORTH: 7343 if (top + range.y < minTop) { 7344 range.y = minTop - top; 7345 } 7346 break; 7347 case ACTION_SOUTH: 7348 if (bottom + range.y > maxHeight) { 7349 range.y = maxHeight - bottom; 7350 } 7351 break; 7352 } 7353 }; 7354 switch (action) { 7355 case ACTION_ALL: 7356 left += range.x; 7357 top += range.y; 7358 break; 7359 case ACTION_EAST: 7360 if (range.x >= 0 && (right >= maxWidth || aspectRatio && (top <= minTop || bottom >= maxHeight))) { 7361 renderable = false; 7362 break; 7363 } 7364 check(ACTION_EAST); 7365 width += range.x; 7366 if (width < 0) { 7367 action = ACTION_WEST; 7368 width = -width; 7369 left -= width; 7370 } 7371 if (aspectRatio) { 7372 height = width / aspectRatio; 7373 top += (cropBoxData.height - height) / 2; 7374 } 7375 break; 7376 case ACTION_NORTH: 7377 if (range.y <= 0 && (top <= minTop || aspectRatio && (left <= minLeft || right >= maxWidth))) { 7378 renderable = false; 7379 break; 7380 } 7381 check(ACTION_NORTH); 7382 height -= range.y; 7383 top += range.y; 7384 if (height < 0) { 7385 action = ACTION_SOUTH; 7386 height = -height; 7387 top -= height; 7388 } 7389 if (aspectRatio) { 7390 width = height * aspectRatio; 7391 left += (cropBoxData.width - width) / 2; 7392 } 7393 break; 7394 case ACTION_WEST: 7395 if (range.x <= 0 && (left <= minLeft || aspectRatio && (top <= minTop || bottom >= maxHeight))) { 7396 renderable = false; 7397 break; 7398 } 7399 check(ACTION_WEST); 7400 width -= range.x; 7401 left += range.x; 7402 if (width < 0) { 7403 action = ACTION_EAST; 7404 width = -width; 7405 left -= width; 7406 } 7407 if (aspectRatio) { 7408 height = width / aspectRatio; 7409 top += (cropBoxData.height - height) / 2; 7410 } 7411 break; 7412 case ACTION_SOUTH: 7413 if (range.y >= 0 && (bottom >= maxHeight || aspectRatio && (left <= minLeft || right >= maxWidth))) { 7414 renderable = false; 7415 break; 7416 } 7417 check(ACTION_SOUTH); 7418 height += range.y; 7419 if (height < 0) { 7420 action = ACTION_NORTH; 7421 height = -height; 7422 top -= height; 7423 } 7424 if (aspectRatio) { 7425 width = height * aspectRatio; 7426 left += (cropBoxData.width - width) / 2; 7427 } 7428 break; 7429 case ACTION_NORTH_EAST: 7430 if (aspectRatio) { 7431 if (range.y <= 0 && (top <= minTop || right >= maxWidth)) { 7432 renderable = false; 7433 break; 7434 } 7435 check(ACTION_NORTH); 7436 height -= range.y; 7437 top += range.y; 7438 width = height * aspectRatio; 7439 } else { 7440 check(ACTION_NORTH); 7441 check(ACTION_EAST); 7442 if (range.x >= 0) { 7443 if (right < maxWidth) { 7444 width += range.x; 7445 } else if (range.y <= 0 && top <= minTop) { 7446 renderable = false; 7447 } 7448 } else { 7449 width += range.x; 7450 } 7451 if (range.y <= 0) { 7452 if (top > minTop) { 7453 height -= range.y; 7454 top += range.y; 7455 } 7456 } else { 7457 height -= range.y; 7458 top += range.y; 7459 } 7460 } 7461 if (width < 0 && height < 0) { 7462 action = ACTION_SOUTH_WEST; 7463 height = -height; 7464 width = -width; 7465 top -= height; 7466 left -= width; 7467 } else if (width < 0) { 7468 action = ACTION_NORTH_WEST; 7469 width = -width; 7470 left -= width; 7471 } else if (height < 0) { 7472 action = ACTION_SOUTH_EAST; 7473 height = -height; 7474 top -= height; 7475 } 7476 break; 7477 case ACTION_NORTH_WEST: 7478 if (aspectRatio) { 7479 if (range.y <= 0 && (top <= minTop || left <= minLeft)) { 7480 renderable = false; 7481 break; 7482 } 7483 check(ACTION_NORTH); 7484 height -= range.y; 7485 top += range.y; 7486 width = height * aspectRatio; 7487 left += cropBoxData.width - width; 7488 } else { 7489 check(ACTION_NORTH); 7490 check(ACTION_WEST); 7491 if (range.x <= 0) { 7492 if (left > minLeft) { 7493 width -= range.x; 7494 left += range.x; 7495 } else if (range.y <= 0 && top <= minTop) { 7496 renderable = false; 7497 } 7498 } else { 7499 width -= range.x; 7500 left += range.x; 7501 } 7502 if (range.y <= 0) { 7503 if (top > minTop) { 7504 height -= range.y; 7505 top += range.y; 7506 } 7507 } else { 7508 height -= range.y; 7509 top += range.y; 7510 } 7511 } 7512 if (width < 0 && height < 0) { 7513 action = ACTION_SOUTH_EAST; 7514 height = -height; 7515 width = -width; 7516 top -= height; 7517 left -= width; 7518 } else if (width < 0) { 7519 action = ACTION_NORTH_EAST; 7520 width = -width; 7521 left -= width; 7522 } else if (height < 0) { 7523 action = ACTION_SOUTH_WEST; 7524 height = -height; 7525 top -= height; 7526 } 7527 break; 7528 case ACTION_SOUTH_WEST: 7529 if (aspectRatio) { 7530 if (range.x <= 0 && (left <= minLeft || bottom >= maxHeight)) { 7531 renderable = false; 7532 break; 7533 } 7534 check(ACTION_WEST); 7535 width -= range.x; 7536 left += range.x; 7537 height = width / aspectRatio; 7538 } else { 7539 check(ACTION_SOUTH); 7540 check(ACTION_WEST); 7541 if (range.x <= 0) { 7542 if (left > minLeft) { 7543 width -= range.x; 7544 left += range.x; 7545 } else if (range.y >= 0 && bottom >= maxHeight) { 7546 renderable = false; 7547 } 7548 } else { 7549 width -= range.x; 7550 left += range.x; 7551 } 7552 if (range.y >= 0) { 7553 if (bottom < maxHeight) { 7554 height += range.y; 7555 } 7556 } else { 7557 height += range.y; 7558 } 7559 } 7560 if (width < 0 && height < 0) { 7561 action = ACTION_NORTH_EAST; 7562 height = -height; 7563 width = -width; 7564 top -= height; 7565 left -= width; 7566 } else if (width < 0) { 7567 action = ACTION_SOUTH_EAST; 7568 width = -width; 7569 left -= width; 7570 } else if (height < 0) { 7571 action = ACTION_NORTH_WEST; 7572 height = -height; 7573 top -= height; 7574 } 7575 break; 7576 case ACTION_SOUTH_EAST: 7577 if (aspectRatio) { 7578 if (range.x >= 0 && (right >= maxWidth || bottom >= maxHeight)) { 7579 renderable = false; 7580 break; 7581 } 7582 check(ACTION_EAST); 7583 width += range.x; 7584 height = width / aspectRatio; 7585 } else { 7586 check(ACTION_SOUTH); 7587 check(ACTION_EAST); 7588 if (range.x >= 0) { 7589 if (right < maxWidth) { 7590 width += range.x; 7591 } else if (range.y >= 0 && bottom >= maxHeight) { 7592 renderable = false; 7593 } 7594 } else { 7595 width += range.x; 7596 } 7597 if (range.y >= 0) { 7598 if (bottom < maxHeight) { 7599 height += range.y; 7600 } 7601 } else { 7602 height += range.y; 7603 } 7604 } 7605 if (width < 0 && height < 0) { 7606 action = ACTION_NORTH_WEST; 7607 height = -height; 7608 width = -width; 7609 top -= height; 7610 left -= width; 7611 } else if (width < 0) { 7612 action = ACTION_SOUTH_WEST; 7613 width = -width; 7614 left -= width; 7615 } else if (height < 0) { 7616 action = ACTION_NORTH_EAST; 7617 height = -height; 7618 top -= height; 7619 } 7620 break; 7621 case ACTION_MOVE: 7622 this.move(range.x, range.y); 7623 renderable = false; 7624 break; 7625 case ACTION_ZOOM: 7626 this.zoom(getMaxZoomRatio(pointers), event); 7627 renderable = false; 7628 break; 7629 case ACTION_CROP: 7630 if (!range.x || !range.y) { 7631 renderable = false; 7632 break; 7633 } 7634 offset = getOffset(this.cropper); 7635 left = pointer.startX - offset.left; 7636 top = pointer.startY - offset.top; 7637 width = cropBoxData.minWidth; 7638 height = cropBoxData.minHeight; 7639 if (range.x > 0) { 7640 action = range.y > 0 ? ACTION_SOUTH_EAST : ACTION_NORTH_EAST; 7641 } else if (range.x < 0) { 7642 left -= width; 7643 action = range.y > 0 ? ACTION_SOUTH_WEST : ACTION_NORTH_WEST; 7644 } 7645 if (range.y < 0) { 7646 top -= height; 7647 } 7648 if (!this.cropped) { 7649 removeClass(this.cropBox, CLASS_HIDDEN); 7650 this.cropped = true; 7651 if (this.limited) { 7652 this.limitCropBox(true, true); 7653 } 7654 } 7655 break; 7656 } 7657 if (renderable) { 7658 cropBoxData.width = width; 7659 cropBoxData.height = height; 7660 cropBoxData.left = left; 7661 cropBoxData.top = top; 7662 this.action = action; 7663 this.renderCropBox(); 7664 } 7665 forEach(pointers, function(p3) { 7666 p3.startX = p3.endX; 7667 p3.startY = p3.endY; 7668 }); 7669 } 7670}; 7671var methods = { 7672 // Show the crop box manually 7673 crop: function crop() { 7674 if (this.ready && !this.cropped && !this.disabled) { 7675 this.cropped = true; 7676 this.limitCropBox(true, true); 7677 if (this.options.modal) { 7678 addClass(this.dragBox, CLASS_MODAL); 7679 } 7680 removeClass(this.cropBox, CLASS_HIDDEN); 7681 this.setCropBoxData(this.initialCropBoxData); 7682 } 7683 return this; 7684 }, 7685 // Reset the image and crop box to their initial states 7686 reset: function reset() { 7687 if (this.ready && !this.disabled) { 7688 this.imageData = assign2({}, this.initialImageData); 7689 this.canvasData = assign2({}, this.initialCanvasData); 7690 this.cropBoxData = assign2({}, this.initialCropBoxData); 7691 this.renderCanvas(); 7692 if (this.cropped) { 7693 this.renderCropBox(); 7694 } 7695 } 7696 return this; 7697 }, 7698 // Clear the crop box 7699 clear: function clear() { 7700 if (this.cropped && !this.disabled) { 7701 assign2(this.cropBoxData, { 7702 left: 0, 7703 top: 0, 7704 width: 0, 7705 height: 0 7706 }); 7707 this.cropped = false; 7708 this.renderCropBox(); 7709 this.limitCanvas(true, true); 7710 this.renderCanvas(); 7711 removeClass(this.dragBox, CLASS_MODAL); 7712 addClass(this.cropBox, CLASS_HIDDEN); 7713 } 7714 return this; 7715 }, 7716 /** 7717 * Replace the image's src and rebuild the cropper 7718 * @param {string} url - The new URL. 7719 * @param {boolean} [hasSameSize] - Indicate if the new image has the same size as the old one. 7720 * @returns {Cropper} this 7721 */ 7722 replace: function replace2(url) { 7723 var hasSameSize = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false; 7724 if (!this.disabled && url) { 7725 if (this.isImg) { 7726 this.element.src = url; 7727 } 7728 if (hasSameSize) { 7729 this.url = url; 7730 this.image.src = url; 7731 if (this.ready) { 7732 this.viewBoxImage.src = url; 7733 forEach(this.previews, function(element) { 7734 element.getElementsByTagName("img")[0].src = url; 7735 }); 7736 } 7737 } else { 7738 if (this.isImg) { 7739 this.replaced = true; 7740 } 7741 this.options.data = null; 7742 this.uncreate(); 7743 this.load(url); 7744 } 7745 } 7746 return this; 7747 }, 7748 // Enable (unfreeze) the cropper 7749 enable: function enable() { 7750 if (this.ready && this.disabled) { 7751 this.disabled = false; 7752 removeClass(this.cropper, CLASS_DISABLED); 7753 } 7754 return this; 7755 }, 7756 // Disable (freeze) the cropper 7757 disable: function disable() { 7758 if (this.ready && !this.disabled) { 7759 this.disabled = true; 7760 addClass(this.cropper, CLASS_DISABLED); 7761 } 7762 return this; 7763 }, 7764 /** 7765 * Destroy the cropper and remove the instance from the image 7766 * @returns {Cropper} this 7767 */ 7768 destroy: function destroy() { 7769 var element = this.element; 7770 if (!element[NAMESPACE]) { 7771 return this; 7772 } 7773 element[NAMESPACE] = void 0; 7774 if (this.isImg && this.replaced) { 7775 element.src = this.originalUrl; 7776 } 7777 this.uncreate(); 7778 return this; 7779 }, 7780 /** 7781 * Move the canvas with relative offsets 7782 * @param {number} offsetX - The relative offset distance on the x-axis. 7783 * @param {number} [offsetY=offsetX] - The relative offset distance on the y-axis. 7784 * @returns {Cropper} this 7785 */ 7786 move: function move(offsetX) { 7787 var offsetY = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : offsetX; 7788 var _this$canvasData = this.canvasData, left = _this$canvasData.left, top = _this$canvasData.top; 7789 return this.moveTo(isUndefined(offsetX) ? offsetX : left + Number(offsetX), isUndefined(offsetY) ? offsetY : top + Number(offsetY)); 7790 }, 7791 /** 7792 * Move the canvas to an absolute point 7793 * @param {number} x - The x-axis coordinate. 7794 * @param {number} [y=x] - The y-axis coordinate. 7795 * @returns {Cropper} this 7796 */ 7797 moveTo: function moveTo(x2) { 7798 var y4 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : x2; 7799 var canvasData = this.canvasData; 7800 var changed = false; 7801 x2 = Number(x2); 7802 y4 = Number(y4); 7803 if (this.ready && !this.disabled && this.options.movable) { 7804 if (isNumber(x2)) { 7805 canvasData.left = x2; 7806 changed = true; 7807 } 7808 if (isNumber(y4)) { 7809 canvasData.top = y4; 7810 changed = true; 7811 } 7812 if (changed) { 7813 this.renderCanvas(true); 7814 } 7815 } 7816 return this; 7817 }, 7818 /** 7819 * Zoom the canvas with a relative ratio 7820 * @param {number} ratio - The target ratio. 7821 * @param {Event} _originalEvent - The original event if any. 7822 * @returns {Cropper} this 7823 */ 7824 zoom: function zoom(ratio, _originalEvent) { 7825 var canvasData = this.canvasData; 7826 ratio = Number(ratio); 7827 if (ratio < 0) { 7828 ratio = 1 / (1 - ratio); 7829 } else { 7830 ratio = 1 + ratio; 7831 } 7832 return this.zoomTo(canvasData.width * ratio / canvasData.naturalWidth, null, _originalEvent); 7833 }, 7834 /** 7835 * Zoom the canvas to an absolute ratio 7836 * @param {number} ratio - The target ratio. 7837 * @param {Object} pivot - The zoom pivot point coordinate. 7838 * @param {Event} _originalEvent - The original event if any. 7839 * @returns {Cropper} this 7840 */ 7841 zoomTo: function zoomTo(ratio, pivot, _originalEvent) { 7842 var options2 = this.options, canvasData = this.canvasData; 7843 var width = canvasData.width, height = canvasData.height, naturalWidth = canvasData.naturalWidth, naturalHeight = canvasData.naturalHeight; 7844 ratio = Number(ratio); 7845 if (ratio >= 0 && this.ready && !this.disabled && options2.zoomable) { 7846 var newWidth = naturalWidth * ratio; 7847 var newHeight = naturalHeight * ratio; 7848 if (dispatchEvent(this.element, EVENT_ZOOM, { 7849 ratio, 7850 oldRatio: width / naturalWidth, 7851 originalEvent: _originalEvent 7852 }) === false) { 7853 return this; 7854 } 7855 if (_originalEvent) { 7856 var pointers = this.pointers; 7857 var offset = getOffset(this.cropper); 7858 var center2 = pointers && Object.keys(pointers).length ? getPointersCenter(pointers) : { 7859 pageX: _originalEvent.pageX, 7860 pageY: _originalEvent.pageY 7861 }; 7862 canvasData.left -= (newWidth - width) * ((center2.pageX - offset.left - canvasData.left) / width); 7863 canvasData.top -= (newHeight - height) * ((center2.pageY - offset.top - canvasData.top) / height); 7864 } else if (isPlainObject(pivot) && isNumber(pivot.x) && isNumber(pivot.y)) { 7865 canvasData.left -= (newWidth - width) * ((pivot.x - canvasData.left) / width); 7866 canvasData.top -= (newHeight - height) * ((pivot.y - canvasData.top) / height); 7867 } else { 7868 canvasData.left -= (newWidth - width) / 2; 7869 canvasData.top -= (newHeight - height) / 2; 7870 } 7871 canvasData.width = newWidth; 7872 canvasData.height = newHeight; 7873 this.renderCanvas(true); 7874 } 7875 return this; 7876 }, 7877 /** 7878 * Rotate the canvas with a relative degree 7879 * @param {number} degree - The rotate degree. 7880 * @returns {Cropper} this 7881 */ 7882 rotate: function rotate(degree) { 7883 return this.rotateTo((this.imageData.rotate || 0) + Number(degree)); 7884 }, 7885 /** 7886 * Rotate the canvas to an absolute degree 7887 * @param {number} degree - The rotate degree. 7888 * @returns {Cropper} this 7889 */ 7890 rotateTo: function rotateTo(degree) { 7891 degree = Number(degree); 7892 if (isNumber(degree) && this.ready && !this.disabled && this.options.rotatable) { 7893 this.imageData.rotate = degree % 360; 7894 this.renderCanvas(true, true); 7895 } 7896 return this; 7897 }, 7898 /** 7899 * Scale the image on the x-axis. 7900 * @param {number} scaleX - The scale ratio on the x-axis. 7901 * @returns {Cropper} this 7902 */ 7903 scaleX: function scaleX(_scaleX) { 7904 var scaleY2 = this.imageData.scaleY; 7905 return this.scale(_scaleX, isNumber(scaleY2) ? scaleY2 : 1); 7906 }, 7907 /** 7908 * Scale the image on the y-axis. 7909 * @param {number} scaleY - The scale ratio on the y-axis. 7910 * @returns {Cropper} this 7911 */ 7912 scaleY: function scaleY(_scaleY) { 7913 var scaleX2 = this.imageData.scaleX; 7914 return this.scale(isNumber(scaleX2) ? scaleX2 : 1, _scaleY); 7915 }, 7916 /** 7917 * Scale the image 7918 * @param {number} scaleX - The scale ratio on the x-axis. 7919 * @param {number} [scaleY=scaleX] - The scale ratio on the y-axis. 7920 * @returns {Cropper} this 7921 */ 7922 scale: function scale(scaleX2) { 7923 var scaleY2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : scaleX2; 7924 var imageData = this.imageData; 7925 var transformed = false; 7926 scaleX2 = Number(scaleX2); 7927 scaleY2 = Number(scaleY2); 7928 if (this.ready && !this.disabled && this.options.scalable) { 7929 if (isNumber(scaleX2)) { 7930 imageData.scaleX = scaleX2; 7931 transformed = true; 7932 } 7933 if (isNumber(scaleY2)) { 7934 imageData.scaleY = scaleY2; 7935 transformed = true; 7936 } 7937 if (transformed) { 7938 this.renderCanvas(true, true); 7939 } 7940 } 7941 return this; 7942 }, 7943 /** 7944 * Get the cropped area position and size data (base on the original image) 7945 * @param {boolean} [rounded=false] - Indicate if round the data values or not. 7946 * @returns {Object} The result cropped data. 7947 */ 7948 getData: function getData2() { 7949 var rounded = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false; 7950 var options2 = this.options, imageData = this.imageData, canvasData = this.canvasData, cropBoxData = this.cropBoxData; 7951 var data; 7952 if (this.ready && this.cropped) { 7953 data = { 7954 x: cropBoxData.left - canvasData.left, 7955 y: cropBoxData.top - canvasData.top, 7956 width: cropBoxData.width, 7957 height: cropBoxData.height 7958 }; 7959 var ratio = imageData.width / imageData.naturalWidth; 7960 forEach(data, function(n2, i3) { 7961 data[i3] = n2 / ratio; 7962 }); 7963 if (rounded) { 7964 var bottom = Math.round(data.y + data.height); 7965 var right = Math.round(data.x + data.width); 7966 data.x = Math.round(data.x); 7967 data.y = Math.round(data.y); 7968 data.width = right - data.x; 7969 data.height = bottom - data.y; 7970 } 7971 } else { 7972 data = { 7973 x: 0, 7974 y: 0, 7975 width: 0, 7976 height: 0 7977 }; 7978 } 7979 if (options2.rotatable) { 7980 data.rotate = imageData.rotate || 0; 7981 } 7982 if (options2.scalable) { 7983 data.scaleX = imageData.scaleX || 1; 7984 data.scaleY = imageData.scaleY || 1; 7985 } 7986 return data; 7987 }, 7988 /** 7989 * Set the cropped area position and size with new data 7990 * @param {Object} data - The new data. 7991 * @returns {Cropper} this 7992 */ 7993 setData: function setData2(data) { 7994 var options2 = this.options, imageData = this.imageData, canvasData = this.canvasData; 7995 var cropBoxData = {}; 7996 if (this.ready && !this.disabled && isPlainObject(data)) { 7997 var transformed = false; 7998 if (options2.rotatable) { 7999 if (isNumber(data.rotate) && data.rotate !== imageData.rotate) { 8000 imageData.rotate = data.rotate; 8001 transformed = true; 8002 } 8003 } 8004 if (options2.scalable) { 8005 if (isNumber(data.scaleX) && data.scaleX !== imageData.scaleX) { 8006 imageData.scaleX = data.scaleX; 8007 transformed = true; 8008 } 8009 if (isNumber(data.scaleY) && data.scaleY !== imageData.scaleY) { 8010 imageData.scaleY = data.scaleY; 8011 transformed = true; 8012 } 8013 } 8014 if (transformed) { 8015 this.renderCanvas(true, true); 8016 } 8017 var ratio = imageData.width / imageData.naturalWidth; 8018 if (isNumber(data.x)) { 8019 cropBoxData.left = data.x * ratio + canvasData.left; 8020 } 8021 if (isNumber(data.y)) { 8022 cropBoxData.top = data.y * ratio + canvasData.top; 8023 } 8024 if (isNumber(data.width)) { 8025 cropBoxData.width = data.width * ratio; 8026 } 8027 if (isNumber(data.height)) { 8028 cropBoxData.height = data.height * ratio; 8029 } 8030 this.setCropBoxData(cropBoxData); 8031 } 8032 return this; 8033 }, 8034 /** 8035 * Get the container size data. 8036 * @returns {Object} The result container data. 8037 */ 8038 getContainerData: function getContainerData() { 8039 return this.ready ? assign2({}, this.containerData) : {}; 8040 }, 8041 /** 8042 * Get the image position and size data. 8043 * @returns {Object} The result image data. 8044 */ 8045 getImageData: function getImageData() { 8046 return this.sized ? assign2({}, this.imageData) : {}; 8047 }, 8048 /** 8049 * Get the canvas position and size data. 8050 * @returns {Object} The result canvas data. 8051 */ 8052 getCanvasData: function getCanvasData() { 8053 var canvasData = this.canvasData; 8054 var data = {}; 8055 if (this.ready) { 8056 forEach(["left", "top", "width", "height", "naturalWidth", "naturalHeight"], function(n2) { 8057 data[n2] = canvasData[n2]; 8058 }); 8059 } 8060 return data; 8061 }, 8062 /** 8063 * Set the canvas position and size with new data. 8064 * @param {Object} data - The new canvas data. 8065 * @returns {Cropper} this 8066 */ 8067 setCanvasData: function setCanvasData(data) { 8068 var canvasData = this.canvasData; 8069 var aspectRatio = canvasData.aspectRatio; 8070 if (this.ready && !this.disabled && isPlainObject(data)) { 8071 if (isNumber(data.left)) { 8072 canvasData.left = data.left; 8073 } 8074 if (isNumber(data.top)) { 8075 canvasData.top = data.top; 8076 } 8077 if (isNumber(data.width)) { 8078 canvasData.width = data.width; 8079 canvasData.height = data.width / aspectRatio; 8080 } else if (isNumber(data.height)) { 8081 canvasData.height = data.height; 8082 canvasData.width = data.height * aspectRatio; 8083 } 8084 this.renderCanvas(true); 8085 } 8086 return this; 8087 }, 8088 /** 8089 * Get the crop box position and size data. 8090 * @returns {Object} The result crop box data. 8091 */ 8092 getCropBoxData: function getCropBoxData() { 8093 var cropBoxData = this.cropBoxData; 8094 var data; 8095 if (this.ready && this.cropped) { 8096 data = { 8097 left: cropBoxData.left, 8098 top: cropBoxData.top, 8099 width: cropBoxData.width, 8100 height: cropBoxData.height 8101 }; 8102 } 8103 return data || {}; 8104 }, 8105 /** 8106 * Set the crop box position and size with new data. 8107 * @param {Object} data - The new crop box data. 8108 * @returns {Cropper} this 8109 */ 8110 setCropBoxData: function setCropBoxData(data) { 8111 var cropBoxData = this.cropBoxData; 8112 var aspectRatio = this.options.aspectRatio; 8113 var widthChanged; 8114 var heightChanged; 8115 if (this.ready && this.cropped && !this.disabled && isPlainObject(data)) { 8116 if (isNumber(data.left)) { 8117 cropBoxData.left = data.left; 8118 } 8119 if (isNumber(data.top)) { 8120 cropBoxData.top = data.top; 8121 } 8122 if (isNumber(data.width) && data.width !== cropBoxData.width) { 8123 widthChanged = true; 8124 cropBoxData.width = data.width; 8125 } 8126 if (isNumber(data.height) && data.height !== cropBoxData.height) { 8127 heightChanged = true; 8128 cropBoxData.height = data.height; 8129 } 8130 if (aspectRatio) { 8131 if (widthChanged) { 8132 cropBoxData.height = cropBoxData.width / aspectRatio; 8133 } else if (heightChanged) { 8134 cropBoxData.width = cropBoxData.height * aspectRatio; 8135 } 8136 } 8137 this.renderCropBox(); 8138 } 8139 return this; 8140 }, 8141 /** 8142 * Get a canvas drawn the cropped image. 8143 * @param {Object} [options={}] - The config options. 8144 * @returns {HTMLCanvasElement} - The result canvas. 8145 */ 8146 getCroppedCanvas: function getCroppedCanvas() { 8147 var options2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; 8148 if (!this.ready || !window.HTMLCanvasElement) { 8149 return null; 8150 } 8151 var canvasData = this.canvasData; 8152 var source = getSourceCanvas(this.image, this.imageData, canvasData, options2); 8153 if (!this.cropped) { 8154 return source; 8155 } 8156 var _this$getData = this.getData(options2.rounded), initialX = _this$getData.x, initialY = _this$getData.y, initialWidth = _this$getData.width, initialHeight = _this$getData.height; 8157 var ratio = source.width / Math.floor(canvasData.naturalWidth); 8158 if (ratio !== 1) { 8159 initialX *= ratio; 8160 initialY *= ratio; 8161 initialWidth *= ratio; 8162 initialHeight *= ratio; 8163 } 8164 var aspectRatio = initialWidth / initialHeight; 8165 var maxSizes = getAdjustedSizes({ 8166 aspectRatio, 8167 width: options2.maxWidth || Infinity, 8168 height: options2.maxHeight || Infinity 8169 }); 8170 var minSizes = getAdjustedSizes({ 8171 aspectRatio, 8172 width: options2.minWidth || 0, 8173 height: options2.minHeight || 0 8174 }, "cover"); 8175 var _getAdjustedSizes = getAdjustedSizes({ 8176 aspectRatio, 8177 width: options2.width || (ratio !== 1 ? source.width : initialWidth), 8178 height: options2.height || (ratio !== 1 ? source.height : initialHeight) 8179 }), width = _getAdjustedSizes.width, height = _getAdjustedSizes.height; 8180 width = Math.min(maxSizes.width, Math.max(minSizes.width, width)); 8181 height = Math.min(maxSizes.height, Math.max(minSizes.height, height)); 8182 var canvas = document.createElement("canvas"); 8183 var context = canvas.getContext("2d"); 8184 canvas.width = normalizeDecimalNumber(width); 8185 canvas.height = normalizeDecimalNumber(height); 8186 context.fillStyle = options2.fillColor || "transparent"; 8187 context.fillRect(0, 0, width, height); 8188 var _options$imageSmoothi = options2.imageSmoothingEnabled, imageSmoothingEnabled = _options$imageSmoothi === void 0 ? true : _options$imageSmoothi, imageSmoothingQuality = options2.imageSmoothingQuality; 8189 context.imageSmoothingEnabled = imageSmoothingEnabled; 8190 if (imageSmoothingQuality) { 8191 context.imageSmoothingQuality = imageSmoothingQuality; 8192 } 8193 var sourceWidth = source.width; 8194 var sourceHeight = source.height; 8195 var srcX = initialX; 8196 var srcY = initialY; 8197 var srcWidth; 8198 var srcHeight; 8199 var dstX; 8200 var dstY; 8201 var dstWidth; 8202 var dstHeight; 8203 if (srcX <= -initialWidth || srcX > sourceWidth) { 8204 srcX = 0; 8205 srcWidth = 0; 8206 dstX = 0; 8207 dstWidth = 0; 8208 } else if (srcX <= 0) { 8209 dstX = -srcX; 8210 srcX = 0; 8211 srcWidth = Math.min(sourceWidth, initialWidth + srcX); 8212 dstWidth = srcWidth; 8213 } else if (srcX <= sourceWidth) { 8214 dstX = 0; 8215 srcWidth = Math.min(initialWidth, sourceWidth - srcX); 8216 dstWidth = srcWidth; 8217 } 8218 if (srcWidth <= 0 || srcY <= -initialHeight || srcY > sourceHeight) { 8219 srcY = 0; 8220 srcHeight = 0; 8221 dstY = 0; 8222 dstHeight = 0; 8223 } else if (srcY <= 0) { 8224 dstY = -srcY; 8225 srcY = 0; 8226 srcHeight = Math.min(sourceHeight, initialHeight + srcY); 8227 dstHeight = srcHeight; 8228 } else if (srcY <= sourceHeight) { 8229 dstY = 0; 8230 srcHeight = Math.min(initialHeight, sourceHeight - srcY); 8231 dstHeight = srcHeight; 8232 } 8233 var params = [srcX, srcY, srcWidth, srcHeight]; 8234 if (dstWidth > 0 && dstHeight > 0) { 8235 var scale2 = width / initialWidth; 8236 params.push(dstX * scale2, dstY * scale2, dstWidth * scale2, dstHeight * scale2); 8237 } 8238 context.drawImage.apply(context, [source].concat(_toConsumableArray2(params.map(function(param) { 8239 return Math.floor(normalizeDecimalNumber(param)); 8240 })))); 8241 return canvas; 8242 }, 8243 /** 8244 * Change the aspect ratio of the crop box. 8245 * @param {number} aspectRatio - The new aspect ratio. 8246 * @returns {Cropper} this 8247 */ 8248 setAspectRatio: function setAspectRatio(aspectRatio) { 8249 var options2 = this.options; 8250 if (!this.disabled && !isUndefined(aspectRatio)) { 8251 options2.aspectRatio = Math.max(0, aspectRatio) || NaN; 8252 if (this.ready) { 8253 this.initCropBox(); 8254 if (this.cropped) { 8255 this.renderCropBox(); 8256 } 8257 } 8258 } 8259 return this; 8260 }, 8261 /** 8262 * Change the drag mode. 8263 * @param {string} mode - The new drag mode. 8264 * @returns {Cropper} this 8265 */ 8266 setDragMode: function setDragMode(mode) { 8267 var options2 = this.options, dragBox = this.dragBox, face = this.face; 8268 if (this.ready && !this.disabled) { 8269 var croppable = mode === DRAG_MODE_CROP; 8270 var movable = options2.movable && mode === DRAG_MODE_MOVE; 8271 mode = croppable || movable ? mode : DRAG_MODE_NONE; 8272 options2.dragMode = mode; 8273 setData(dragBox, DATA_ACTION, mode); 8274 toggleClass(dragBox, CLASS_CROP, croppable); 8275 toggleClass(dragBox, CLASS_MOVE, movable); 8276 if (!options2.cropBoxMovable) { 8277 setData(face, DATA_ACTION, mode); 8278 toggleClass(face, CLASS_CROP, croppable); 8279 toggleClass(face, CLASS_MOVE, movable); 8280 } 8281 } 8282 return this; 8283 } 8284}; 8285var AnotherCropper = WINDOW.Cropper; 8286var Cropper = function() { 8287 function Cropper2(element) { 8288 var options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; 8289 _classCallCheck2(this, Cropper2); 8290 if (!element || !REGEXP_TAG_NAME.test(element.tagName)) { 8291 throw new Error("The first argument is required and must be an <img> or <canvas> element."); 8292 } 8293 this.element = element; 8294 this.options = assign2({}, DEFAULTS, isPlainObject(options2) && options2); 8295 this.cropped = false; 8296 this.disabled = false; 8297 this.pointers = {}; 8298 this.ready = false; 8299 this.reloading = false; 8300 this.replaced = false; 8301 this.sized = false; 8302 this.sizing = false; 8303 this.init(); 8304 } 8305 _createClass2(Cropper2, [{ 8306 key: "init", 8307 value: function init() { 8308 var element = this.element; 8309 var tagName = element.tagName.toLowerCase(); 8310 var url; 8311 if (element[NAMESPACE]) { 8312 return; 8313 } 8314 element[NAMESPACE] = this; 8315 if (tagName === "img") { 8316 this.isImg = true; 8317 url = element.getAttribute("src") || ""; 8318 this.originalUrl = url; 8319 if (!url) { 8320 return; 8321 } 8322 url = element.src; 8323 } else if (tagName === "canvas" && window.HTMLCanvasElement) { 8324 url = element.toDataURL(); 8325 } 8326 this.load(url); 8327 } 8328 }, { 8329 key: "load", 8330 value: function load(url) { 8331 var _this = this; 8332 if (!url) { 8333 return; 8334 } 8335 this.url = url; 8336 this.imageData = {}; 8337 var element = this.element, options2 = this.options; 8338 if (!options2.rotatable && !options2.scalable) { 8339 options2.checkOrientation = false; 8340 } 8341 if (!options2.checkOrientation || !window.ArrayBuffer) { 8342 this.clone(); 8343 return; 8344 } 8345 if (REGEXP_DATA_URL.test(url)) { 8346 if (REGEXP_DATA_URL_JPEG.test(url)) { 8347 this.read(dataURLToArrayBuffer(url)); 8348 } else { 8349 this.clone(); 8350 } 8351 return; 8352 } 8353 var xhr = new XMLHttpRequest(); 8354 var clone = this.clone.bind(this); 8355 this.reloading = true; 8356 this.xhr = xhr; 8357 xhr.onabort = clone; 8358 xhr.onerror = clone; 8359 xhr.ontimeout = clone; 8360 xhr.onprogress = function() { 8361 if (xhr.getResponseHeader("content-type") !== MIME_TYPE_JPEG) { 8362 xhr.abort(); 8363 } 8364 }; 8365 xhr.onload = function() { 8366 _this.read(xhr.response); 8367 }; 8368 xhr.onloadend = function() { 8369 _this.reloading = false; 8370 _this.xhr = null; 8371 }; 8372 if (options2.checkCrossOrigin && isCrossOriginURL(url) && element.crossOrigin) { 8373 url = addTimestamp(url); 8374 } 8375 xhr.open("GET", url, true); 8376 xhr.responseType = "arraybuffer"; 8377 xhr.withCredentials = element.crossOrigin === "use-credentials"; 8378 xhr.send(); 8379 } 8380 }, { 8381 key: "read", 8382 value: function read(arrayBuffer) { 8383 var options2 = this.options, imageData = this.imageData; 8384 var orientation = resetAndGetOrientation(arrayBuffer); 8385 var rotate2 = 0; 8386 var scaleX2 = 1; 8387 var scaleY2 = 1; 8388 if (orientation > 1) { 8389 this.url = arrayBufferToDataURL(arrayBuffer, MIME_TYPE_JPEG); 8390 var _parseOrientation = parseOrientation(orientation); 8391 rotate2 = _parseOrientation.rotate; 8392 scaleX2 = _parseOrientation.scaleX; 8393 scaleY2 = _parseOrientation.scaleY; 8394 } 8395 if (options2.rotatable) { 8396 imageData.rotate = rotate2; 8397 } 8398 if (options2.scalable) { 8399 imageData.scaleX = scaleX2; 8400 imageData.scaleY = scaleY2; 8401 } 8402 this.clone(); 8403 } 8404 }, { 8405 key: "clone", 8406 value: function clone() { 8407 var element = this.element, url = this.url; 8408 var crossOrigin = element.crossOrigin; 8409 var crossOriginUrl = url; 8410 if (this.options.checkCrossOrigin && isCrossOriginURL(url)) { 8411 if (!crossOrigin) { 8412 crossOrigin = "anonymous"; 8413 } 8414 crossOriginUrl = addTimestamp(url); 8415 } 8416 this.crossOrigin = crossOrigin; 8417 this.crossOriginUrl = crossOriginUrl; 8418 var image = document.createElement("img"); 8419 if (crossOrigin) { 8420 image.crossOrigin = crossOrigin; 8421 } 8422 image.src = crossOriginUrl || url; 8423 image.alt = element.alt || "The image to crop"; 8424 this.image = image; 8425 image.onload = this.start.bind(this); 8426 image.onerror = this.stop.bind(this); 8427 addClass(image, CLASS_HIDE); 8428 element.parentNode.insertBefore(image, element.nextSibling); 8429 } 8430 }, { 8431 key: "start", 8432 value: function start() { 8433 var _this2 = this; 8434 var image = this.image; 8435 image.onload = null; 8436 image.onerror = null; 8437 this.sizing = true; 8438 var isIOSWebKit = WINDOW.navigator && /(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(WINDOW.navigator.userAgent); 8439 var done = function done2(naturalWidth, naturalHeight) { 8440 assign2(_this2.imageData, { 8441 naturalWidth, 8442 naturalHeight, 8443 aspectRatio: naturalWidth / naturalHeight 8444 }); 8445 _this2.initialImageData = assign2({}, _this2.imageData); 8446 _this2.sizing = false; 8447 _this2.sized = true; 8448 _this2.build(); 8449 }; 8450 if (image.naturalWidth && !isIOSWebKit) { 8451 done(image.naturalWidth, image.naturalHeight); 8452 return; 8453 } 8454 var sizingImage = document.createElement("img"); 8455 var body = document.body || document.documentElement; 8456 this.sizingImage = sizingImage; 8457 sizingImage.onload = function() { 8458 done(sizingImage.width, sizingImage.height); 8459 if (!isIOSWebKit) { 8460 body.removeChild(sizingImage); 8461 } 8462 }; 8463 sizingImage.src = image.src; 8464 if (!isIOSWebKit) { 8465 sizingImage.style.cssText = "left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;"; 8466 body.appendChild(sizingImage); 8467 } 8468 } 8469 }, { 8470 key: "stop", 8471 value: function stop() { 8472 var image = this.image; 8473 image.onload = null; 8474 image.onerror = null; 8475 image.parentNode.removeChild(image); 8476 this.image = null; 8477 } 8478 }, { 8479 key: "build", 8480 value: function build() { 8481 if (!this.sized || this.ready) { 8482 return; 8483 } 8484 var element = this.element, options2 = this.options, image = this.image; 8485 var container = element.parentNode; 8486 var template18 = document.createElement("div"); 8487 template18.innerHTML = TEMPLATE; 8488 var cropper = template18.querySelector(".".concat(NAMESPACE, "-container")); 8489 var canvas = cropper.querySelector(".".concat(NAMESPACE, "-canvas")); 8490 var dragBox = cropper.querySelector(".".concat(NAMESPACE, "-drag-box")); 8491 var cropBox = cropper.querySelector(".".concat(NAMESPACE, "-crop-box")); 8492 var face = cropBox.querySelector(".".concat(NAMESPACE, "-face")); 8493 this.container = container; 8494 this.cropper = cropper; 8495 this.canvas = canvas; 8496 this.dragBox = dragBox; 8497 this.cropBox = cropBox; 8498 this.viewBox = cropper.querySelector(".".concat(NAMESPACE, "-view-box")); 8499 this.face = face; 8500 canvas.appendChild(image); 8501 addClass(element, CLASS_HIDDEN); 8502 container.insertBefore(cropper, element.nextSibling); 8503 removeClass(image, CLASS_HIDE); 8504 this.initPreview(); 8505 this.bind(); 8506 options2.initialAspectRatio = Math.max(0, options2.initialAspectRatio) || NaN; 8507 options2.aspectRatio = Math.max(0, options2.aspectRatio) || NaN; 8508 options2.viewMode = Math.max(0, Math.min(3, Math.round(options2.viewMode))) || 0; 8509 addClass(cropBox, CLASS_HIDDEN); 8510 if (!options2.guides) { 8511 addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-dashed")), CLASS_HIDDEN); 8512 } 8513 if (!options2.center) { 8514 addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-center")), CLASS_HIDDEN); 8515 } 8516 if (options2.background) { 8517 addClass(cropper, "".concat(NAMESPACE, "-bg")); 8518 } 8519 if (!options2.highlight) { 8520 addClass(face, CLASS_INVISIBLE); 8521 } 8522 if (options2.cropBoxMovable) { 8523 addClass(face, CLASS_MOVE); 8524 setData(face, DATA_ACTION, ACTION_ALL); 8525 } 8526 if (!options2.cropBoxResizable) { 8527 addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-line")), CLASS_HIDDEN); 8528 addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-point")), CLASS_HIDDEN); 8529 } 8530 this.render(); 8531 this.ready = true; 8532 this.setDragMode(options2.dragMode); 8533 if (options2.autoCrop) { 8534 this.crop(); 8535 } 8536 this.setData(options2.data); 8537 if (isFunction(options2.ready)) { 8538 addListener(element, EVENT_READY, options2.ready, { 8539 once: true 8540 }); 8541 } 8542 dispatchEvent(element, EVENT_READY); 8543 } 8544 }, { 8545 key: "unbuild", 8546 value: function unbuild() { 8547 if (!this.ready) { 8548 return; 8549 } 8550 this.ready = false; 8551 this.unbind(); 8552 this.resetPreview(); 8553 var parentNode = this.cropper.parentNode; 8554 if (parentNode) { 8555 parentNode.removeChild(this.cropper); 8556 } 8557 removeClass(this.element, CLASS_HIDDEN); 8558 } 8559 }, { 8560 key: "uncreate", 8561 value: function uncreate() { 8562 if (this.ready) { 8563 this.unbuild(); 8564 this.ready = false; 8565 this.cropped = false; 8566 } else if (this.sizing) { 8567 this.sizingImage.onload = null; 8568 this.sizing = false; 8569 this.sized = false; 8570 } else if (this.reloading) { 8571 this.xhr.onabort = null; 8572 this.xhr.abort(); 8573 } else if (this.image) { 8574 this.stop(); 8575 } 8576 } 8577 /** 8578 * Get the no conflict cropper class. 8579 * @returns {Cropper} The cropper class. 8580 */ 8581 }], [{ 8582 key: "noConflict", 8583 value: function noConflict() { 8584 window.Cropper = AnotherCropper; 8585 return Cropper2; 8586 } 8587 /** 8588 * Change the default options. 8589 * @param {Object} options - The new default options. 8590 */ 8591 }, { 8592 key: "setDefaults", 8593 value: function setDefaults(options2) { 8594 assign2(DEFAULTS, isPlainObject(options2) && options2); 8595 } 8596 }]); 8597 return Cropper2; 8598}(); 8599assign2(Cropper.prototype, render, preview, events, handlers, change, methods); 8600
vendor: 2,028 bytes, lines 8601-8671
8601// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/hooks/useCropImg.mjs 8602var QUALITY = 1; 8603var useCropImg = () => { 8604 const cropperRef = React11.useRef(); 8605 const [isCropping, setIsCropping] = React11.useState(false); 8606 const [size, setSize] = React11.useState({ 8607 width: void 0, 8608 height: void 0 8609 }); 8610 React11.useEffect(() => { 8611 return () => { 8612 if (cropperRef.current) { 8613 cropperRef.current.destroy(); 8614 } 8615 }; 8616 }, []); 8617 const handleResize = ({ detail: { height, width } }) => { 8618 const roundedDataWidth = Math.round(width); 8619 const roundedDataHeight = Math.round(height); 8620 setSize({ 8621 width: roundedDataWidth, 8622 height: roundedDataHeight 8623 }); 8624 }; 8625 const crop2 = (image) => { 8626 if (!cropperRef.current) { 8627 cropperRef.current = new Cropper(image, { 8628 modal: true, 8629 initialAspectRatio: 16 / 9, 8630 movable: true, 8631 zoomable: false, 8632 cropBoxResizable: true, 8633 background: false, 8634 checkCrossOrigin: false, 8635 crop: handleResize 8636 }); 8637 setIsCropping(true); 8638 } 8639 }; 8640 const stopCropping = () => { 8641 if (cropperRef.current) { 8642 cropperRef.current.destroy(); 8643 cropperRef.current = void 0; 8644 setIsCropping(false); 8645 } 8646 }; 8647 const produceFile = (name, mimeType, lastModifiedDate) => new Promise((resolve, reject) => { 8648 if (!cropperRef.current) { 8649 reject(new Error("The cropper has not been instantiated: make sure to call the crop() function before calling produceFile().")); 8650 } else { 8651 const canvas = cropperRef.current.getCroppedCanvas(); 8652 canvas.toBlob((blob) => { 8653 resolve(new File([ 8654 blob 8655 ], name, { 8656 type: mimeType, 8657 lastModified: new Date(lastModifiedDate).getTime() 8658 })); 8659 }, mimeType, QUALITY); 8660 } 8661 }); 8662 return { 8663 crop: crop2, 8664 produceFile, 8665 stopCropping, 8666 isCropping, 8667 isCropperReady: Boolean(cropperRef.current), 8668 ...size 8669 }; 8670}; 8671
vendor: 1,880 bytes, lines 8672-8740
8672// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/hooks/useUpload.mjs 8673var React12 = __toESM(require_react(), 1); 8674var endpoint = `/${pluginId}`; 8675var uploadAssets = (assets, folderId, signal, onProgress, post) => { 8676 const assetsArray = Array.isArray(assets) ? assets : [ 8677 assets 8678 ]; 8679 const formData = new FormData(); 8680 assetsArray.forEach((asset) => { 8681 if (asset.rawFile) { 8682 formData.append("files", asset.rawFile); 8683 } 8684 }); 8685 assetsArray.forEach((asset) => { 8686 formData.append("fileInfo", JSON.stringify({ 8687 name: asset.name, 8688 caption: asset.caption, 8689 alternativeText: asset.alternativeText, 8690 folder: folderId 8691 })); 8692 }); 8693 return post(endpoint, formData, { 8694 signal 8695 }).then((res) => res.data); 8696}; 8697var useUpload = () => { 8698 const dispatch = useDispatch(); 8699 const [progress, setProgress] = React12.useState(0); 8700 const queryClient = useQueryClient(); 8701 const abortController = new AbortController(); 8702 const signal = abortController.signal; 8703 const { post } = useFetchClient(); 8704 const mutation = useMutation(({ assets, folderId }) => { 8705 return uploadAssets(assets, folderId, signal, setProgress, post); 8706 }, { 8707 onSuccess() { 8708 queryClient.refetchQueries([ 8709 pluginId, 8710 "assets" 8711 ], { 8712 active: true 8713 }); 8714 queryClient.refetchQueries([ 8715 pluginId, 8716 "asset-count" 8717 ], { 8718 active: true 8719 }); 8720 dispatch(adminApi.util.invalidateTags([ 8721 "HomepageKeyStatistics", 8722 "AIUsage" 8723 ])); 8724 } 8725 }); 8726 const upload = (assets, folderId) => mutation.mutateAsync({ 8727 assets, 8728 folderId 8729 }); 8730 const cancel = () => abortController.abort(); 8731 return { 8732 upload, 8733 isLoading: mutation.isLoading, 8734 cancel, 8735 error: mutation.error, 8736 progress, 8737 status: mutation.status 8738 }; 8739}; 8740
vendor: 306 bytes, lines 8741-8745
8741// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/utils/prefixFileUrlWithBackendUrl.mjs 8742var prefixFileUrlWithBackendUrl = (fileURL) => { 8743 return !!fileURL && fileURL.startsWith("/") ? `${window.strapi.backendURL}${fileURL}` : fileURL; 8744}; 8745
vendor: 487 bytes, lines 8746-8755
8746// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/utils/createAssetUrl.mjs 8747var createAssetUrl = (asset, forThumbnail = true) => { 8748 var _a3, _b; 8749 if (asset.isLocal) { 8750 return asset.url; 8751 } 8752 const assetUrl = forThumbnail ? ((_b = (_a3 = asset == null ? void 0 : asset.formats) == null ? void 0 : _a3.thumbnail) == null ? void 0 : _b.url) || asset.url : asset.url; 8753 return prefixFileUrlWithBackendUrl(assetUrl); 8754}; 8755
vendor: 442 bytes, lines 8756-8765
8756// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/utils/downloadFile.mjs 8757var downloadFile = async (url, fileName) => { 8758 const fileBlob = await fetch(url).then((res) => res.blob()); 8759 const urlDownload = window.URL.createObjectURL(fileBlob); 8760 const link = document.createElement("a"); 8761 link.href = urlDownload; 8762 link.setAttribute("download", fileName); 8763 link.click(); 8764}; 8765
vendor: 214 bytes, lines 8766-8768
8766// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EditAssetDialog/PreviewBox/PreviewBox.mjs 8767var import_qs7 = __toESM(require_lib(), 1); 8768
vendor: 1,010 bytes, lines 8769-8797
8769// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/CopyLinkButton/CopyLinkButton.mjs 8770var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1); 8771var import_qs4 = __toESM(require_lib(), 1); 8772var CopyLinkButton = ({ url }) => { 8773 const { toggleNotification } = useNotification(); 8774 const { formatMessage } = useIntl(); 8775 const { copy: copy2 } = useClipboard(); 8776 const handleClick = async () => { 8777 const didCopy = await copy2(url); 8778 if (didCopy) { 8779 toggleNotification({ 8780 type: "success", 8781 message: formatMessage({ 8782 id: "notification.link-copied", 8783 defaultMessage: "Link copied into the clipboard" 8784 }) 8785 }); 8786 } 8787 }; 8788 return (0, import_jsx_runtime5.jsx)(IconButton, { 8789 label: formatMessage({ 8790 id: getTrad("control-card.copy-link"), 8791 defaultMessage: "Copy link" 8792 }), 8793 onClick: handleClick, 8794 children: (0, import_jsx_runtime5.jsx)(ForwardRef$1f, {}) 8795 }); 8796}; 8797
vendor: 2,227 bytes, lines 8798-8876
8798// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/UploadProgress/UploadProgress.mjs 8799var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1); 8800var BoxWrapper = dt(Flex)` 8801 border-radius: ${({ theme }) => `${theme.borderRadius} ${theme.borderRadius} 0 0`}; 8802 width: 100%; 8803 height: 100%; 8804 8805 svg { 8806 path { 8807 fill: ${({ theme, error }) => error ? theme.colors.danger600 : void 0}; 8808 } 8809 } 8810`; 8811var CancelButton = dt.button` 8812 border: none; 8813 background: none; 8814 width: min-content; 8815 color: ${({ theme }) => theme.colors.neutral600}; 8816 8817 &:hover, 8818 &:focus { 8819 color: ${({ theme }) => theme.colors.neutral700}; 8820 } 8821 8822 svg { 8823 height: 10px; 8824 width: 10px; 8825 8826 path { 8827 fill: currentColor; 8828 } 8829 } 8830`; 8831var UploadProgress = ({ onCancel, progress = 0, error }) => { 8832 const { formatMessage } = useIntl(); 8833 return (0, import_jsx_runtime6.jsx)(BoxWrapper, { 8834 alignItems: "center", 8835 background: error ? "danger100" : "neutral150", 8836 error, 8837 children: error ? (0, import_jsx_runtime6.jsx)(ForwardRef$26, { 8838 "aria-label": error == null ? void 0 : error.message 8839 }) : (0, import_jsx_runtime6.jsxs)(Flex, { 8840 direction: "column", 8841 alignItems: "center", 8842 gap: 2, 8843 width: "100%", 8844 children: [ 8845 (0, import_jsx_runtime6.jsx)(ProgressBar, { 8846 value: progress 8847 }), 8848 (0, import_jsx_runtime6.jsx)(Typography, { 8849 children: `${progress}/100%` 8850 }), 8851 (0, import_jsx_runtime6.jsx)(CancelButton, { 8852 type: "button", 8853 onClick: onCancel, 8854 children: (0, import_jsx_runtime6.jsxs)(Flex, { 8855 gap: 2, 8856 children: [ 8857 (0, import_jsx_runtime6.jsx)(Typography, { 8858 variant: "pi", 8859 tag: "span", 8860 textColor: "inherit", 8861 children: formatMessage({ 8862 id: "app.components.Button.cancel", 8863 defaultMessage: "Cancel" 8864 }) 8865 }), 8866 (0, import_jsx_runtime6.jsx)(ForwardRef$26, { 8867 "aria-hidden": true 8868 }) 8869 ] 8870 }) 8871 }) 8872 ] 8873 }) 8874 }); 8875}; 8876
vendor: 227 bytes, lines 8877-8879
8877// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EditAssetDialog/RemoveAssetDialog.mjs 8878var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1); 8879
vendor: 1,307 bytes, lines 8880-8928
8880// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/hooks/useRemoveAsset.mjs 8881var useRemoveAsset = (onSuccess) => { 8882 const dispatch = useDispatch(); 8883 const { toggleNotification } = useNotification(); 8884 const { formatMessage } = useIntl(); 8885 const queryClient = useQueryClient(); 8886 const { del } = useFetchClient(); 8887 const mutation = useMutation((assetId) => del(`/upload/files/${assetId}`), { 8888 onSuccess() { 8889 queryClient.refetchQueries([ 8890 pluginId, 8891 "assets" 8892 ], { 8893 active: true 8894 }); 8895 queryClient.refetchQueries([ 8896 pluginId, 8897 "asset-count" 8898 ], { 8899 active: true 8900 }); 8901 toggleNotification({ 8902 type: "success", 8903 message: formatMessage({ 8904 id: "modal.remove.success-label", 8905 defaultMessage: "Elements have been successfully deleted." 8906 }) 8907 }); 8908 dispatch(adminApi.util.invalidateTags([ 8909 "HomepageKeyStatistics" 8910 ])); 8911 onSuccess(); 8912 }, 8913 onError(error) { 8914 toggleNotification({ 8915 type: "danger", 8916 message: error.message 8917 }); 8918 } 8919 }); 8920 const removeAsset = async (assetId) => { 8921 await mutation.mutateAsync(assetId); 8922 }; 8923 return { 8924 ...mutation, 8925 removeAsset 8926 }; 8927}; 8928
vendor: 627 bytes, lines 8929-8946
8929// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EditAssetDialog/RemoveAssetDialog.mjs 8930var RemoveAssetDialog = ({ open, onClose, asset }) => { 8931 const { removeAsset } = useRemoveAsset(() => { 8932 onClose(null); 8933 }); 8934 const handleConfirm = async (event) => { 8935 event == null ? void 0 : event.preventDefault(); 8936 await removeAsset(asset.id); 8937 }; 8938 return (0, import_jsx_runtime7.jsx)(Dialog.Root, { 8939 open, 8940 onOpenChange: onClose, 8941 children: (0, import_jsx_runtime7.jsx)(ConfirmDialog, { 8942 onConfirm: handleConfirm 8943 }) 8944 }); 8945}; 8946
vendor: 276 bytes, lines 8947-8950
8947// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EditAssetDialog/PreviewBox/AssetPreview.mjs 8948var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1); 8949var React13 = __toESM(require_react(), 1); 8950
vendor: 244 bytes, lines 8951-8953
8951// node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]__@[email protected]_v5oz3fkxfmbzkmmswy7mecoobm/node_modules/@mux/mux-player-react/dist/index.mjs 8952var import_react11 = __toESM(require_react(), 1); 8953
vendor: 113,805 bytes, lines 8954-10945
8954// node_modules/.pnpm/[email protected]/node_modules/mux-embed/dist/mux.mjs 8955var Zr = Object.create; 8956var _t = Object.defineProperty; 8957var ea = Object.getOwnPropertyDescriptor; 8958var ta = Object.getOwnPropertyNames; 8959var ra = Object.getPrototypeOf; 8960var aa = Object.prototype.hasOwnProperty; 8961var ft2 = function(r10, e) { 8962 return function() { 8963 return r10 && (e = r10(r10 = 0)), e; 8964 }; 8965}; 8966var B = function(r10, e) { 8967 return function() { 8968 return e || r10((e = { exports: {} }).exports, e), e.exports; 8969 }; 8970}; 8971var ia = function(r10, e, t2, i3) { 8972 if (e && typeof e == "object" || typeof e == "function") for (var a2 = ta(e), n2 = 0, o2 = a2.length, s; n2 < o2; n2++) s = a2[n2], !aa.call(r10, s) && s !== t2 && _t(r10, s, { get: (function(u3) { 8973 return e[u3]; 8974 }).bind(null, s), enumerable: !(i3 = ea(e, s)) || i3.enumerable }); 8975 return r10; 8976}; 8977var G = function(r10, e, t2) { 8978 return t2 = r10 != null ? Zr(ra(r10)) : {}, ia(e || !r10 || !r10.__esModule ? _t(t2, "default", { value: r10, enumerable: true }) : t2, r10); 8979}; 8980var Q = B(function(Xi, ht4) { 8981 var xe3; 8982 typeof window != "undefined" ? xe3 = window : typeof global != "undefined" ? xe3 = global : typeof self != "undefined" ? xe3 = self : xe3 = {}; 8983 ht4.exports = xe3; 8984}); 8985function U(r10, e) { 8986 return e != null && typeof Symbol != "undefined" && e[Symbol.hasInstance] ? !!e[Symbol.hasInstance](r10) : U(r10, e); 8987} 8988var te = ft2(function() { 8989 te(); 8990}); 8991function Le(r10) { 8992 "@swc/helpers - typeof"; 8993 return r10 && typeof Symbol != "undefined" && r10.constructor === Symbol ? "symbol" : typeof r10; 8994} 8995var Je = ft2(function() { 8996}); 8997var Ke = B(function(Ss, cr) { 8998 var lr = Array.prototype.slice; 8999 cr.exports = La; 9000 function La(r10, e) { 9001 for (("length" in r10) || (r10 = [r10]), r10 = lr.call(r10); r10.length; ) { 9002 var t2 = r10.shift(), i3 = e(t2); 9003 if (i3) return i3; 9004 t2.childNodes && t2.childNodes.length && (r10 = lr.call(t2.childNodes).concat(r10)); 9005 } 9006 } 9007}); 9008var fr = B(function(Rs, _r) { 9009 te(); 9010 _r.exports = ve4; 9011 function ve4(r10, e) { 9012 if (!U(this, ve4)) return new ve4(r10, e); 9013 this.data = r10, this.nodeValue = r10, this.length = r10.length, this.ownerDocument = e || null; 9014 } 9015 ve4.prototype.nodeType = 8; 9016 ve4.prototype.nodeName = "#comment"; 9017 ve4.prototype.toString = function() { 9018 return "[object Comment]"; 9019 }; 9020}); 9021var mr = B(function(Ps, pr) { 9022 te(); 9023 pr.exports = ae5; 9024 function ae5(r10, e) { 9025 if (!U(this, ae5)) return new ae5(r10); 9026 this.data = r10 || "", this.length = this.data.length, this.ownerDocument = e || null; 9027 } 9028 ae5.prototype.type = "DOMTextNode"; 9029 ae5.prototype.nodeType = 3; 9030 ae5.prototype.nodeName = "#text"; 9031 ae5.prototype.toString = function() { 9032 return this.data; 9033 }; 9034 ae5.prototype.replaceData = function(e, t2, i3) { 9035 var a2 = this.data, n2 = a2.substring(0, e), o2 = a2.substring(e + t2, a2.length); 9036 this.data = n2 + i3 + o2, this.length = this.data.length; 9037 }; 9038}); 9039var Ye = B(function(Os, vr) { 9040 vr.exports = Na; 9041 function Na(r10) { 9042 var e = this, t2 = r10.type; 9043 r10.target || (r10.target = e), e.listeners || (e.listeners = {}); 9044 var i3 = e.listeners[t2]; 9045 if (i3) return i3.forEach(function(a2) { 9046 r10.currentTarget = e, typeof a2 == "function" ? a2(r10) : a2.handleEvent(r10); 9047 }); 9048 e.parentNode && e.parentNode.dispatchEvent(r10); 9049 } 9050}); 9051var Xe = B(function(Is, hr) { 9052 hr.exports = Ca2; 9053 function Ca2(r10, e) { 9054 var t2 = this; 9055 t2.listeners || (t2.listeners = {}), t2.listeners[r10] || (t2.listeners[r10] = []), t2.listeners[r10].indexOf(e) === -1 && t2.listeners[r10].push(e); 9056 } 9057}); 9058var $e = B(function(Ls, yr) { 9059 yr.exports = Ma; 9060 function Ma(r10, e) { 9061 var t2 = this; 9062 if (t2.listeners && t2.listeners[r10]) { 9063 var i3 = t2.listeners[r10], a2 = i3.indexOf(e); 9064 a2 !== -1 && i3.splice(a2, 1); 9065 } 9066 } 9067}); 9068var Tr2 = B(function(Cs2, wr) { 9069 Je(); 9070 wr.exports = gr; 9071 var Ha2 = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "menuitem", "meta", "param", "source", "track", "wbr"]; 9072 function gr(r10) { 9073 switch (r10.nodeType) { 9074 case 3: 9075 return Ze3(r10.data); 9076 case 8: 9077 return "<!--" + r10.data + "-->"; 9078 default: 9079 return Ba2(r10); 9080 } 9081 } 9082 function Ba2(r10) { 9083 var e = [], t2 = r10.tagName; 9084 return r10.namespaceURI === "http://www.w3.org/1999/xhtml" && (t2 = t2.toLowerCase()), e.push("<" + t2 + ja(r10) + Va2(r10)), Ha2.indexOf(t2) > -1 ? e.push(" />") : (e.push(">"), r10.childNodes.length ? e.push.apply(e, r10.childNodes.map(gr)) : r10.textContent || r10.innerText ? e.push(Ze3(r10.textContent || r10.innerText)) : r10.innerHTML && e.push(r10.innerHTML), e.push("</" + t2 + ">")), e.join(""); 9085 } 9086 function Ua2(r10, e) { 9087 var t2 = Le(r10[e]); 9088 return e === "style" && Object.keys(r10.style).length > 0 ? true : r10.hasOwnProperty(e) && (t2 === "string" || t2 === "boolean" || t2 === "number") && e !== "nodeName" && e !== "className" && e !== "tagName" && e !== "textContent" && e !== "innerText" && e !== "namespaceURI" && e !== "innerHTML"; 9089 } 9090 function Fa2(r10) { 9091 if (typeof r10 == "string") return r10; 9092 var e = ""; 9093 return Object.keys(r10).forEach(function(t2) { 9094 var i3 = r10[t2]; 9095 t2 = t2.replace(/[A-Z]/g, function(a2) { 9096 return "-" + a2.toLowerCase(); 9097 }), e += t2 + ":" + i3 + ";"; 9098 }), e; 9099 } 9100 function Va2(r10) { 9101 var e = r10.dataset, t2 = []; 9102 for (var i3 in e) t2.push({ name: "data-" + i3, value: e[i3] }); 9103 return t2.length ? br(t2) : ""; 9104 } 9105 function br(r10) { 9106 var e = []; 9107 return r10.forEach(function(t2) { 9108 var i3 = t2.name, a2 = t2.value; 9109 i3 === "style" && (a2 = Fa2(a2)), e.push(i3 + '="' + Wa(a2) + '"'); 9110 }), e.length ? " " + e.join(" ") : ""; 9111 } 9112 function ja(r10) { 9113 var e = []; 9114 for (var t2 in r10) Ua2(r10, t2) && e.push({ name: t2, value: r10[t2] }); 9115 for (var i3 in r10._attributes) for (var a2 in r10._attributes[i3]) { 9116 var n2 = r10._attributes[i3][a2], o2 = (n2.prefix ? n2.prefix + ":" : "") + a2; 9117 e.push({ name: o2, value: n2.value }); 9118 } 9119 return r10.className && e.push({ name: "class", value: r10.className }), e.length ? br(e) : ""; 9120 } 9121 function Ze3(r10) { 9122 var e = ""; 9123 return typeof r10 == "string" ? e = r10 : r10 && (e = r10.toString()), e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"); 9124 } 9125 function Wa(r10) { 9126 return Ze3(r10).replace(/"/g, """); 9127 } 9128}); 9129var tt = B(function(Hs, kr) { 9130 te(); 9131 var et3 = Ke(), Ga = Ye(), Ja = Xe(), Qa = $e(), za = Tr2(), Er = "http://www.w3.org/1999/xhtml"; 9132 kr.exports = I4; 9133 function I4(r10, e, t2) { 9134 if (!U(this, I4)) return new I4(r10); 9135 var i3 = t2 === void 0 ? Er : t2 || null; 9136 this.tagName = i3 === Er ? String(r10).toUpperCase() : r10, this.nodeName = this.tagName, this.className = "", this.dataset = {}, this.childNodes = [], this.parentNode = null, this.style = {}, this.ownerDocument = e || null, this.namespaceURI = i3, this._attributes = {}, this.tagName === "INPUT" && (this.type = "text"); 9137 } 9138 I4.prototype.type = "DOMElement"; 9139 I4.prototype.nodeType = 1; 9140 I4.prototype.appendChild = function(e) { 9141 return e.parentNode && e.parentNode.removeChild(e), this.childNodes.push(e), e.parentNode = this, e; 9142 }; 9143 I4.prototype.replaceChild = function(e, t2) { 9144 e.parentNode && e.parentNode.removeChild(e); 9145 var i3 = this.childNodes.indexOf(t2); 9146 return t2.parentNode = null, this.childNodes[i3] = e, e.parentNode = this, t2; 9147 }; 9148 I4.prototype.removeChild = function(e) { 9149 var t2 = this.childNodes.indexOf(e); 9150 return this.childNodes.splice(t2, 1), e.parentNode = null, e; 9151 }; 9152 I4.prototype.insertBefore = function(e, t2) { 9153 e.parentNode && e.parentNode.removeChild(e); 9154 var i3 = t2 == null ? -1 : this.childNodes.indexOf(t2); 9155 return i3 > -1 ? this.childNodes.splice(i3, 0, e) : this.childNodes.push(e), e.parentNode = this, e; 9156 }; 9157 I4.prototype.setAttributeNS = function(e, t2, i3) { 9158 var a2 = null, n2 = t2, o2 = t2.indexOf(":"); 9159 if (o2 > -1 && (a2 = t2.substr(0, o2), n2 = t2.substr(o2 + 1)), this.tagName === "INPUT" && t2 === "type") this.type = i3; 9160 else { 9161 var s = this._attributes[e] || (this._attributes[e] = {}); 9162 s[n2] = { value: i3, prefix: a2 }; 9163 } 9164 }; 9165 I4.prototype.getAttributeNS = function(e, t2) { 9166 var i3 = this._attributes[e], a2 = i3 && i3[t2] && i3[t2].value; 9167 return this.tagName === "INPUT" && t2 === "type" ? this.type : typeof a2 != "string" ? null : a2; 9168 }; 9169 I4.prototype.removeAttributeNS = function(e, t2) { 9170 var i3 = this._attributes[e]; 9171 i3 && delete i3[t2]; 9172 }; 9173 I4.prototype.hasAttributeNS = function(e, t2) { 9174 var i3 = this._attributes[e]; 9175 return !!i3 && t2 in i3; 9176 }; 9177 I4.prototype.setAttribute = function(e, t2) { 9178 return this.setAttributeNS(null, e, t2); 9179 }; 9180 I4.prototype.getAttribute = function(e) { 9181 return this.getAttributeNS(null, e); 9182 }; 9183 I4.prototype.removeAttribute = function(e) { 9184 return this.removeAttributeNS(null, e); 9185 }; 9186 I4.prototype.hasAttribute = function(e) { 9187 return this.hasAttributeNS(null, e); 9188 }; 9189 I4.prototype.removeEventListener = Qa; 9190 I4.prototype.addEventListener = Ja; 9191 I4.prototype.dispatchEvent = Ga; 9192 I4.prototype.focus = function() { 9193 }; 9194 I4.prototype.toString = function() { 9195 return za(this); 9196 }; 9197 I4.prototype.getElementsByClassName = function(e) { 9198 var t2 = e.split(" "), i3 = []; 9199 return et3(this, function(a2) { 9200 if (a2.nodeType === 1) { 9201 var n2 = a2.className || "", o2 = n2.split(" "); 9202 t2.every(function(s) { 9203 return o2.indexOf(s) !== -1; 9204 }) && i3.push(a2); 9205 } 9206 }), i3; 9207 }; 9208 I4.prototype.getElementsByTagName = function(e) { 9209 e = e.toLowerCase(); 9210 var t2 = []; 9211 return et3(this.childNodes, function(i3) { 9212 i3.nodeType === 1 && (e === "*" || i3.tagName.toLowerCase() === e) && t2.push(i3); 9213 }), t2; 9214 }; 9215 I4.prototype.contains = function(e) { 9216 return et3(this, function(t2) { 9217 return e === t2; 9218 }) || false; 9219 }; 9220}); 9221var Dr = B(function(Us, xr) { 9222 te(); 9223 var rt3 = tt(); 9224 xr.exports = K4; 9225 function K4(r10) { 9226 if (!U(this, K4)) return new K4(); 9227 this.childNodes = [], this.parentNode = null, this.ownerDocument = r10 || null; 9228 } 9229 K4.prototype.type = "DocumentFragment"; 9230 K4.prototype.nodeType = 11; 9231 K4.prototype.nodeName = "#document-fragment"; 9232 K4.prototype.appendChild = rt3.prototype.appendChild; 9233 K4.prototype.replaceChild = rt3.prototype.replaceChild; 9234 K4.prototype.removeChild = rt3.prototype.removeChild; 9235 K4.prototype.toString = function() { 9236 return this.childNodes.map(function(e) { 9237 return String(e); 9238 }).join(""); 9239 }; 9240}); 9241var qr = B(function(Fs, Sr2) { 9242 Sr2.exports = at3; 9243 function at3(r10) { 9244 } 9245 at3.prototype.initEvent = function(e, t2, i3) { 9246 this.type = e, this.bubbles = t2, this.cancelable = i3; 9247 }; 9248 at3.prototype.preventDefault = function() { 9249 }; 9250}); 9251var Ar = B(function(js, Rr) { 9252 te(); 9253 var Ka2 = Ke(), Ya = fr(), Xa = mr(), qe2 = tt(), $a2 = Dr(), Za = qr(), ei2 = Ye(), ti2 = Xe(), ri2 = $e(); 9254 Rr.exports = Be4; 9255 function Be4() { 9256 if (!U(this, Be4)) return new Be4(); 9257 this.head = this.createElement("head"), this.body = this.createElement("body"), this.documentElement = this.createElement("html"), this.documentElement.appendChild(this.head), this.documentElement.appendChild(this.body), this.childNodes = [this.documentElement], this.nodeType = 9; 9258 } 9259 var j3 = Be4.prototype; 9260 j3.createTextNode = function(e) { 9261 return new Xa(e, this); 9262 }; 9263 j3.createElementNS = function(e, t2) { 9264 var i3 = e === null ? null : String(e); 9265 return new qe2(t2, this, i3); 9266 }; 9267 j3.createElement = function(e) { 9268 return new qe2(e, this); 9269 }; 9270 j3.createDocumentFragment = function() { 9271 return new $a2(this); 9272 }; 9273 j3.createEvent = function(e) { 9274 return new Za(e); 9275 }; 9276 j3.createComment = function(e) { 9277 return new Ya(e, this); 9278 }; 9279 j3.getElementById = function(e) { 9280 e = String(e); 9281 var t2 = Ka2(this.childNodes, function(i3) { 9282 if (String(i3.id) === e) return i3; 9283 }); 9284 return t2 || null; 9285 }; 9286 j3.getElementsByClassName = qe2.prototype.getElementsByClassName; 9287 j3.getElementsByTagName = qe2.prototype.getElementsByTagName; 9288 j3.contains = qe2.prototype.contains; 9289 j3.removeEventListener = ri2; 9290 j3.addEventListener = ti2; 9291 j3.dispatchEvent = ei2; 9292}); 9293var Or = B(function(Ws, Pr) { 9294 var ai = Ar(); 9295 Pr.exports = new ai(); 9296}); 9297var it = B(function(Gs, Lr2) { 9298 var Ir2 = typeof global != "undefined" ? global : typeof window != "undefined" ? window : {}, ii2 = Or(), Re4; 9299 typeof document != "undefined" ? Re4 = document : (Re4 = Ir2["__GLOBAL_DOCUMENT_CACHE@4"], Re4 || (Re4 = Ir2["__GLOBAL_DOCUMENT_CACHE@4"] = ii2)); 9300 Lr2.exports = Re4; 9301}); 9302function pt(r10) { 9303 if (Array.isArray(r10)) return r10; 9304} 9305function mt(r10, e) { 9306 var t2 = r10 == null ? null : typeof Symbol != "undefined" && r10[Symbol.iterator] || r10["@@iterator"]; 9307 if (t2 != null) { 9308 var i3 = [], a2 = true, n2 = false, o2, s; 9309 try { 9310 for (t2 = t2.call(r10); !(a2 = (o2 = t2.next()).done) && (i3.push(o2.value), !(e && i3.length === e)); a2 = true) ; 9311 } catch (u3) { 9312 n2 = true, s = u3; 9313 } finally { 9314 try { 9315 !a2 && t2.return != null && t2.return(); 9316 } finally { 9317 if (n2) throw s; 9318 } 9319 } 9320 return i3; 9321 } 9322} 9323function vt() { 9324 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 9325} 9326function ke(r10, e) { 9327 (e == null || e > r10.length) && (e = r10.length); 9328 for (var t2 = 0, i3 = new Array(e); t2 < e; t2++) i3[t2] = r10[t2]; 9329 return i3; 9330} 9331function Ae(r10, e) { 9332 if (r10) { 9333 if (typeof r10 == "string") return ke(r10, e); 9334 var t2 = Object.prototype.toString.call(r10).slice(8, -1); 9335 if (t2 === "Object" && r10.constructor && (t2 = r10.constructor.name), t2 === "Map" || t2 === "Set") return Array.from(t2); 9336 if (t2 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t2)) return ke(r10, e); 9337 } 9338} 9339function H(r10, e) { 9340 return pt(r10) || mt(r10, e) || Ae(r10, e) || vt(); 9341} 9342var be = G(Q()); 9343var Ge = G(Q()); 9344var yt = G(Q()); 9345var na = { now: function() { 9346 var r10 = yt.default.performance, e = r10 && r10.timing, t2 = e && e.navigationStart, i3 = typeof t2 == "number" && typeof r10.now == "function" ? t2 + r10.now() : Date.now(); 9347 return Math.round(i3); 9348} }; 9349var A = na; 9350var ee = function() { 9351 var e, t2, i3; 9352 if (typeof ((e = Ge.default.crypto) === null || e === void 0 ? void 0 : e.getRandomValues) == "function") { 9353 i3 = new Uint8Array(32), Ge.default.crypto.getRandomValues(i3); 9354 for (var a2 = 0; a2 < 32; a2++) i3[a2] = i3[a2] % 16; 9355 } else { 9356 i3 = []; 9357 for (var n2 = 0; n2 < 32; n2++) i3[n2] = Math.random() * 16 | 0; 9358 } 9359 var o2 = 0; 9360 t2 = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(f) { 9361 var g = f === "x" ? i3[o2] : i3[o2] & 3 | 8; 9362 return o2++, g.toString(16); 9363 }); 9364 var s = A.now(), u3 = s == null ? void 0 : s.toString(16).substring(3); 9365 return u3 ? t2.substring(0, 28) + u3 : t2; 9366}; 9367var Pe = function() { 9368 return ("000000" + (Math.random() * Math.pow(36, 6) << 0).toString(36)).slice(-6); 9369}; 9370var J = function(e) { 9371 if (e && typeof e.nodeName != "undefined") return e.muxId || (e.muxId = Pe()), e.muxId; 9372 var t2; 9373 try { 9374 t2 = document.querySelector(e); 9375 } catch (i3) { 9376 } 9377 return t2 && !t2.muxId && (t2.muxId = e), (t2 == null ? void 0 : t2.muxId) || e; 9378}; 9379var se = function(e) { 9380 var t2; 9381 e && typeof e.nodeName != "undefined" ? (t2 = e, e = J(t2)) : t2 = document.querySelector(e); 9382 var i3 = t2 && t2.nodeName ? t2.nodeName.toLowerCase() : ""; 9383 return [t2, e, i3]; 9384}; 9385function gt(r10) { 9386 if (Array.isArray(r10)) return ke(r10); 9387} 9388function bt(r10) { 9389 if (typeof Symbol != "undefined" && r10[Symbol.iterator] != null || r10["@@iterator"] != null) return Array.from(r10); 9390} 9391function wt() { 9392 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); 9393} 9394function V(r10) { 9395 return gt(r10) || bt(r10) || Ae(r10) || wt(); 9396} 9397var Y = { TRACE: 0, DEBUG: 1, INFO: 2, WARN: 3, ERROR: 4, SILENT: 5 }; 9398var Tt = function(r10) { 9399 var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 3, t2, i3, a2, n2, o2, s = r10 ? [console, r10] : [console], u3 = (t2 = console.trace).bind.apply(t2, V(s)), f = (i3 = console.info).bind.apply(i3, V(s)), g = (a2 = console.debug).bind.apply(a2, V(s)), k3 = (n2 = console.warn).bind.apply(n2, V(s)), h3 = (o2 = console.error).bind.apply(o2, V(s)), c3 = e; 9400 return { trace: function() { 9401 for (var w4 = arguments.length, x2 = new Array(w4), v2 = 0; v2 < w4; v2++) x2[v2] = arguments[v2]; 9402 if (!(c3 > Y.TRACE)) return u3.apply(void 0, V(x2)); 9403 }, debug: function() { 9404 for (var w4 = arguments.length, x2 = new Array(w4), v2 = 0; v2 < w4; v2++) x2[v2] = arguments[v2]; 9405 if (!(c3 > Y.DEBUG)) return g.apply(void 0, V(x2)); 9406 }, info: function() { 9407 for (var w4 = arguments.length, x2 = new Array(w4), v2 = 0; v2 < w4; v2++) x2[v2] = arguments[v2]; 9408 if (!(c3 > Y.INFO)) return f.apply(void 0, V(x2)); 9409 }, warn: function() { 9410 for (var w4 = arguments.length, x2 = new Array(w4), v2 = 0; v2 < w4; v2++) x2[v2] = arguments[v2]; 9411 if (!(c3 > Y.WARN)) return k3.apply(void 0, V(x2)); 9412 }, error: function() { 9413 for (var w4 = arguments.length, x2 = new Array(w4), v2 = 0; v2 < w4; v2++) x2[v2] = arguments[v2]; 9414 if (!(c3 > Y.ERROR)) return h3.apply(void 0, V(x2)); 9415 }, get level() { 9416 return c3; 9417 }, set level(m2) { 9418 m2 !== this.level && (c3 = m2 != null ? m2 : e); 9419 } }; 9420}; 9421var R = Tt("[mux]"); 9422var Oe = G(Q()); 9423function ce() { 9424 var r10 = Oe.default.doNotTrack || Oe.default.navigator && Oe.default.navigator.doNotTrack; 9425 return r10 === "1"; 9426} 9427function b(r10) { 9428 if (r10 === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 9429 return r10; 9430} 9431te(); 9432function D(r10, e) { 9433 if (!U(r10, e)) throw new TypeError("Cannot call a class as a function"); 9434} 9435function Et(r10, e) { 9436 for (var t2 = 0; t2 < e.length; t2++) { 9437 var i3 = e[t2]; 9438 i3.enumerable = i3.enumerable || false, i3.configurable = true, "value" in i3 && (i3.writable = true), Object.defineProperty(r10, i3.key, i3); 9439 } 9440} 9441function N(r10, e, t2) { 9442 return e && Et(r10.prototype, e), t2 && Et(r10, t2), r10; 9443} 9444function l(r10, e, t2) { 9445 return e in r10 ? Object.defineProperty(r10, e, { value: t2, enumerable: true, configurable: true, writable: true }) : r10[e] = t2, r10; 9446} 9447function X(r10) { 9448 return X = Object.setPrototypeOf ? Object.getPrototypeOf : function(t2) { 9449 return t2.__proto__ || Object.getPrototypeOf(t2); 9450 }, X(r10); 9451} 9452function kt(r10, e) { 9453 for (; !Object.prototype.hasOwnProperty.call(r10, e) && (r10 = X(r10), r10 !== null); ) ; 9454 return r10; 9455} 9456function De(r10, e, t2) { 9457 return typeof Reflect != "undefined" && Reflect.get ? De = Reflect.get : De = function(a2, n2, o2) { 9458 var s = kt(a2, n2); 9459 if (s) { 9460 var u3 = Object.getOwnPropertyDescriptor(s, n2); 9461 return u3.get ? u3.get.call(o2 || a2) : u3.value; 9462 } 9463 }, De(r10, e, t2 || r10); 9464} 9465function Ie(r10, e) { 9466 return Ie = Object.setPrototypeOf || function(i3, a2) { 9467 return i3.__proto__ = a2, i3; 9468 }, Ie(r10, e); 9469} 9470function xt(r10, e) { 9471 if (typeof e != "function" && e !== null) throw new TypeError("Super expression must either be null or a function"); 9472 r10.prototype = Object.create(e && e.prototype, { constructor: { value: r10, writable: true, configurable: true } }), e && Ie(r10, e); 9473} 9474function Dt(r10, e) { 9475 if (r10 == null) return {}; 9476 var t2 = {}, i3 = Object.keys(r10), a2, n2; 9477 for (n2 = 0; n2 < i3.length; n2++) a2 = i3[n2], !(e.indexOf(a2) >= 0) && (t2[a2] = r10[a2]); 9478 return t2; 9479} 9480function St(r10, e) { 9481 if (r10 == null) return {}; 9482 var t2 = Dt(r10, e), i3, a2; 9483 if (Object.getOwnPropertySymbols) { 9484 var n2 = Object.getOwnPropertySymbols(r10); 9485 for (a2 = 0; a2 < n2.length; a2++) i3 = n2[a2], !(e.indexOf(i3) >= 0) && Object.prototype.propertyIsEnumerable.call(r10, i3) && (t2[i3] = r10[i3]); 9486 } 9487 return t2; 9488} 9489function qt() { 9490 if (typeof Reflect == "undefined" || !Reflect.construct || Reflect.construct.sham) return false; 9491 if (typeof Proxy == "function") return true; 9492 try { 9493 return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() { 9494 })), true; 9495 } catch (r10) { 9496 return false; 9497 } 9498} 9499Je(); 9500function Rt(r10, e) { 9501 return e && (Le(e) === "object" || typeof e == "function") ? e : b(r10); 9502} 9503function At(r10) { 9504 var e = qt(); 9505 return function() { 9506 var i3 = X(r10), a2; 9507 if (e) { 9508 var n2 = X(this).constructor; 9509 a2 = Reflect.construct(i3, arguments, n2); 9510 } else a2 = i3.apply(this, arguments); 9511 return Rt(this, a2); 9512 }; 9513} 9514var F = function(r10) { 9515 return re(r10)[0]; 9516}; 9517var re = function(r10) { 9518 if (typeof r10 != "string" || r10 === "") return ["localhost"]; 9519 var e = /^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/, t2 = r10.match(e) || [], i3 = t2[4], a2; 9520 return i3 && (a2 = (i3.match(/[^\.]+\.[^\.]+$/) || [])[0]), [i3, a2]; 9521}; 9522var Ne = G(Q()); 9523var oa = { exists: function() { 9524 var r10 = Ne.default.performance, e = r10 && r10.timing; 9525 return e !== void 0; 9526}, domContentLoadedEventEnd: function() { 9527 var r10 = Ne.default.performance, e = r10 && r10.timing; 9528 return e && e.domContentLoadedEventEnd; 9529}, navigationStart: function() { 9530 var r10 = Ne.default.performance, e = r10 && r10.timing; 9531 return e && e.navigationStart; 9532} }; 9533var _e = oa; 9534function P(r10, e, t2) { 9535 t2 = t2 === void 0 ? 1 : t2, r10[e] = r10[e] || 0, r10[e] += t2; 9536} 9537function ue(r10) { 9538 for (var e = 1; e < arguments.length; e++) { 9539 var t2 = arguments[e] != null ? arguments[e] : {}, i3 = Object.keys(t2); 9540 typeof Object.getOwnPropertySymbols == "function" && (i3 = i3.concat(Object.getOwnPropertySymbols(t2).filter(function(a2) { 9541 return Object.getOwnPropertyDescriptor(t2, a2).enumerable; 9542 }))), i3.forEach(function(a2) { 9543 l(r10, a2, t2[a2]); 9544 }); 9545 } 9546 return r10; 9547} 9548function sa(r10, e) { 9549 var t2 = Object.keys(r10); 9550 if (Object.getOwnPropertySymbols) { 9551 var i3 = Object.getOwnPropertySymbols(r10); 9552 e && (i3 = i3.filter(function(a2) { 9553 return Object.getOwnPropertyDescriptor(r10, a2).enumerable; 9554 })), t2.push.apply(t2, i3); 9555 } 9556 return t2; 9557} 9558function fe(r10, e) { 9559 return e = e != null ? e : {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(r10, Object.getOwnPropertyDescriptors(e)) : sa(Object(e)).forEach(function(t2) { 9560 Object.defineProperty(r10, t2, Object.getOwnPropertyDescriptor(e, t2)); 9561 }), r10; 9562} 9563var ua = ["x-cdn", "content-type"]; 9564var Pt = ["x-request-id", "cf-ray", "x-amz-cf-id", "x-akamai-request-id"]; 9565var da = ua.concat(Pt); 9566function pe(r10) { 9567 r10 = r10 || ""; 9568 var e = {}, t2 = r10.trim().split(/[\r\n]+/); 9569 return t2.forEach(function(i3) { 9570 if (i3) { 9571 var a2 = i3.split(": "), n2 = a2.shift(); 9572 n2 && (da.indexOf(n2.toLowerCase()) >= 0 || n2.toLowerCase().indexOf("x-litix-") === 0) && (e[n2] = a2.join(": ")); 9573 } 9574 }), e; 9575} 9576function de(r10) { 9577 if (r10) { 9578 var e = Pt.find(function(t2) { 9579 return r10[t2] !== void 0; 9580 }); 9581 return e ? r10[e] : void 0; 9582 } 9583} 9584var la = function(r10) { 9585 var e = {}; 9586 for (var t2 in r10) { 9587 var i3 = r10[t2], a2 = i3["DATA-ID"].search("io.litix.data."); 9588 if (a2 !== -1) { 9589 var n2 = i3["DATA-ID"].replace("io.litix.data.", ""); 9590 e[n2] = i3.VALUE; 9591 } 9592 } 9593 return e; 9594}; 9595var Ce = la; 9596var Me = function(r10) { 9597 if (!r10) return {}; 9598 var e = _e.navigationStart(), t2 = r10.loading, i3 = t2 ? t2.start : r10.trequest, a2 = t2 ? t2.first : r10.tfirst, n2 = t2 ? t2.end : r10.tload; 9599 return { bytesLoaded: r10.total, requestStart: Math.round(e + i3), responseStart: Math.round(e + a2), responseEnd: Math.round(e + n2) }; 9600}; 9601var Se = function(r10) { 9602 if (!(!r10 || typeof r10.getAllResponseHeaders != "function")) return pe(r10.getAllResponseHeaders()); 9603}; 9604var Ot = function(r10, e, t2) { 9605 var i3 = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}, a2 = arguments.length > 4 ? arguments[4] : void 0, n2 = r10.log, o2 = r10.utils.secondsToMs, s = function(v2) { 9606 var p3 = parseInt(a2.version), _3; 9607 return p3 === 1 && v2.programDateTime !== null && (_3 = v2.programDateTime), p3 === 0 && v2.pdt !== null && (_3 = v2.pdt), _3; 9608 }; 9609 if (!_e.exists()) { 9610 n2.warn("performance timing not supported. Not tracking HLS.js."); 9611 return; 9612 } 9613 var u3 = function(v2, p3) { 9614 return r10.emit(e, v2, p3); 9615 }, f = function(v2, p3) { 9616 var _3 = p3.levels, d2 = p3.audioTracks, y4 = p3.url, T3 = p3.stats, E5 = p3.networkDetails, S3 = p3.sessionData, L = {}, M4 = {}; 9617 _3.forEach(function(W4, oe5) { 9618 L[oe5] = { width: W4.width, height: W4.height, bitrate: W4.bitrate, attrs: W4.attrs }; 9619 }), d2.forEach(function(W4, oe5) { 9620 M4[oe5] = { name: W4.name, language: W4.lang, bitrate: W4.bitrate }; 9621 }); 9622 var O2 = Me(T3), q3 = O2.bytesLoaded, Z4 = O2.requestStart, we4 = O2.responseStart, Te4 = O2.responseEnd; 9623 u3("requestcompleted", fe(ue({}, Ce(S3)), { request_event_type: v2, request_bytes_loaded: q3, request_start: Z4, request_response_start: we4, request_response_end: Te4, request_type: "manifest", request_hostname: F(y4), request_response_headers: Se(E5), request_rendition_lists: { media: L, audio: M4, video: {} } })); 9624 }; 9625 t2.on(a2.Events.MANIFEST_LOADED, f); 9626 var g = function(v2, p3) { 9627 var _3 = p3.details, d2 = p3.level, y4 = p3.networkDetails, T3 = p3.stats, E5 = Me(T3), S3 = E5.bytesLoaded, L = E5.requestStart, M4 = E5.responseStart, O2 = E5.responseEnd, q3 = _3.fragments[_3.fragments.length - 1], Z4 = s(q3) + o2(q3.duration); 9628 u3("requestcompleted", { request_event_type: v2, request_bytes_loaded: S3, request_start: L, request_response_start: M4, request_response_end: O2, request_current_level: d2, request_type: "manifest", request_hostname: F(_3.url), request_response_headers: Se(y4), video_holdback: _3.holdBack && o2(_3.holdBack), video_part_holdback: _3.partHoldBack && o2(_3.partHoldBack), video_part_target_duration: _3.partTarget && o2(_3.partTarget), video_target_duration: _3.targetduration && o2(_3.targetduration), video_source_is_live: _3.live, player_manifest_newest_program_time: isNaN(Z4) ? void 0 : Z4 }); 9629 }; 9630 t2.on(a2.Events.LEVEL_LOADED, g); 9631 var k3 = function(v2, p3) { 9632 var _3 = p3.details, d2 = p3.networkDetails, y4 = p3.stats, T3 = Me(y4), E5 = T3.bytesLoaded, S3 = T3.requestStart, L = T3.responseStart, M4 = T3.responseEnd; 9633 u3("requestcompleted", { request_event_type: v2, request_bytes_loaded: E5, request_start: S3, request_response_start: L, request_response_end: M4, request_type: "manifest", request_hostname: F(_3.url), request_response_headers: Se(d2) }); 9634 }; 9635 t2.on(a2.Events.AUDIO_TRACK_LOADED, k3); 9636 var h3 = function(v2, p3) { 9637 var _3 = p3.stats, d2 = p3.networkDetails, y4 = p3.frag; 9638 _3 = _3 || y4.stats; 9639 var T3 = Me(_3), E5 = T3.bytesLoaded, S3 = T3.requestStart, L = T3.responseStart, M4 = T3.responseEnd, O2 = d2 ? Se(d2) : void 0, q3 = { request_event_type: v2, request_bytes_loaded: E5, request_start: S3, request_response_start: L, request_response_end: M4, request_hostname: d2 ? F(d2.responseURL) : void 0, request_id: O2 ? de(O2) : void 0, request_response_headers: O2, request_media_duration: y4.duration, request_url: d2 == null ? void 0 : d2.responseURL }; 9640 y4.type === "main" ? (q3.request_type = "media", q3.request_current_level = y4.level, q3.request_video_width = (t2.levels[y4.level] || {}).width, q3.request_video_height = (t2.levels[y4.level] || {}).height, q3.request_labeled_bitrate = (t2.levels[y4.level] || {}).bitrate) : q3.request_type = y4.type, u3("requestcompleted", q3); 9641 }; 9642 t2.on(a2.Events.FRAG_LOADED, h3); 9643 var c3 = function(v2, p3) { 9644 var _3 = p3.frag, d2 = _3.start, y4 = s(_3), T3 = { currentFragmentPDT: y4, currentFragmentStart: o2(d2) }; 9645 u3("fragmentchange", T3); 9646 }; 9647 t2.on(a2.Events.FRAG_CHANGED, c3); 9648 var m2 = function(v2, p3) { 9649 var _3 = p3.type, d2 = p3.details, y4 = p3.response, T3 = p3.fatal, E5 = p3.frag, S3 = p3.networkDetails, L = (E5 == null ? void 0 : E5.url) || p3.url || "", M4 = S3 ? Se(S3) : void 0; 9650 if ((d2 === a2.ErrorDetails.MANIFEST_LOAD_ERROR || d2 === a2.ErrorDetails.MANIFEST_LOAD_TIMEOUT || d2 === a2.ErrorDetails.FRAG_LOAD_ERROR || d2 === a2.ErrorDetails.FRAG_LOAD_TIMEOUT || d2 === a2.ErrorDetails.LEVEL_LOAD_ERROR || d2 === a2.ErrorDetails.LEVEL_LOAD_TIMEOUT || d2 === a2.ErrorDetails.AUDIO_TRACK_LOAD_ERROR || d2 === a2.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT || d2 === a2.ErrorDetails.SUBTITLE_LOAD_ERROR || d2 === a2.ErrorDetails.SUBTITLE_LOAD_TIMEOUT || d2 === a2.ErrorDetails.KEY_LOAD_ERROR || d2 === a2.ErrorDetails.KEY_LOAD_TIMEOUT) && u3("requestfailed", { request_error: d2, request_url: L, request_hostname: F(L), request_id: M4 ? de(M4) : void 0, request_type: d2 === a2.ErrorDetails.FRAG_LOAD_ERROR || d2 === a2.ErrorDetails.FRAG_LOAD_TIMEOUT ? "media" : d2 === a2.ErrorDetails.AUDIO_TRACK_LOAD_ERROR || d2 === a2.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT ? "audio" : d2 === a2.ErrorDetails.SUBTITLE_LOAD_ERROR || d2 === a2.ErrorDetails.SUBTITLE_LOAD_TIMEOUT ? "subtitle" : d2 === a2.ErrorDetails.KEY_LOAD_ERROR || d2 === a2.ErrorDetails.KEY_LOAD_TIMEOUT ? "encryption" : "manifest", request_error_code: y4 == null ? void 0 : y4.code, request_error_text: y4 == null ? void 0 : y4.text }), T3) { 9651 var O2, q3 = "".concat(L ? "url: ".concat(L, "\n") : "") + "".concat(y4 && (y4.code || y4.text) ? "response: ".concat(y4.code, ", ").concat(y4.text, "\n") : "") + "".concat(p3.reason ? "failure reason: ".concat(p3.reason, "\n") : "") + "".concat(p3.level ? "level: ".concat(p3.level, "\n") : "") + "".concat(p3.parent ? "parent stream controller: ".concat(p3.parent, "\n") : "") + "".concat(p3.buffer ? "buffer length: ".concat(p3.buffer, "\n") : "") + "".concat(p3.error ? "error: ".concat(p3.error, "\n") : "") + "".concat(p3.event ? "event: ".concat(p3.event, "\n") : "") + "".concat(p3.err ? "error message: ".concat((O2 = p3.err) === null || O2 === void 0 ? void 0 : O2.message, "\n") : ""); 9652 u3("error", { player_error_code: _3, player_error_message: d2, player_error_context: q3 }); 9653 } 9654 }; 9655 t2.on(a2.Events.ERROR, m2); 9656 var w4 = function(v2, p3) { 9657 var _3 = p3.frag, d2 = _3 && _3._url || ""; 9658 u3("requestcanceled", { request_event_type: v2, request_url: d2, request_type: "media", request_hostname: F(d2) }); 9659 }; 9660 t2.on(a2.Events.FRAG_LOAD_EMERGENCY_ABORTED, w4); 9661 var x2 = function(v2, p3) { 9662 var _3 = p3.level, d2 = t2.levels[_3]; 9663 if (d2 && d2.attrs && d2.attrs.BANDWIDTH) { 9664 var y4 = d2.attrs.BANDWIDTH, T3, E5 = parseFloat(d2.attrs["FRAME-RATE"]); 9665 isNaN(E5) || (T3 = E5), y4 ? u3("renditionchange", { video_source_fps: T3, video_source_bitrate: y4, video_source_width: d2.width, video_source_height: d2.height, video_source_rendition_name: d2.name, video_source_codec: d2 == null ? void 0 : d2.videoCodec }) : n2.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js"); 9666 } 9667 }; 9668 t2.on(a2.Events.LEVEL_SWITCHED, x2), t2._stopMuxMonitor = function() { 9669 t2.off(a2.Events.MANIFEST_LOADED, f), t2.off(a2.Events.LEVEL_LOADED, g), t2.off(a2.Events.AUDIO_TRACK_LOADED, k3), t2.off(a2.Events.FRAG_LOADED, h3), t2.off(a2.Events.FRAG_CHANGED, c3), t2.off(a2.Events.ERROR, m2), t2.off(a2.Events.FRAG_LOAD_EMERGENCY_ABORTED, w4), t2.off(a2.Events.LEVEL_SWITCHED, x2), t2.off(a2.Events.DESTROYING, t2._stopMuxMonitor), delete t2._stopMuxMonitor; 9670 }, t2.on(a2.Events.DESTROYING, t2._stopMuxMonitor); 9671}; 9672var It = function(r10) { 9673 r10 && typeof r10._stopMuxMonitor == "function" && r10._stopMuxMonitor(); 9674}; 9675var Lt = function(r10, e) { 9676 if (!r10 || !r10.requestEndDate) return {}; 9677 var t2 = F(r10.url), i3 = r10.url, a2 = r10.bytesLoaded, n2 = new Date(r10.requestStartDate).getTime(), o2 = new Date(r10.firstByteDate).getTime(), s = new Date(r10.requestEndDate).getTime(), u3 = isNaN(r10.duration) ? 0 : r10.duration, f = typeof e.getMetricsFor == "function" ? e.getMetricsFor(r10.mediaType).HttpList : e.getDashMetrics().getHttpRequests(r10.mediaType), g; 9678 f.length > 0 && (g = pe(f[f.length - 1]._responseHeaders || "")); 9679 var k3 = g ? de(g) : void 0; 9680 return { requestStart: n2, requestResponseStart: o2, requestResponseEnd: s, requestBytesLoaded: a2, requestResponseHeaders: g, requestMediaDuration: u3, requestHostname: t2, requestUrl: i3, requestId: k3 }; 9681}; 9682var ca = function(r10, e) { 9683 var t2 = e.getQualityFor(r10), i3 = e.getCurrentTrackFor(r10).bitrateList; 9684 return i3 ? { currentLevel: t2, renditionWidth: i3[t2].width || null, renditionHeight: i3[t2].height || null, renditionBitrate: i3[t2].bandwidth } : {}; 9685}; 9686var _a = function(r10) { 9687 var e; 9688 return (e = r10.match(/.*codecs\*?="(.*)"/)) === null || e === void 0 ? void 0 : e[1]; 9689}; 9690var fa = function(e) { 9691 try { 9692 var t2, i3, a2 = (i3 = e.getVersion) === null || i3 === void 0 || (t2 = i3.call(e)) === null || t2 === void 0 ? void 0 : t2.split(".").map(function(n2) { 9693 return parseInt(n2); 9694 })[0]; 9695 return a2; 9696 } catch (n2) { 9697 return false; 9698 } 9699}; 9700var Nt = function(r10, e, t2) { 9701 var i3 = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}, a2 = r10.log; 9702 if (!t2 || !t2.on) { 9703 a2.warn("Invalid dash.js player reference. Monitoring blocked."); 9704 return; 9705 } 9706 var n2 = fa(t2), o2 = function(_3, d2) { 9707 return r10.emit(e, _3, d2); 9708 }, s = function(_3) { 9709 var d2 = _3.type, y4 = _3.data, T3 = (y4 || {}).url; 9710 o2("requestcompleted", { request_event_type: d2, request_start: 0, request_response_start: 0, request_response_end: 0, request_bytes_loaded: -1, request_type: "manifest", request_hostname: F(T3), request_url: T3 }); 9711 }; 9712 t2.on("manifestLoaded", s); 9713 var u3 = {}, f = function(_3) { 9714 if (typeof _3.getRequests != "function") return null; 9715 var d2 = _3.getRequests({ state: "executed" }); 9716 return d2.length === 0 ? null : d2[d2.length - 1]; 9717 }, g = function(_3) { 9718 var d2 = _3.type, y4 = _3.fragmentModel, T3 = _3.chunk, E5 = f(y4); 9719 k3({ type: d2, request: E5, chunk: T3 }); 9720 }, k3 = function(_3) { 9721 var d2 = _3.type, y4 = _3.chunk, T3 = _3.request, E5 = (y4 || {}).mediaInfo, S3 = E5 || {}, L = S3.type, M4 = S3.bitrateList; 9722 M4 = M4 || []; 9723 var O2 = {}; 9724 M4.forEach(function(Ee5, z3) { 9725 O2[z3] = {}, O2[z3].width = Ee5.width, O2[z3].height = Ee5.height, O2[z3].bitrate = Ee5.bandwidth, O2[z3].attrs = {}; 9726 }), L === "video" ? u3.video = O2 : L === "audio" ? u3.audio = O2 : u3.media = O2; 9727 var q3 = Lt(T3, t2), Z4 = q3.requestStart, we4 = q3.requestResponseStart, Te4 = q3.requestResponseEnd, W4 = q3.requestResponseHeaders, oe5 = q3.requestMediaDuration, Ve4 = q3.requestHostname, je3 = q3.requestUrl, We3 = q3.requestId; 9728 o2("requestcompleted", { request_event_type: d2, request_start: Z4, request_response_start: we4, request_response_end: Te4, request_bytes_loaded: -1, request_type: L + "_init", request_response_headers: W4, request_hostname: Ve4, request_id: We3, request_url: je3, request_media_duration: oe5, request_rendition_lists: u3 }); 9729 }; 9730 n2 >= 4 ? t2.on("initFragmentLoaded", k3) : t2.on("initFragmentLoaded", g); 9731 var h3 = function(_3) { 9732 var d2 = _3.type, y4 = _3.fragmentModel, T3 = _3.chunk, E5 = f(y4); 9733 c3({ type: d2, request: E5, chunk: T3 }); 9734 }, c3 = function(_3) { 9735 var d2 = _3.type, y4 = _3.chunk, T3 = _3.request, E5 = y4 || {}, S3 = E5.mediaInfo, L = E5.start, M4 = S3 || {}, O2 = M4.type, q3 = Lt(T3, t2), Z4 = q3.requestStart, we4 = q3.requestResponseStart, Te4 = q3.requestResponseEnd, W4 = q3.requestBytesLoaded, oe5 = q3.requestResponseHeaders, Ve4 = q3.requestMediaDuration, je3 = q3.requestHostname, We3 = q3.requestUrl, Ee5 = q3.requestId, z3 = ca(O2, t2), Kr = z3.currentLevel, Yr = z3.renditionWidth, Xr = z3.renditionHeight, $r = z3.renditionBitrate; 9736 o2("requestcompleted", { request_event_type: d2, request_start: Z4, request_response_start: we4, request_response_end: Te4, request_bytes_loaded: W4, request_type: O2, request_response_headers: oe5, request_hostname: je3, request_id: Ee5, request_url: We3, request_media_start_time: L, request_media_duration: Ve4, request_current_level: Kr, request_labeled_bitrate: $r, request_video_width: Yr, request_video_height: Xr }); 9737 }; 9738 n2 >= 4 ? t2.on("mediaFragmentLoaded", c3) : t2.on("mediaFragmentLoaded", h3); 9739 var m2 = { video: void 0, audio: void 0, totalBitrate: void 0 }, w4 = function() { 9740 if (m2.video && typeof m2.video.bitrate == "number") { 9741 if (!(m2.video.width && m2.video.height)) { 9742 a2.warn("have bitrate info for video but missing width/height"); 9743 return; 9744 } 9745 var _3 = m2.video.bitrate; 9746 if (m2.audio && typeof m2.audio.bitrate == "number" && (_3 += m2.audio.bitrate), _3 !== m2.totalBitrate) return m2.totalBitrate = _3, { video_source_bitrate: _3, video_source_height: m2.video.height, video_source_width: m2.video.width, video_source_codec: _a(m2.video.codec) }; 9747 } 9748 }, x2 = function(_3, d2, y4) { 9749 if (typeof _3.newQuality != "number") { 9750 a2.warn("missing evt.newQuality in qualityChangeRendered event", _3); 9751 return; 9752 } 9753 var T3 = _3.mediaType; 9754 if (T3 === "audio" || T3 === "video") { 9755 var E5 = t2.getBitrateInfoListFor(T3).find(function(L) { 9756 var M4 = L.qualityIndex; 9757 return M4 === _3.newQuality; 9758 }); 9759 if (!(E5 && typeof E5.bitrate == "number")) { 9760 a2.warn("missing bitrate info for ".concat(T3)); 9761 return; 9762 } 9763 m2[T3] = fe(ue({}, E5), { codec: t2.getCurrentTrackFor(T3).codec }); 9764 var S3 = w4(); 9765 S3 && o2("renditionchange", S3); 9766 } 9767 }; 9768 t2.on("qualityChangeRendered", x2); 9769 var v2 = function(_3) { 9770 var d2 = _3.request, y4 = _3.mediaType; 9771 d2 = d2 || {}, o2("requestcanceled", { request_event_type: d2.type + "_" + d2.action, request_url: d2.url, request_type: y4, request_hostname: F(d2.url) }); 9772 }; 9773 t2.on("fragmentLoadingAbandoned", v2); 9774 var p3 = function(_3) { 9775 var d2 = _3.error, y4, T3, E5 = (d2 == null || (y4 = d2.data) === null || y4 === void 0 ? void 0 : y4.request) || {}, S3 = (d2 == null || (T3 = d2.data) === null || T3 === void 0 ? void 0 : T3.response) || {}; 9776 (d2 == null ? void 0 : d2.code) === 27 && o2("requestfailed", { request_error: E5.type + "_" + E5.action, request_url: E5.url, request_hostname: F(E5.url), request_type: E5.mediaType, request_error_code: S3.status, request_error_text: S3.statusText }); 9777 var L = "".concat(E5 != null && E5.url ? "url: ".concat(E5.url, "\n") : "") + "".concat(S3 != null && S3.status || S3 != null && S3.statusText ? "response: ".concat(S3 == null ? void 0 : S3.status, ", ").concat(S3 == null ? void 0 : S3.statusText, "\n") : ""); 9778 o2("error", { player_error_code: d2 == null ? void 0 : d2.code, player_error_message: d2 == null ? void 0 : d2.message, player_error_context: L }); 9779 }; 9780 t2.on("error", p3), t2._stopMuxMonitor = function() { 9781 t2.off("manifestLoaded", s), t2.off("initFragmentLoaded", k3), t2.off("mediaFragmentLoaded", c3), t2.off("qualityChangeRendered", x2), t2.off("error", p3), t2.off("fragmentLoadingAbandoned", v2), delete t2._stopMuxMonitor; 9782 }; 9783}; 9784var Ct = function(r10) { 9785 r10 && typeof r10._stopMuxMonitor == "function" && r10._stopMuxMonitor(); 9786}; 9787var Mt = 0; 9788var pa = function() { 9789 "use strict"; 9790 function r10() { 9791 D(this, r10), l(this, "_listeners", void 0); 9792 } 9793 return N(r10, [{ key: "on", value: function(t2, i3, a2) { 9794 return i3._eventEmitterGuid = i3._eventEmitterGuid || ++Mt, this._listeners = this._listeners || {}, this._listeners[t2] = this._listeners[t2] || [], a2 && (i3 = i3.bind(a2)), this._listeners[t2].push(i3), i3; 9795 } }, { key: "off", value: function(t2, i3) { 9796 var a2 = this._listeners && this._listeners[t2]; 9797 a2 && a2.forEach(function(n2, o2) { 9798 n2._eventEmitterGuid === i3._eventEmitterGuid && a2.splice(o2, 1); 9799 }); 9800 } }, { key: "one", value: function(t2, i3, a2) { 9801 var n2 = this; 9802 i3._eventEmitterGuid = i3._eventEmitterGuid || ++Mt; 9803 var o2 = function() { 9804 n2.off(t2, o2), i3.apply(a2 || this, arguments); 9805 }; 9806 o2._eventEmitterGuid = i3._eventEmitterGuid, this.on(t2, o2); 9807 } }, { key: "emit", value: function(t2, i3) { 9808 var a2 = this; 9809 if (this._listeners) { 9810 i3 = i3 || {}; 9811 var n2 = this._listeners["before" + t2] || [], o2 = this._listeners["before*"] || [], s = this._listeners[t2] || [], u3 = this._listeners["after" + t2] || [], f = function(g, k3) { 9812 g = g.slice(), g.forEach(function(h3) { 9813 h3.call(a2, { type: t2 }, k3); 9814 }); 9815 }; 9816 f(n2, i3), f(o2, i3), f(s, i3), f(u3, i3); 9817 } 9818 } }]), r10; 9819}(); 9820var Ht = pa; 9821var He = G(Q()); 9822var ma = function() { 9823 "use strict"; 9824 function r10(e) { 9825 var t2 = this; 9826 D(this, r10), l(this, "_playbackHeartbeatInterval", void 0), l(this, "_playheadShouldBeProgressing", void 0), l(this, "pm", void 0), this.pm = e, this._playbackHeartbeatInterval = null, this._playheadShouldBeProgressing = false, e.on("playing", function() { 9827 t2._playheadShouldBeProgressing = true; 9828 }), e.on("play", this._startPlaybackHeartbeatInterval.bind(this)), e.on("playing", this._startPlaybackHeartbeatInterval.bind(this)), e.on("adbreakstart", this._startPlaybackHeartbeatInterval.bind(this)), e.on("adplay", this._startPlaybackHeartbeatInterval.bind(this)), e.on("adplaying", this._startPlaybackHeartbeatInterval.bind(this)), e.on("devicewake", this._startPlaybackHeartbeatInterval.bind(this)), e.on("viewstart", this._startPlaybackHeartbeatInterval.bind(this)), e.on("rebufferstart", this._startPlaybackHeartbeatInterval.bind(this)), e.on("pause", this._stopPlaybackHeartbeatInterval.bind(this)), e.on("ended", this._stopPlaybackHeartbeatInterval.bind(this)), e.on("viewend", this._stopPlaybackHeartbeatInterval.bind(this)), e.on("error", this._stopPlaybackHeartbeatInterval.bind(this)), e.on("aderror", this._stopPlaybackHeartbeatInterval.bind(this)), e.on("adpause", this._stopPlaybackHeartbeatInterval.bind(this)), e.on("adended", this._stopPlaybackHeartbeatInterval.bind(this)), e.on("adbreakend", this._stopPlaybackHeartbeatInterval.bind(this)), e.on("seeked", function() { 9829 e.data.player_is_paused ? t2._stopPlaybackHeartbeatInterval() : t2._startPlaybackHeartbeatInterval(); 9830 }), e.on("timeupdate", function() { 9831 t2._playbackHeartbeatInterval !== null && e.emit("playbackheartbeat"); 9832 }), e.on("devicesleep", function(i3, a2) { 9833 t2._playbackHeartbeatInterval !== null && (He.default.clearInterval(t2._playbackHeartbeatInterval), e.emit("playbackheartbeatend", { viewer_time: a2.viewer_time }), t2._playbackHeartbeatInterval = null); 9834 }); 9835 } 9836 return N(r10, [{ key: "_startPlaybackHeartbeatInterval", value: function() { 9837 var t2 = this; 9838 this._playbackHeartbeatInterval === null && (this.pm.emit("playbackheartbeat"), this._playbackHeartbeatInterval = He.default.setInterval(function() { 9839 t2.pm.emit("playbackheartbeat"); 9840 }, this.pm.playbackHeartbeatTime)); 9841 } }, { key: "_stopPlaybackHeartbeatInterval", value: function() { 9842 this._playheadShouldBeProgressing = false, this._playbackHeartbeatInterval !== null && (He.default.clearInterval(this._playbackHeartbeatInterval), this.pm.emit("playbackheartbeatend"), this._playbackHeartbeatInterval = null); 9843 } }]), r10; 9844}(); 9845var Bt = ma; 9846var va = function r(e) { 9847 "use strict"; 9848 var t2 = this; 9849 D(this, r), l(this, "viewErrored", void 0), e.on("viewinit", function() { 9850 t2.viewErrored = false; 9851 }), e.on("error", function(i3, a2) { 9852 try { 9853 var n2 = e.errorTranslator({ player_error_code: a2.player_error_code, player_error_message: a2.player_error_message, player_error_context: a2.player_error_context, player_error_severity: a2.player_error_severity, player_error_business_exception: a2.player_error_business_exception }); 9854 n2 && (e.data.player_error_code = n2.player_error_code || a2.player_error_code, e.data.player_error_message = n2.player_error_message || a2.player_error_message, e.data.player_error_context = n2.player_error_context || a2.player_error_context, e.data.player_error_severity = n2.player_error_severity || a2.player_error_severity, e.data.player_error_business_exception = n2.player_error_business_exception || a2.player_error_business_exception, t2.viewErrored = true); 9855 } catch (o2) { 9856 e.mux.log.warn("Exception in error translator callback.", o2), t2.viewErrored = true; 9857 } 9858 }), e.on("aftererror", function() { 9859 var i3, a2, n2, o2, s; 9860 (i3 = e.data) === null || i3 === void 0 || delete i3.player_error_code, (a2 = e.data) === null || a2 === void 0 || delete a2.player_error_message, (n2 = e.data) === null || n2 === void 0 || delete n2.player_error_context, (o2 = e.data) === null || o2 === void 0 || delete o2.player_error_severity, (s = e.data) === null || s === void 0 || delete s.player_error_business_exception; 9861 }); 9862}; 9863var Ut = va; 9864var ha = function() { 9865 "use strict"; 9866 function r10(e) { 9867 D(this, r10), l(this, "_watchTimeTrackerLastCheckedTime", void 0), l(this, "pm", void 0), this.pm = e, this._watchTimeTrackerLastCheckedTime = null, e.on("playbackheartbeat", this._updateWatchTime.bind(this)), e.on("playbackheartbeatend", this._clearWatchTimeState.bind(this)); 9868 } 9869 return N(r10, [{ key: "_updateWatchTime", value: function(t2, i3) { 9870 var a2 = i3.viewer_time; 9871 this._watchTimeTrackerLastCheckedTime === null && (this._watchTimeTrackerLastCheckedTime = a2), P(this.pm.data, "view_watch_time", a2 - this._watchTimeTrackerLastCheckedTime), this._watchTimeTrackerLastCheckedTime = a2; 9872 } }, { key: "_clearWatchTimeState", value: function(t2, i3) { 9873 this._updateWatchTime(t2, i3), this._watchTimeTrackerLastCheckedTime = null; 9874 } }]), r10; 9875}(); 9876var Ft = ha; 9877var ya = function() { 9878 "use strict"; 9879 function r10(e) { 9880 var t2 = this; 9881 D(this, r10), l(this, "_playbackTimeTrackerLastPlayheadPosition", void 0), l(this, "_lastTime", void 0), l(this, "_isAdPlaying", void 0), l(this, "_callbackUpdatePlaybackTime", void 0), l(this, "pm", void 0), this.pm = e, this._playbackTimeTrackerLastPlayheadPosition = -1, this._lastTime = A.now(), this._isAdPlaying = false, this._callbackUpdatePlaybackTime = null, e.on("viewinit", function() { 9882 t2.pm.data.view_playing_time_ms_cumulative = 0; 9883 }); 9884 var i3 = this._startPlaybackTimeTracking.bind(this); 9885 e.on("playing", i3), e.on("adplaying", i3), e.on("seeked", i3), e.on("rebufferend", i3); 9886 var a2 = this._stopPlaybackTimeTracking.bind(this); 9887 e.on("playbackheartbeatend", a2), e.on("seeking", a2), e.on("rebufferstart", a2), e.on("adplaying", function() { 9888 t2._isAdPlaying = true; 9889 }), e.on("adended", function() { 9890 t2._isAdPlaying = false; 9891 }), e.on("adpause", function() { 9892 t2._isAdPlaying = false; 9893 }), e.on("adbreakstart", function() { 9894 t2._isAdPlaying = false; 9895 }), e.on("adbreakend", function() { 9896 t2._isAdPlaying = false; 9897 }), e.on("adplay", function() { 9898 t2._isAdPlaying = false; 9899 }), e.on("viewinit", function() { 9900 t2._playbackTimeTrackerLastPlayheadPosition = -1, t2._lastTime = A.now(), t2._isAdPlaying = false, t2._callbackUpdatePlaybackTime = null; 9901 }); 9902 } 9903 return N(r10, [{ key: "_startPlaybackTimeTracking", value: function() { 9904 this._callbackUpdatePlaybackTime === null && (this._callbackUpdatePlaybackTime = this._updatePlaybackTime.bind(this), this._playbackTimeTrackerLastPlayheadPosition = this.pm.data.player_playhead_time, this._lastTime = A.now(), this.pm.on("playbackheartbeat", this._callbackUpdatePlaybackTime)); 9905 } }, { key: "_stopPlaybackTimeTracking", value: function() { 9906 this._callbackUpdatePlaybackTime && (this._updatePlaybackTime(), this.pm.off("playbackheartbeat", this._callbackUpdatePlaybackTime), this._callbackUpdatePlaybackTime = null, this._playbackTimeTrackerLastPlayheadPosition = -1); 9907 } }, { key: "_updatePlaybackTime", value: function() { 9908 var t2 = this.pm.data.player_playhead_time || 0, i3 = A.now(), a2 = i3 - this._lastTime, n2 = -1; 9909 this._playbackTimeTrackerLastPlayheadPosition >= 0 && t2 > this._playbackTimeTrackerLastPlayheadPosition ? n2 = t2 - this._playbackTimeTrackerLastPlayheadPosition : this._isAdPlaying && (n2 = a2), n2 > 0 && n2 <= 1e3 && P(this.pm.data, "view_content_playback_time", n2), this._callbackUpdatePlaybackTime !== null && a2 > 0 && a2 <= 1e3 && (this._isAdPlaying && P(this.pm.data, "ad_playing_time_ms_cumulative", a2), P(this.pm.data, "view_playing_time_ms_cumulative", a2)), this._playbackTimeTrackerLastPlayheadPosition = t2, this._lastTime = i3; 9910 } }]), r10; 9911}(); 9912var Vt = ya; 9913var ga = function() { 9914 "use strict"; 9915 function r10(e) { 9916 D(this, r10), l(this, "pm", void 0), this.pm = e; 9917 var t2 = this._updatePlayheadTime.bind(this); 9918 e.on("playbackheartbeat", t2), e.on("playbackheartbeatend", t2), e.on("timeupdate", t2), e.on("destroy", function() { 9919 e.off("timeupdate", t2); 9920 }); 9921 } 9922 return N(r10, [{ key: "_updateMaxPlayheadPosition", value: function() { 9923 this.pm.data.view_max_playhead_position = typeof this.pm.data.view_max_playhead_position == "undefined" ? this.pm.data.player_playhead_time : Math.max(this.pm.data.view_max_playhead_position, this.pm.data.player_playhead_time); 9924 } }, { key: "_updatePlayheadTime", value: function(t2, i3) { 9925 var a2 = this, n2 = function() { 9926 a2.pm.currentFragmentPDT && a2.pm.currentFragmentStart && (a2.pm.data.player_program_time = a2.pm.currentFragmentPDT + a2.pm.data.player_playhead_time - a2.pm.currentFragmentStart); 9927 }; 9928 if (i3 && i3.player_playhead_time) this.pm.data.player_playhead_time = i3.player_playhead_time, n2(), this._updateMaxPlayheadPosition(); 9929 else if (this.pm.getPlayheadTime) { 9930 var o2 = this.pm.getPlayheadTime(); 9931 typeof o2 != "undefined" && (this.pm.data.player_playhead_time = o2, n2(), this._updateMaxPlayheadPosition()); 9932 } 9933 } }]), r10; 9934}(); 9935var jt = ga; 9936var Wt = 5 * 60 * 1e3; 9937var ba = function r2(e) { 9938 "use strict"; 9939 if (D(this, r2), !e.disableRebufferTracking) { 9940 var t2, i3 = function(n2, o2) { 9941 a2(o2), t2 = void 0; 9942 }, a2 = function(n2) { 9943 if (t2) { 9944 var o2 = n2.viewer_time - t2; 9945 P(e.data, "view_rebuffer_duration", o2), t2 = n2.viewer_time, e.data.view_rebuffer_duration > Wt && (e.emit("viewend"), e.send("viewend"), e.mux.log.warn("Ending view after rebuffering for longer than ".concat(Wt, "ms, future events will be ignored unless a programchange or videochange occurs."))); 9946 } 9947 e.data.view_watch_time >= 0 && e.data.view_rebuffer_count > 0 && (e.data.view_rebuffer_frequency = e.data.view_rebuffer_count / e.data.view_watch_time, e.data.view_rebuffer_percentage = e.data.view_rebuffer_duration / e.data.view_watch_time); 9948 }; 9949 e.on("playbackheartbeat", function(n2, o2) { 9950 return a2(o2); 9951 }), e.on("rebufferstart", function(n2, o2) { 9952 t2 || (P(e.data, "view_rebuffer_count", 1), t2 = o2.viewer_time, e.one("rebufferend", i3)); 9953 }), e.on("viewinit", function() { 9954 t2 = void 0, e.off("rebufferend", i3); 9955 }); 9956 } 9957}; 9958var Gt = ba; 9959var wa = function() { 9960 "use strict"; 9961 function r10(e) { 9962 var t2 = this; 9963 D(this, r10), l(this, "_lastCheckedTime", void 0), l(this, "_lastPlayheadTime", void 0), l(this, "_lastPlayheadTimeUpdatedTime", void 0), l(this, "_rebuffering", void 0), l(this, "pm", void 0), this.pm = e, !(e.disableRebufferTracking || e.disablePlayheadRebufferTracking) && (this._lastCheckedTime = null, this._lastPlayheadTime = null, this._lastPlayheadTimeUpdatedTime = null, e.on("playbackheartbeat", this._checkIfRebuffering.bind(this)), e.on("playbackheartbeatend", this._cleanupRebufferTracker.bind(this)), e.on("seeking", function() { 9964 t2._cleanupRebufferTracker(null, { viewer_time: A.now() }); 9965 })); 9966 } 9967 return N(r10, [{ key: "_checkIfRebuffering", value: function(t2, i3) { 9968 if (this.pm.seekingTracker.isSeeking || this.pm.adTracker.isAdBreak || !this.pm.playbackHeartbeat._playheadShouldBeProgressing) { 9969 this._cleanupRebufferTracker(t2, i3); 9970 return; 9971 } 9972 if (this._lastCheckedTime === null) { 9973 this._prepareRebufferTrackerState(i3.viewer_time); 9974 return; 9975 } 9976 if (this._lastPlayheadTime !== this.pm.data.player_playhead_time) { 9977 this._cleanupRebufferTracker(t2, i3, true); 9978 return; 9979 } 9980 var a2 = i3.viewer_time - this._lastPlayheadTimeUpdatedTime; 9981 typeof this.pm.sustainedRebufferThreshold == "number" && a2 >= this.pm.sustainedRebufferThreshold && (this._rebuffering || (this._rebuffering = true, this.pm.emit("rebufferstart", { viewer_time: this._lastPlayheadTimeUpdatedTime }))), this._lastCheckedTime = i3.viewer_time; 9982 } }, { key: "_clearRebufferTrackerState", value: function() { 9983 this._lastCheckedTime = null, this._lastPlayheadTime = null, this._lastPlayheadTimeUpdatedTime = null; 9984 } }, { key: "_prepareRebufferTrackerState", value: function(t2) { 9985 this._lastCheckedTime = t2, this._lastPlayheadTime = this.pm.data.player_playhead_time, this._lastPlayheadTimeUpdatedTime = t2; 9986 } }, { key: "_cleanupRebufferTracker", value: function(t2, i3) { 9987 var a2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false; 9988 if (this._rebuffering) this._rebuffering = false, this.pm.emit("rebufferend", { viewer_time: i3.viewer_time }); 9989 else { 9990 if (this._lastCheckedTime === null) return; 9991 var n2 = this.pm.data.player_playhead_time - this._lastPlayheadTime, o2 = i3.viewer_time - this._lastPlayheadTimeUpdatedTime; 9992 typeof this.pm.minimumRebufferDuration == "number" && n2 > 0 && o2 - n2 > this.pm.minimumRebufferDuration && (this._lastCheckedTime = null, this.pm.emit("rebufferstart", { viewer_time: this._lastPlayheadTimeUpdatedTime }), this.pm.emit("rebufferend", { viewer_time: this._lastPlayheadTimeUpdatedTime + o2 - n2 })); 9993 } 9994 a2 ? this._prepareRebufferTrackerState(i3.viewer_time) : this._clearRebufferTrackerState(); 9995 } }]), r10; 9996}(); 9997var Jt = wa; 9998var Ta = function() { 9999 "use strict"; 10000 function r10(e) { 10001 var t2 = this; 10002 D(this, r10), l(this, "pm", void 0), this.pm = e, e.on("viewinit", function() { 10003 var i3 = e.data, a2 = i3.view_id; 10004 if (!i3.view_program_changed) { 10005 var n2 = function(o2, s) { 10006 var u3 = s.viewer_time; 10007 o2.type === "playing" && typeof e.data.view_time_to_first_frame == "undefined" ? t2.calculateTimeToFirstFrame(u3 || A.now(), a2) : o2.type === "adplaying" && (typeof e.data.view_time_to_first_frame == "undefined" || t2._inPrerollPosition()) && t2.calculateTimeToFirstFrame(u3 || A.now(), a2); 10008 }; 10009 e.one("playing", n2), e.one("adplaying", n2), e.one("viewend", function() { 10010 e.off("playing", n2), e.off("adplaying", n2); 10011 }); 10012 } 10013 }); 10014 } 10015 return N(r10, [{ key: "_inPrerollPosition", value: function() { 10016 return typeof this.pm.data.view_content_playback_time == "undefined" || this.pm.data.view_content_playback_time <= 1e3; 10017 } }, { key: "calculateTimeToFirstFrame", value: function(t2, i3) { 10018 i3 === this.pm.data.view_id && (this.pm.watchTimeTracker._updateWatchTime(null, { viewer_time: t2 }), this.pm.data.view_time_to_first_frame = this.pm.data.view_watch_time, (this.pm.data.player_autoplay_on || this.pm.data.video_is_autoplay) && this.pm.pageLoadInitTime && (this.pm.data.view_aggregate_startup_time = this.pm.data.view_start + this.pm.data.view_watch_time - this.pm.pageLoadInitTime)); 10019 } }]), r10; 10020}(); 10021var Qt = Ta; 10022var Ea = function r3(e) { 10023 "use strict"; 10024 var t2 = this; 10025 D(this, r3), l(this, "_lastPlayerHeight", void 0), l(this, "_lastPlayerWidth", void 0), l(this, "_lastPlayheadPosition", void 0), l(this, "_lastSourceHeight", void 0), l(this, "_lastSourceWidth", void 0), e.on("viewinit", function() { 10026 t2._lastPlayheadPosition = -1; 10027 }); 10028 var i3 = ["pause", "rebufferstart", "seeking", "error", "adbreakstart", "hb", "renditionchange", "orientationchange", "viewend", "playbackmodechange"], a2 = ["playing", "hb", "renditionchange", "orientationchange", "playbackmodechange"]; 10029 i3.forEach(function(n2) { 10030 e.on(n2, function() { 10031 if (t2._lastPlayheadPosition >= 0 && e.data.player_playhead_time >= 0 && t2._lastPlayerWidth >= 0 && t2._lastSourceWidth > 0 && t2._lastPlayerHeight >= 0 && t2._lastSourceHeight > 0) { 10032 var o2 = e.data.player_playhead_time - t2._lastPlayheadPosition; 10033 if (o2 < 0) { 10034 t2._lastPlayheadPosition = -1; 10035 return; 10036 } 10037 var s = Math.min(t2._lastPlayerWidth / t2._lastSourceWidth, t2._lastPlayerHeight / t2._lastSourceHeight), u3 = Math.max(0, s - 1), f = Math.max(0, 1 - s); 10038 e.data.view_max_upscale_percentage = Math.max(e.data.view_max_upscale_percentage || 0, u3), e.data.view_max_downscale_percentage = Math.max(e.data.view_max_downscale_percentage || 0, f), P(e.data, "view_total_content_playback_time", o2), P(e.data, "view_total_upscaling", u3 * o2), P(e.data, "view_total_downscaling", f * o2); 10039 } 10040 t2._lastPlayheadPosition = -1; 10041 }); 10042 }), a2.forEach(function(n2) { 10043 e.on(n2, function() { 10044 t2._lastPlayheadPosition = e.data.player_playhead_time, t2._lastPlayerWidth = e.data.player_width, t2._lastPlayerHeight = e.data.player_height, t2._lastSourceWidth = e.data.video_source_width, t2._lastSourceHeight = e.data.video_source_height; 10045 }); 10046 }); 10047}; 10048var zt = Ea; 10049var ka = 2e3; 10050var xa = function r4(e) { 10051 "use strict"; 10052 var t2 = this; 10053 D(this, r4), l(this, "isSeeking", void 0), this.isSeeking = false; 10054 var i3 = -1, a2 = function() { 10055 var n2 = A.now(), o2 = (e.data.viewer_time || n2) - (i3 || n2); 10056 P(e.data, "view_seek_duration", o2), e.data.view_max_seek_time = Math.max(e.data.view_max_seek_time || 0, o2), t2.isSeeking = false, i3 = -1; 10057 }; 10058 e.on("seeking", function(n2, o2) { 10059 if (Object.assign(e.data, o2), t2.isSeeking && o2.viewer_time - i3 <= ka) { 10060 i3 = o2.viewer_time; 10061 return; 10062 } 10063 t2.isSeeking && a2(), t2.isSeeking = true, i3 = o2.viewer_time, P(e.data, "view_seek_count", 1), e.send("seeking"); 10064 }), e.on("seeked", function() { 10065 a2(); 10066 }), e.on("viewend", function() { 10067 t2.isSeeking && (a2(), e.send("seeked")), t2.isSeeking = false, i3 = -1; 10068 }); 10069}; 10070var Kt = xa; 10071var Yt = function(e, t2) { 10072 e.push(t2), e.sort(function(i3, a2) { 10073 return i3.viewer_time - a2.viewer_time; 10074 }); 10075}; 10076var Da = ["adbreakstart", "adrequest", "adresponse", "adplay", "adplaying", "adpause", "adended", "adbreakend", "aderror", "adclicked", "adskipped"]; 10077var Sa = function() { 10078 "use strict"; 10079 function r10(e) { 10080 var t2 = this; 10081 D(this, r10), l(this, "_adHasPlayed", void 0), l(this, "_adRequests", void 0), l(this, "_adResponses", void 0), l(this, "_currentAdRequestNumber", void 0), l(this, "_currentAdResponseNumber", void 0), l(this, "_prerollPlayTime", void 0), l(this, "_wouldBeNewAdPlay", void 0), l(this, "isAdBreak", void 0), l(this, "pm", void 0), this.pm = e, e.on("viewinit", function() { 10082 t2.isAdBreak = false, t2._currentAdRequestNumber = 0, t2._currentAdResponseNumber = 0, t2._adRequests = [], t2._adResponses = [], t2._adHasPlayed = false, t2._wouldBeNewAdPlay = true, t2._prerollPlayTime = void 0; 10083 }), Da.forEach(function(a2) { 10084 return e.on(a2, t2._updateAdData.bind(t2)); 10085 }); 10086 var i3 = function() { 10087 t2.isAdBreak = false; 10088 }; 10089 e.on("adbreakstart", function() { 10090 t2.isAdBreak = true; 10091 }), e.on("play", i3), e.on("playing", i3), e.on("viewend", i3), e.on("adrequest", function(a2, n2) { 10092 n2 = Object.assign({ ad_request_id: "generatedAdRequestId" + t2._currentAdRequestNumber++ }, n2), Yt(t2._adRequests, n2), P(e.data, "view_ad_request_count"), t2.inPrerollPosition() && (e.data.view_preroll_requested = true, t2._adHasPlayed || P(e.data, "view_preroll_request_count")); 10093 }), e.on("adresponse", function(a2, n2) { 10094 n2 = Object.assign({ ad_request_id: "generatedAdRequestId" + t2._currentAdResponseNumber++ }, n2), Yt(t2._adResponses, n2); 10095 var o2 = t2.findAdRequest(n2.ad_request_id); 10096 o2 && P(e.data, "view_ad_request_time", Math.max(0, n2.viewer_time - o2.viewer_time)); 10097 }), e.on("adplay", function(a2, n2) { 10098 t2._adHasPlayed = true, t2._wouldBeNewAdPlay && (t2._wouldBeNewAdPlay = false, P(e.data, "view_ad_played_count")), t2.inPrerollPosition() && !e.data.view_preroll_played && (e.data.view_preroll_played = true, t2._adRequests.length > 0 && (e.data.view_preroll_request_time = Math.max(0, n2.viewer_time - t2._adRequests[0].viewer_time)), e.data.view_start && (e.data.view_startup_preroll_request_time = Math.max(0, n2.viewer_time - e.data.view_start)), t2._prerollPlayTime = n2.viewer_time); 10099 }), e.on("adplaying", function(a2, n2) { 10100 t2.inPrerollPosition() && typeof e.data.view_preroll_load_time == "undefined" && typeof t2._prerollPlayTime != "undefined" && (e.data.view_preroll_load_time = n2.viewer_time - t2._prerollPlayTime, e.data.view_startup_preroll_load_time = n2.viewer_time - t2._prerollPlayTime); 10101 }), e.on("adclicked", function(a2, n2) { 10102 t2._wouldBeNewAdPlay || P(e.data, "view_ad_clicked_count"); 10103 }), e.on("adskipped", function(a2, n2) { 10104 t2._wouldBeNewAdPlay || P(e.data, "view_ad_skipped_count"); 10105 }), e.on("adended", function() { 10106 t2._wouldBeNewAdPlay = true; 10107 }), e.on("aderror", function() { 10108 t2._wouldBeNewAdPlay = true; 10109 }); 10110 } 10111 return N(r10, [{ key: "inPrerollPosition", value: function() { 10112 return typeof this.pm.data.view_content_playback_time == "undefined" || this.pm.data.view_content_playback_time <= 1e3; 10113 } }, { key: "findAdRequest", value: function(t2) { 10114 for (var i3 = 0; i3 < this._adRequests.length; i3++) if (this._adRequests[i3].ad_request_id === t2) return this._adRequests[i3]; 10115 } }, { key: "_updateAdData", value: function(t2, i3) { 10116 if (this.inPrerollPosition()) { 10117 if (!this.pm.data.view_preroll_ad_tag_hostname && i3.ad_tag_url) { 10118 var a2 = H(re(i3.ad_tag_url), 2), n2 = a2[0], o2 = a2[1]; 10119 this.pm.data.view_preroll_ad_tag_domain = o2, this.pm.data.view_preroll_ad_tag_hostname = n2; 10120 } 10121 if (!this.pm.data.view_preroll_ad_asset_hostname && i3.ad_asset_url) { 10122 var s = H(re(i3.ad_asset_url), 2), u3 = s[0], f = s[1]; 10123 this.pm.data.view_preroll_ad_asset_domain = f, this.pm.data.view_preroll_ad_asset_hostname = u3; 10124 } 10125 this.pm.data.ad_type = "preroll"; 10126 } 10127 this.pm.data.ad_asset_url = i3 == null ? void 0 : i3.ad_asset_url, this.pm.data.ad_tag_url = i3 == null ? void 0 : i3.ad_tag_url, this.pm.data.ad_creative_id = i3 == null ? void 0 : i3.ad_creative_id, this.pm.data.ad_id = i3 == null ? void 0 : i3.ad_id, this.pm.data.ad_universal_id = i3 == null ? void 0 : i3.ad_universal_id, i3 != null && i3.ad_type && (this.pm.data.ad_type = i3 == null ? void 0 : i3.ad_type); 10128 } }]), r10; 10129}(); 10130var Xt = Sa; 10131var qa = function r5(e) { 10132 "use strict"; 10133 var t2 = this; 10134 D(this, r5), l(this, "lastWallClockTime", void 0); 10135 var i3 = function() { 10136 t2.lastWallClockTime = A.now(), e.on("before*", a2); 10137 }, a2 = function(n2) { 10138 var o2 = A.now(), s = t2.lastWallClockTime; 10139 t2.lastWallClockTime = o2, o2 - s > 3e4 && (e.emit("devicesleep", { viewer_time: s }), Object.assign(e.data, { viewer_time: s }), e.send("devicesleep"), e.emit("devicewake", { viewer_time: o2 }), Object.assign(e.data, { viewer_time: o2 }), e.send("devicewake")); 10140 }; 10141 e.one("playbackheartbeat", i3), e.on("playbackheartbeatend", function() { 10142 e.off("before*", a2), e.one("playbackheartbeat", i3); 10143 }); 10144}; 10145var $t = qa; 10146var Ue = G(Q()); 10147var Qe = function(r10) { 10148 return r10(); 10149}(function() { 10150 var r10 = function() { 10151 for (var i3 = 0, a2 = {}; i3 < arguments.length; i3++) { 10152 var n2 = arguments[i3]; 10153 for (var o2 in n2) a2[o2] = n2[o2]; 10154 } 10155 return a2; 10156 }; 10157 function e(t2) { 10158 function i3(a2, n2, o2) { 10159 var s; 10160 if (typeof document != "undefined") { 10161 if (arguments.length > 1) { 10162 if (o2 = r10({ path: "/" }, i3.defaults, o2), typeof o2.expires == "number") { 10163 var u3 = /* @__PURE__ */ new Date(); 10164 u3.setMilliseconds(u3.getMilliseconds() + o2.expires * 864e5), o2.expires = u3; 10165 } 10166 try { 10167 s = JSON.stringify(n2), /^[\{\[]/.test(s) && (n2 = s); 10168 } catch (w4) { 10169 } 10170 return t2.write ? n2 = t2.write(n2, a2) : n2 = encodeURIComponent(String(n2)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent), a2 = encodeURIComponent(String(a2)), a2 = a2.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent), a2 = a2.replace(/[\(\)]/g, escape), document.cookie = [a2, "=", n2, o2.expires ? "; expires=" + o2.expires.toUTCString() : "", o2.path ? "; path=" + o2.path : "", o2.domain ? "; domain=" + o2.domain : "", o2.secure ? "; secure" : ""].join(""); 10171 } 10172 a2 || (s = {}); 10173 for (var f = document.cookie ? document.cookie.split("; ") : [], g = /(%[0-9A-Z]{2})+/g, k3 = 0; k3 < f.length; k3++) { 10174 var h3 = f[k3].split("="), c3 = h3.slice(1).join("="); 10175 c3.charAt(0) === '"' && (c3 = c3.slice(1, -1)); 10176 try { 10177 var m2 = h3[0].replace(g, decodeURIComponent); 10178 if (c3 = t2.read ? t2.read(c3, m2) : t2(c3, m2) || c3.replace(g, decodeURIComponent), this.json) try { 10179 c3 = JSON.parse(c3); 10180 } catch (w4) { 10181 } 10182 if (a2 === m2) { 10183 s = c3; 10184 break; 10185 } 10186 a2 || (s[m2] = c3); 10187 } catch (w4) { 10188 } 10189 } 10190 return s; 10191 } 10192 } 10193 return i3.set = i3, i3.get = function(a2) { 10194 return i3.call(i3, a2); 10195 }, i3.getJSON = function() { 10196 return i3.apply({ json: true }, [].slice.call(arguments)); 10197 }, i3.defaults = {}, i3.remove = function(a2, n2) { 10198 i3(a2, "", r10(n2, { expires: -1 })); 10199 }, i3.withConverter = e, i3; 10200 } 10201 return e(function() { 10202 }); 10203}); 10204var Zt = "muxData"; 10205var Ra = function(r10) { 10206 return Object.entries(r10).map(function(e) { 10207 var t2 = H(e, 2), i3 = t2[0], a2 = t2[1]; 10208 return "".concat(i3, "=").concat(a2); 10209 }).join("&"); 10210}; 10211var Aa = function(r10) { 10212 return r10.split("&").reduce(function(e, t2) { 10213 var i3 = H(t2.split("="), 2), a2 = i3[0], n2 = i3[1], o2 = +n2, s = n2 && o2 == n2 ? o2 : n2; 10214 return e[a2] = s, e; 10215 }, {}); 10216}; 10217var er = function() { 10218 var e; 10219 try { 10220 e = Aa(Qe.get(Zt) || ""); 10221 } catch (t2) { 10222 e = {}; 10223 } 10224 return e; 10225}; 10226var tr = function(e) { 10227 try { 10228 Qe.set(Zt, Ra(e), { expires: 365 }); 10229 } catch (t2) { 10230 } 10231}; 10232var rr = function() { 10233 var e = er(); 10234 return e.mux_viewer_id = e.mux_viewer_id || ee(), e.msn = e.msn || Math.random(), tr(e), { mux_viewer_id: e.mux_viewer_id, mux_sample_number: e.msn }; 10235}; 10236var ar = function() { 10237 var e = er(), t2 = A.now(); 10238 return e.session_start && (e.sst = e.session_start, delete e.session_start), e.session_id && (e.sid = e.session_id, delete e.session_id), e.session_expires && (e.sex = e.session_expires, delete e.session_expires), (!e.sex || e.sex < t2) && (e.sid = ee(), e.sst = t2), e.sex = t2 + 25 * 60 * 1e3, tr(e), { session_id: e.sid, session_start: e.sst, session_expires: e.sex }; 10239}; 10240function ze(r10, e) { 10241 var t2 = e.beaconCollectionDomain, i3 = e.beaconDomain; 10242 if (t2) return "https://" + t2; 10243 r10 = r10 || "inferred"; 10244 var a2 = i3 || "litix.io"; 10245 return r10.match(/^[a-z0-9]+$/) ? "https://" + r10 + "." + a2 : "https://img.litix.io/a.gif"; 10246} 10247var ir = G(Q()); 10248var nr = function() { 10249 var e; 10250 switch (or()) { 10251 case "cellular": 10252 e = "cellular"; 10253 break; 10254 case "ethernet": 10255 e = "wired"; 10256 break; 10257 case "wifi": 10258 e = "wifi"; 10259 break; 10260 case void 0: 10261 break; 10262 default: 10263 e = "other"; 10264 } 10265 return e; 10266}; 10267var or = function() { 10268 var e = ir.default.navigator, t2 = e && (e.connection || e.mozConnection || e.webkitConnection); 10269 return t2 && t2.type; 10270}; 10271nr.getConnectionFromAPI = or; 10272var sr = nr; 10273var Pa = { a: "env", b: "beacon", c: "custom", d: "ad", e: "event", f: "experiment", i: "internal", m: "mux", n: "response", p: "player", q: "request", r: "retry", s: "session", t: "timestamp", u: "viewer", v: "video", w: "page", x: "view", y: "sub" }; 10274var Oa = dr(Pa); 10275var Ia = { ad: "ad", af: "affiliate", ag: "aggregate", ap: "api", al: "application", ao: "audio", ar: "architecture", as: "asset", au: "autoplay", av: "average", bi: "bitrate", bn: "brand", br: "break", bw: "browser", by: "bytes", bz: "business", ca: "cached", cb: "cancel", cc: "codec", cd: "code", cg: "category", ch: "changed", ci: "client", ck: "clicked", cl: "canceled", cm: "cmcd", cn: "config", co: "count", ce: "counter", cp: "complete", cq: "creator", cr: "creative", cs: "captions", ct: "content", cu: "current", cv: "cumulative", cx: "connection", cz: "context", da: "data", dg: "downscaling", dm: "domain", dn: "cdn", do: "downscale", dr: "drm", dp: "dropped", du: "duration", dv: "device", dy: "dynamic", eb: "enabled", ec: "encoding", ed: "edge", en: "end", eg: "engine", em: "embed", er: "error", ep: "experiments", es: "errorcode", et: "errortext", ee: "event", ev: "events", ex: "expires", ez: "exception", fa: "failed", fi: "first", fm: "family", ft: "format", fp: "fps", fq: "frequency", fr: "frame", fs: "fullscreen", ha: "has", hb: "holdback", he: "headers", ho: "host", hn: "hostname", ht: "height", id: "id", ii: "init", in: "instance", ip: "ip", is: "is", ke: "key", la: "language", lb: "labeled", le: "level", li: "live", ld: "loaded", lo: "load", ls: "lists", lt: "latency", ma: "max", md: "media", me: "message", mf: "manifest", mi: "mime", ml: "midroll", mm: "min", mn: "manufacturer", mo: "model", mp: "mode", ms: "ms", mx: "mux", ne: "newest", nm: "name", no: "number", on: "on", or: "origin", os: "os", pa: "paused", pb: "playback", pd: "producer", pe: "percentage", pf: "played", pg: "program", ph: "playhead", pi: "plugin", pl: "preroll", pn: "playing", po: "poster", pp: "pip", pr: "preload", ps: "position", pt: "part", pv: "previous", py: "property", px: "pop", pz: "plan", ra: "rate", rd: "requested", re: "rebuffer", rf: "rendition", rg: "range", rm: "remote", ro: "ratio", rp: "response", rq: "request", rs: "requests", sa: "sample", sd: "skipped", se: "session", sh: "shift", sk: "seek", sm: "stream", so: "source", sq: "sequence", sr: "series", ss: "status", st: "start", su: "startup", sv: "server", sw: "software", sy: "severity", ta: "tag", tc: "tech", te: "text", tg: "target", th: "throughput", ti: "time", tl: "total", to: "to", tt: "title", ty: "type", ug: "upscaling", un: "universal", up: "upscale", ur: "url", us: "user", va: "variant", vd: "viewed", vi: "video", ve: "version", vw: "view", vr: "viewer", wd: "width", wa: "watch", wt: "waiting" }; 10276var ur = dr(Ia); 10277function dr(r10) { 10278 var e = {}; 10279 for (var t2 in r10) r10.hasOwnProperty(t2) && (e[r10[t2]] = t2); 10280 return e; 10281} 10282function me(r10) { 10283 var e = {}, t2 = {}; 10284 return Object.keys(r10).forEach(function(i3) { 10285 var a2 = false; 10286 if (r10.hasOwnProperty(i3) && r10[i3] !== void 0) { 10287 var n2 = i3.split("_"), o2 = n2[0], s = Oa[o2]; 10288 s || (R.info("Data key word `" + n2[0] + "` not expected in " + i3), s = o2 + "_"), n2.splice(1).forEach(function(u3) { 10289 u3 === "url" && (a2 = true), ur[u3] ? s += ur[u3] : Number.isInteger(Number(u3)) ? s += u3 : (R.info("Data key word `" + u3 + "` not expected in " + i3), s += "_" + u3 + "_"); 10290 }), a2 ? t2[s] = r10[i3] : e[s] = r10[i3]; 10291 } 10292 }), Object.assign(e, t2); 10293} 10294var ie = G(Q()); 10295var Nr = G(it()); 10296var ni = { maxBeaconSize: 300, maxQueueLength: 3600, baseTimeBetweenBeacons: 1e4, maxPayloadKBSize: 500 }; 10297var oi = 56 * 1024; 10298var si = ["hb", "requestcompleted", "requestfailed", "requestcanceled"]; 10299var ui = "https://img.litix.io"; 10300var $ = function(e) { 10301 var t2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; 10302 this._beaconUrl = e || ui, this._eventQueue = [], this._postInFlight = false, this._resendAfterPost = false, this._failureCount = 0, this._sendTimeout = false, this._options = Object.assign({}, ni, t2); 10303}; 10304$.prototype.queueEvent = function(r10, e) { 10305 var t2 = Object.assign({}, e); 10306 return this._eventQueue.length <= this._options.maxQueueLength || r10 === "eventrateexceeded" ? (this._eventQueue.push(t2), this._sendTimeout || this._startBeaconSending(), this._eventQueue.length <= this._options.maxQueueLength) : false; 10307}; 10308$.prototype.flushEvents = function() { 10309 var r10 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false; 10310 if (r10 && this._eventQueue.length === 1) { 10311 this._eventQueue.pop(); 10312 return; 10313 } 10314 this._eventQueue.length && this._sendBeaconQueue(), this._startBeaconSending(); 10315}; 10316$.prototype.destroy = function() { 10317 var r10 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false; 10318 this.destroyed = true, r10 ? this._clearBeaconQueue() : this.flushEvents(), ie.default.clearTimeout(this._sendTimeout); 10319}; 10320$.prototype._clearBeaconQueue = function() { 10321 var r10 = this._eventQueue.length > this._options.maxBeaconSize ? this._eventQueue.length - this._options.maxBeaconSize : 0, e = this._eventQueue.slice(r10); 10322 r10 > 0 && Object.assign(e[e.length - 1], me({ mux_view_message: "event queue truncated" })); 10323 var t2 = this._createPayload(e); 10324 Cr(this._beaconUrl, t2, true, function() { 10325 }); 10326}; 10327$.prototype._sendBeaconQueue = function() { 10328 var r10 = this; 10329 if (this._postInFlight) { 10330 this._resendAfterPost = true; 10331 return; 10332 } 10333 var e = this._eventQueue.slice(0, this._options.maxBeaconSize); 10334 this._eventQueue = this._eventQueue.slice(this._options.maxBeaconSize), this._postInFlight = true; 10335 var t2 = this._createPayload(e), i3 = A.now(); 10336 Cr(this._beaconUrl, t2, false, function(a2, n2) { 10337 n2 ? (r10._eventQueue = e.concat(r10._eventQueue), r10._failureCount += 1, R.info("Error sending beacon: " + n2)) : r10._failureCount = 0, r10._roundTripTime = A.now() - i3, r10._postInFlight = false, r10._resendAfterPost && (r10._resendAfterPost = false, r10._eventQueue.length > 0 && r10._sendBeaconQueue()); 10338 }); 10339}; 10340$.prototype._getNextBeaconTime = function() { 10341 if (!this._failureCount) return this._options.baseTimeBetweenBeacons; 10342 var r10 = Math.pow(2, this._failureCount - 1); 10343 return r10 = r10 * Math.random(), (1 + r10) * this._options.baseTimeBetweenBeacons; 10344}; 10345$.prototype._startBeaconSending = function() { 10346 var r10 = this; 10347 ie.default.clearTimeout(this._sendTimeout), !this.destroyed && (this._sendTimeout = ie.default.setTimeout(function() { 10348 r10._eventQueue.length && r10._sendBeaconQueue(), r10._startBeaconSending(); 10349 }, this._getNextBeaconTime())); 10350}; 10351$.prototype._createPayload = function(r10) { 10352 var e = this, t2 = { transmission_timestamp: Math.round(A.now()) }; 10353 this._roundTripTime && (t2.rtt_ms = Math.round(this._roundTripTime)); 10354 var i3, a2, n2, o2 = function() { 10355 i3 = JSON.stringify({ metadata: t2, events: a2 || r10 }), n2 = i3.length / 1024; 10356 }, s = function() { 10357 return n2 <= e._options.maxPayloadKBSize; 10358 }; 10359 return o2(), s() || (R.info("Payload size is too big (" + n2 + " kb). Removing unnecessary events."), a2 = r10.filter(function(u3) { 10360 return si.indexOf(u3.e) === -1; 10361 }), o2()), s() || (R.info("Payload size still too big (" + n2 + " kb). Cropping fields.."), a2.forEach(function(u3) { 10362 for (var f in u3) { 10363 var g = u3[f], k3 = 50 * 1024; 10364 typeof g == "string" && g.length > k3 && (u3[f] = g.substring(0, k3)); 10365 } 10366 }), o2()), i3; 10367}; 10368var di = typeof Nr.default.exitPictureInPicture == "function" ? function(r10) { 10369 return r10.length <= oi; 10370} : function(r10) { 10371 return false; 10372}; 10373var Cr = function(r10, e, t2, i3) { 10374 if (t2 && navigator && navigator.sendBeacon && navigator.sendBeacon(r10, e)) { 10375 i3(); 10376 return; 10377 } 10378 if (ie.default.fetch) { 10379 ie.default.fetch(r10, { method: "POST", body: e, headers: { "Content-Type": "text/plain" }, keepalive: di(e) }).then(function(n2) { 10380 return i3(null, n2.ok ? null : "Error"); 10381 }).catch(function(n2) { 10382 return i3(null, n2); 10383 }); 10384 return; 10385 } 10386 if (ie.default.XMLHttpRequest) { 10387 var a2 = new ie.default.XMLHttpRequest(); 10388 a2.onreadystatechange = function() { 10389 if (a2.readyState === 4) return i3(null, a2.status !== 200 ? "error" : void 0); 10390 }, a2.open("POST", r10), a2.setRequestHeader("Content-Type", "text/plain"), a2.send(e); 10391 return; 10392 } 10393 i3(); 10394}; 10395var Mr = $; 10396var li = ["env_key", "view_id", "view_sequence_number", "player_sequence_number", "beacon_domain", "player_playhead_time", "viewer_time", "mux_api_version", "event", "video_id", "player_instance_id", "player_error_code", "player_error_message", "player_error_context", "player_error_severity", "player_error_business_exception", "view_playing_time_ms_cumulative", "ad_playing_time_ms_cumulative"]; 10397var ci = ["adplay", "adplaying", "adpause", "adfirstquartile", "admidpoint", "adthirdquartile", "adended", "adresponse", "adrequest"]; 10398var _i = ["ad_id", "ad_creative_id", "ad_universal_id"]; 10399var fi = ["viewstart", "error", "ended", "viewend"]; 10400var pi = 10 * 60 * 1e3; 10401var Hr = function() { 10402 "use strict"; 10403 function r10(e, t2) { 10404 var i3 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; 10405 D(this, r10); 10406 var a2, n2, o2, s, u3, f, g, k3, h3, c3, m2, w4; 10407 l(this, "mux", void 0), l(this, "envKey", void 0), l(this, "options", void 0), l(this, "eventQueue", void 0), l(this, "sampleRate", void 0), l(this, "disableCookies", void 0), l(this, "respectDoNotTrack", void 0), l(this, "previousBeaconData", void 0), l(this, "lastEventTime", void 0), l(this, "rateLimited", void 0), l(this, "pageLevelData", void 0), l(this, "viewerData", void 0), this.mux = e, this.envKey = t2, this.options = i3, this.previousBeaconData = null, this.lastEventTime = 0, this.rateLimited = false, this.eventQueue = new Mr(ze(this.envKey, this.options)); 10408 var x2; 10409 this.sampleRate = (x2 = this.options.sampleRate) !== null && x2 !== void 0 ? x2 : 1; 10410 var v2; 10411 this.disableCookies = (v2 = this.options.disableCookies) !== null && v2 !== void 0 ? v2 : false; 10412 var p3; 10413 this.respectDoNotTrack = (p3 = this.options.respectDoNotTrack) !== null && p3 !== void 0 ? p3 : false, this.previousBeaconData = null, this.lastEventTime = 0, this.rateLimited = false, this.pageLevelData = { mux_api_version: this.mux.API_VERSION, mux_embed: this.mux.NAME, mux_embed_version: this.mux.VERSION, viewer_application_name: (a2 = this.options.platform) === null || a2 === void 0 ? void 0 : a2.name, viewer_application_version: (n2 = this.options.platform) === null || n2 === void 0 ? void 0 : n2.version, viewer_application_engine: (o2 = this.options.platform) === null || o2 === void 0 ? void 0 : o2.layout, viewer_device_name: (s = this.options.platform) === null || s === void 0 ? void 0 : s.product, viewer_device_category: "", viewer_device_manufacturer: (u3 = this.options.platform) === null || u3 === void 0 ? void 0 : u3.manufacturer, viewer_os_family: (g = this.options.platform) === null || g === void 0 || (f = g.os) === null || f === void 0 ? void 0 : f.family, viewer_os_architecture: (h3 = this.options.platform) === null || h3 === void 0 || (k3 = h3.os) === null || k3 === void 0 ? void 0 : k3.architecture, viewer_os_version: (m2 = this.options.platform) === null || m2 === void 0 || (c3 = m2.os) === null || c3 === void 0 ? void 0 : c3.version, viewer_connection_type: sr(), page_url: Ue.default === null || Ue.default === void 0 || (w4 = Ue.default.location) === null || w4 === void 0 ? void 0 : w4.href }, this.viewerData = this.disableCookies ? {} : rr(); 10414 } 10415 return N(r10, [{ key: "send", value: function(t2, i3) { 10416 if (!(!t2 || !(i3 != null && i3.view_id))) { 10417 if (this.respectDoNotTrack && ce()) return R.info("Not sending `" + t2 + "` because Do Not Track is enabled"); 10418 if (!i3 || typeof i3 != "object") return R.error("A data object was expected in send() but was not provided"); 10419 var a2 = this.disableCookies ? {} : ar(), n2 = fe(ue({}, this.pageLevelData, i3, a2, this.viewerData), { event: t2, env_key: this.envKey }); 10420 n2.user_id && (n2.viewer_user_id = n2.user_id, delete n2.user_id); 10421 var o2, s = ((o2 = n2.mux_sample_number) !== null && o2 !== void 0 ? o2 : 0) >= this.sampleRate, u3 = this._deduplicateBeaconData(t2, n2), f = me(u3); 10422 if (this.lastEventTime = this.mux.utils.now(), s) return R.info("Not sending event due to sample rate restriction", t2, n2, f); 10423 if (this.envKey || R.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL", t2, n2, f), !this.rateLimited) if (R.info("Sending event", t2, n2, f), this.rateLimited = !this.eventQueue.queueEvent(t2, f), this.mux.WINDOW_UNLOADING && t2 === "viewend") this.eventQueue.destroy(true); 10424 else { 10425 if (this.mux.WINDOW_HIDDEN && t2 === "hb") this.eventQueue.flushEvents(true); 10426 else if (fi.indexOf(t2) >= 0) { 10427 if (t2 === "error" && i3.player_error_severity === "warning") return; 10428 this.eventQueue.flushEvents(); 10429 } 10430 if (this.rateLimited) return n2.event = "eventrateexceeded", f = me(n2), this.eventQueue.queueEvent(n2.event, f), R.error("Beaconing disabled due to rate limit."); 10431 } 10432 } 10433 } }, { key: "destroy", value: function() { 10434 this.eventQueue.destroy(false); 10435 } }, { key: "_deduplicateBeaconData", value: function(t2, i3) { 10436 var a2 = this, n2 = {}, o2 = i3.view_id; 10437 if (o2 === "-1" || t2 === "viewstart" || t2 === "viewend" || !this.previousBeaconData || this.mux.utils.now() - this.lastEventTime >= pi) n2 = ue({}, i3), o2 && (this.previousBeaconData = n2), o2 && t2 === "viewend" && (this.previousBeaconData = null); 10438 else { 10439 var s = t2.indexOf("request") === 0; 10440 Object.entries(i3).forEach(function(u3) { 10441 var f = H(u3, 2), g = f[0], k3 = f[1]; 10442 a2.previousBeaconData && (k3 !== a2.previousBeaconData[g] || li.indexOf(g) > -1 || a2.objectHasChanged(s, g, k3, a2.previousBeaconData[g]) || a2.eventRequiresKey(t2, g)) && (n2[g] = k3, a2.previousBeaconData[g] = k3); 10443 }); 10444 } 10445 return n2; 10446 } }, { key: "objectHasChanged", value: function(t2, i3, a2, n2) { 10447 return !t2 || i3.indexOf("request_") !== 0 ? false : i3 === "request_response_headers" || typeof a2 != "object" || typeof n2 != "object" ? true : Object.keys(a2 || {}).length !== Object.keys(n2 || {}).length; 10448 } }, { key: "eventRequiresKey", value: function(t2, i3) { 10449 return !!(t2 === "renditionchange" && i3.indexOf("video_source_") === 0 || _i.includes(i3) && ci.includes(t2)); 10450 } }]), r10; 10451}(); 10452var mi = function r6(e) { 10453 "use strict"; 10454 D(this, r6); 10455 var t2 = 0, i3 = 0, a2 = 0, n2 = 0, o2 = 0, s = 0, u3 = 0, f = function(h3, c3) { 10456 var m2 = c3.request_start, w4 = c3.request_response_start, x2 = c3.request_response_end, v2 = c3.request_bytes_loaded; 10457 n2++; 10458 var p3, _3; 10459 if (w4 ? (p3 = w4 - (m2 != null ? m2 : 0), _3 = (x2 != null ? x2 : 0) - w4) : _3 = (x2 != null ? x2 : 0) - (m2 != null ? m2 : 0), _3 > 0 && v2 && v2 > 0) { 10460 var d2 = v2 / _3 * 8e3; 10461 o2++, i3 += v2, a2 += _3, e.data.view_min_request_throughput = Math.min(e.data.view_min_request_throughput || 1 / 0, d2), e.data.view_average_request_throughput = i3 / a2 * 8e3, e.data.view_request_count = n2, p3 > 0 && (t2 += p3, e.data.view_max_request_latency = Math.max(e.data.view_max_request_latency || 0, p3), e.data.view_average_request_latency = t2 / o2); 10462 } 10463 }, g = function(h3, c3) { 10464 n2++, s++, e.data.view_request_count = n2, e.data.view_request_failed_count = s; 10465 }, k3 = function(h3, c3) { 10466 n2++, u3++, e.data.view_request_count = n2, e.data.view_request_canceled_count = u3; 10467 }; 10468 e.on("requestcompleted", f), e.on("requestfailed", g), e.on("requestcanceled", k3); 10469}; 10470var Br = mi; 10471var vi = 60 * 60 * 1e3; 10472var hi = function r7(e) { 10473 "use strict"; 10474 var t2 = this; 10475 D(this, r7), l(this, "_lastEventTime", void 0), e.on("before*", function(i3, a2) { 10476 var n2 = a2.viewer_time, o2 = A.now(), s = t2._lastEventTime; 10477 if (t2._lastEventTime = o2, s && o2 - s > vi) { 10478 var u3 = Object.keys(e.data).reduce(function(g, k3) { 10479 return k3.indexOf("video_") === 0 ? Object.assign(g, l({}, k3, e.data[k3])) : g; 10480 }, {}); 10481 e.mux.log.info("Received event after at least an hour inactivity, creating a new view"); 10482 var f = e.playbackHeartbeat._playheadShouldBeProgressing; 10483 e._resetView(Object.assign({ viewer_time: n2 }, u3)), e.playbackHeartbeat._playheadShouldBeProgressing = f, e.playbackHeartbeat._playheadShouldBeProgressing && i3.type !== "play" && i3.type !== "adbreakstart" && (e.emit("play", { viewer_time: n2 }), i3.type !== "playing" && e.emit("playing", { viewer_time: n2 })); 10484 } 10485 }); 10486}; 10487var Ur = hi; 10488var yi = function r8(e) { 10489 "use strict"; 10490 D(this, r8); 10491 var t2 = function(u3) { 10492 var f = gi(u3), g = bi(u3); 10493 if (f != null && !Fr(f, n2) && o2 <= g) { 10494 n2 = f, o2 = g; 10495 var k3 = { video_cdn: f }; 10496 e.emit("cdnchange", k3); 10497 } 10498 }, i3 = null, a2 = null, n2 = null, o2 = 0; 10499 e.on("viewinit", function() { 10500 i3 = null, a2 = null, n2 = null, o2 = 0; 10501 }), e.on("beforecdnchange", function(s, u3) { 10502 var f = u3 == null ? void 0 : u3.video_cdn; 10503 f && (typeof u3.video_previous_cdn == "undefined" || u3.video_previous_cdn === null) && (Fr(f, a2) ? u3.video_previous_cdn = i3 != null ? i3 : void 0 : (u3.video_previous_cdn = a2 != null ? a2 : void 0, i3 = a2, a2 = f)); 10504 }), e.on("requestcompleted", function(s, u3) { 10505 t2(u3); 10506 }); 10507}; 10508function Fr(r10, e) { 10509 return (r10 == null ? void 0 : r10.toLowerCase()) === (e == null ? void 0 : e.toLowerCase()); 10510} 10511function gi(r10) { 10512 var e; 10513 return r10 != null && r10.request_type && (r10.request_type === "media" || r10.request_type === "video") && (!((e = r10.request_response_headers) === null || e === void 0) && e["x-cdn"]) ? r10.request_response_headers["x-cdn"] : r10 != null && r10.video_cdn ? r10.video_cdn : null; 10514} 10515function bi(r10) { 10516 return r10 != null && r10.request_start ? r10.request_start : r10 != null && r10.viewer_time ? r10.viewer_time : Date.now(); 10517} 10518var Vr = yi; 10519var wi = function(r10) { 10520 try { 10521 return JSON.parse(r10), true; 10522 } catch (e) { 10523 return false; 10524 } 10525}; 10526var Ti = function r9(e) { 10527 "use strict"; 10528 var t2 = this; 10529 D(this, r9), l(this, "_emittingAutomaticEvent", false), l(this, "_hasInitialized", false), e.on("viewstart", function() { 10530 t2._hasInitialized || (t2._hasInitialized = true, t2._emittingAutomaticEvent = true, e.emit("playbackmodechange", { player_playback_mode: "standard", player_playback_mode_data: "{}" }), t2._emittingAutomaticEvent = false); 10531 }), e.on("viewend", function() { 10532 t2._hasInitialized = false; 10533 }), e.on("playbackmodechange", function(i3, a2) { 10534 t2._emittingAutomaticEvent || (a2.player_playback_mode_data ? wi(a2.player_playback_mode_data) || (e.mux.log.warn("Invalid JSON string for player_playback_mode_data"), a2.player_playback_mode_data = "{}") : a2.player_playback_mode_data = "{}", e.data.player_playback_mode_data = a2.player_playback_mode_data, e.data.player_playback_mode = a2.player_playback_mode); 10535 }); 10536}; 10537var jr = Ti; 10538var Ei = ["viewstart", "ended", "loadstart", "pause", "play", "playing", "ratechange", "waiting", "adplay", "adpause", "adended", "aderror", "adplaying", "adrequest", "adresponse", "adbreakstart", "adbreakend", "adfirstquartile", "admidpoint", "adthirdquartile", "rebufferstart", "rebufferend", "seeked", "error", "hb", "requestcompleted", "requestfailed", "requestcanceled", "renditionchange", "cdnchange", "playbackmodechange"]; 10539var ki = /* @__PURE__ */ new Set(["requestcompleted", "requestfailed", "requestcanceled"]); 10540var xi = function(r10) { 10541 "use strict"; 10542 xt(t2, r10); 10543 var e = At(t2); 10544 function t2(i3, a2, n2) { 10545 D(this, t2); 10546 var o2; 10547 o2 = e.call(this), l(b(o2), "pageLoadEndTime", void 0), l(b(o2), "pageLoadInitTime", void 0), l(b(o2), "_destroyed", void 0), l(b(o2), "_heartBeatTimeout", void 0), l(b(o2), "adTracker", void 0), l(b(o2), "dashjs", void 0), l(b(o2), "data", void 0), l(b(o2), "disablePlayheadRebufferTracking", void 0), l(b(o2), "disableRebufferTracking", void 0), l(b(o2), "errorTracker", void 0), l(b(o2), "errorTranslator", void 0), l(b(o2), "emitTranslator", void 0), l(b(o2), "getAdData", void 0), l(b(o2), "getPlayheadTime", void 0), l(b(o2), "getStateData", void 0), l(b(o2), "stateDataTranslator", void 0), l(b(o2), "hlsjs", void 0), l(b(o2), "id", void 0), l(b(o2), "longResumeTracker", void 0), l(b(o2), "minimumRebufferDuration", void 0), l(b(o2), "mux", void 0), l(b(o2), "playbackEventDispatcher", void 0), l(b(o2), "playbackHeartbeat", void 0), l(b(o2), "playbackHeartbeatTime", void 0), l(b(o2), "playheadTime", void 0), l(b(o2), "seekingTracker", void 0), l(b(o2), "sustainedRebufferThreshold", void 0), l(b(o2), "watchTimeTracker", void 0), l(b(o2), "currentFragmentPDT", void 0), l(b(o2), "currentFragmentStart", void 0), o2.pageLoadInitTime = _e.navigationStart(), o2.pageLoadEndTime = _e.domContentLoadedEventEnd(); 10548 var s = { debug: false, minimumRebufferDuration: 250, sustainedRebufferThreshold: 1e3, playbackHeartbeatTime: 25, beaconDomain: "litix.io", sampleRate: 1, disableCookies: false, respectDoNotTrack: false, disableRebufferTracking: false, disablePlayheadRebufferTracking: false, errorTranslator: function(h3) { 10549 return h3; 10550 }, emitTranslator: function() { 10551 for (var h3 = arguments.length, c3 = new Array(h3), m2 = 0; m2 < h3; m2++) c3[m2] = arguments[m2]; 10552 return c3; 10553 }, stateDataTranslator: function(h3) { 10554 return h3; 10555 } }; 10556 o2.mux = i3, o2.id = a2, n2 != null && n2.beaconDomain && o2.mux.log.warn("The `beaconDomain` setting has been deprecated in favor of `beaconCollectionDomain`. Please change your integration to use `beaconCollectionDomain` instead of `beaconDomain`."), n2 = Object.assign(s, n2), n2.data = n2.data || {}, n2.data.property_key && (n2.data.env_key = n2.data.property_key, delete n2.data.property_key), R.level = n2.debug ? Y.DEBUG : Y.WARN, o2.getPlayheadTime = n2.getPlayheadTime, o2.getStateData = n2.getStateData || function() { 10557 return {}; 10558 }, o2.getAdData = n2.getAdData || function() { 10559 }, o2.minimumRebufferDuration = n2.minimumRebufferDuration, o2.sustainedRebufferThreshold = n2.sustainedRebufferThreshold, o2.playbackHeartbeatTime = n2.playbackHeartbeatTime, o2.disableRebufferTracking = n2.disableRebufferTracking, o2.disableRebufferTracking && o2.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."), o2.disablePlayheadRebufferTracking = n2.disablePlayheadRebufferTracking, o2.errorTranslator = n2.errorTranslator, o2.emitTranslator = n2.emitTranslator, o2.stateDataTranslator = n2.stateDataTranslator, o2.playbackEventDispatcher = new Hr(i3, n2.data.env_key, n2), o2.data = { player_instance_id: ee(), mux_sample_rate: n2.sampleRate, beacon_domain: n2.beaconCollectionDomain || n2.beaconDomain }, o2.data.view_sequence_number = 1, o2.data.player_sequence_number = 1; 10560 var u3 = (function() { 10561 typeof this.data.view_start == "undefined" && (this.data.view_start = this.mux.utils.now(), this.emit("viewstart"), this.emit("renditionchange")); 10562 }).bind(b(o2)); 10563 if (o2.on("viewinit", function(h3, c3) { 10564 this._resetVideoData(), this._resetViewData(), this._resetErrorData(), this._updateStateData(), Object.assign(this.data, c3), this._initializeViewData(), this.one("play", u3), this.one("adbreakstart", u3); 10565 }), o2.on("videochange", function(h3, c3) { 10566 this._resetView(c3); 10567 }), o2.on("programchange", function(h3, c3) { 10568 this.data.player_is_paused && this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."), this._resetView(Object.assign(c3, { view_program_changed: true })), u3(), this.emit("play"), this.emit("playing"); 10569 }), o2.on("fragmentchange", function(h3, c3) { 10570 this.currentFragmentPDT = c3.currentFragmentPDT, this.currentFragmentStart = c3.currentFragmentStart; 10571 }), o2.on("destroy", o2.destroy), typeof window != "undefined" && typeof window.addEventListener == "function" && typeof window.removeEventListener == "function") { 10572 var f = function() { 10573 var h3 = typeof o2.data.view_start != "undefined"; 10574 o2.mux.WINDOW_HIDDEN = document.visibilityState === "hidden", h3 && o2.mux.WINDOW_HIDDEN && (o2.data.player_is_paused || o2.emit("hb")); 10575 }; 10576 window.addEventListener("visibilitychange", f, false); 10577 var g = function(h3) { 10578 h3.persisted || o2.destroy(); 10579 }; 10580 window.addEventListener("pagehide", g, false), o2.on("destroy", function() { 10581 window.removeEventListener("visibilitychange", f), window.removeEventListener("pagehide", g); 10582 }); 10583 } 10584 o2.on("playerready", function(h3, c3) { 10585 Object.assign(this.data, c3); 10586 }), Ei.forEach(function(h3) { 10587 o2.on(h3, function(c3, m2) { 10588 h3.indexOf("ad") !== 0 && this._updateStateData(), Object.assign(this.data, m2), this._sanitizeData(); 10589 }), o2.on("after" + h3, function() { 10590 (h3 !== "error" || this.errorTracker.viewErrored) && this.send(h3); 10591 }); 10592 }), o2.on("viewend", function(h3, c3) { 10593 Object.assign(o2.data, c3); 10594 }); 10595 var k3 = function(c3) { 10596 var m2 = this.mux.utils.now(); 10597 this.data.player_init_time && (this.data.player_startup_time = m2 - this.data.player_init_time), this.pageLoadInitTime = this.data.page_load_init_time || this.pageLoadInitTime, this.pageLoadEndTime = this.data.page_load_end_time || this.pageLoadEndTime, !this.mux.PLAYER_TRACKED && this.pageLoadInitTime && (this.mux.PLAYER_TRACKED = true, (this.data.player_init_time || this.pageLoadEndTime) && (this.data.page_load_time = Math.min(this.data.player_init_time || 1 / 0, this.pageLoadEndTime || 1 / 0) - this.pageLoadInitTime)), this.send("playerready"), delete this.data.player_startup_time, delete this.data.page_load_time; 10598 }; 10599 return o2.one("playerready", k3), o2.longResumeTracker = new Ur(b(o2)), o2.errorTracker = new Ut(b(o2)), new $t(b(o2)), o2.seekingTracker = new Kt(b(o2)), o2.playheadTime = new jt(b(o2)), o2.playbackHeartbeat = new Bt(b(o2)), new zt(b(o2)), o2.watchTimeTracker = new Ft(b(o2)), new Vt(b(o2)), o2.adTracker = new Xt(b(o2)), new Jt(b(o2)), new Gt(b(o2)), new Qt(b(o2)), new Br(b(o2)), new Vr(b(o2)), new jr(b(o2)), n2.hlsjs && o2.addHLSJS(n2), n2.dashjs && o2.addDashJS(n2), o2.emit("viewinit", n2.data), o2; 10600 } 10601 return N(t2, [{ key: "emit", value: function(a2, n2) { 10602 var o2, s = Object.assign({ viewer_time: this.mux.utils.now() }, n2), u3 = [a2, s]; 10603 if (this.emitTranslator) try { 10604 u3 = this.emitTranslator(a2, s); 10605 } catch (f) { 10606 this.mux.log.warn("Exception in emit translator callback.", f); 10607 } 10608 u3 != null && u3.length && (o2 = De(X(t2.prototype), "emit", this)).call.apply(o2, [this].concat(V(u3))); 10609 } }, { key: "destroy", value: function() { 10610 this._destroyed || (this._destroyed = true, typeof this.data.view_start != "undefined" && (this.emit("viewend"), this.send("viewend")), this.playbackEventDispatcher.destroy(), this.removeHLSJS(), this.removeDashJS(), window.clearTimeout(this._heartBeatTimeout)); 10611 } }, { key: "send", value: function(a2) { 10612 if (this.data.view_id) { 10613 var n2 = Object.assign({}, this.data), o2 = ["player_program_time", "player_manifest_newest_program_time", "player_live_edge_program_time", "player_program_time", "video_holdback", "video_part_holdback", "video_target_duration", "video_part_target_duration"]; 10614 if (n2.video_source_is_live === void 0 && (n2.player_source_duration === 1 / 0 || n2.video_source_duration === 1 / 0 ? n2.video_source_is_live = true : (n2.player_source_duration > 0 || n2.video_source_duration > 0) && (n2.video_source_is_live = false)), n2.video_source_is_live || o2.forEach(function(g) { 10615 n2[g] = void 0; 10616 }), n2.video_source_url = n2.video_source_url || n2.player_source_url, n2.video_source_url) { 10617 var s = H(re(n2.video_source_url), 2), u3 = s[0], f = s[1]; 10618 n2.video_source_domain = f, n2.video_source_hostname = u3; 10619 } 10620 delete n2.ad_request_id, this.playbackEventDispatcher.send(a2, n2), this.data.view_sequence_number++, this.data.player_sequence_number++, ki.has(a2) || this._restartHeartBeat(), a2 === "viewend" && delete this.data.view_id; 10621 } 10622 } }, { key: "_resetView", value: function(a2) { 10623 this.emit("viewend"), this.send("viewend"), this.emit("viewinit", a2); 10624 } }, { key: "_updateStateData", value: function() { 10625 var a2, n2 = this.getStateData(); 10626 if (typeof this.stateDataTranslator == "function") try { 10627 n2 = this.stateDataTranslator(n2); 10628 } catch (u3) { 10629 this.mux.log.warn("Exception in stateDataTranslator translator callback.", u3); 10630 } 10631 if (!((a2 = this.data) === null || a2 === void 0) && a2.video_cdn && (n2 != null && n2.video_cdn)) { 10632 var o2 = n2.video_cdn, s = St(n2, ["video_cdn"]); 10633 n2 = s; 10634 } 10635 Object.assign(this.data, n2), this.playheadTime._updatePlayheadTime(), this._sanitizeData(); 10636 } }, { key: "_sanitizeData", value: function() { 10637 var a2 = this, n2 = ["player_width", "player_height", "video_source_width", "video_source_height", "player_playhead_time", "video_source_bitrate"]; 10638 n2.forEach(function(s) { 10639 var u3 = parseInt(a2.data[s], 10); 10640 a2.data[s] = isNaN(u3) ? void 0 : u3; 10641 }); 10642 var o2 = ["player_source_url", "video_source_url"]; 10643 o2.forEach(function(s) { 10644 if (a2.data[s]) { 10645 var u3 = a2.data[s].toLowerCase(); 10646 (u3.indexOf("data:") === 0 || u3.indexOf("blob:") === 0) && (a2.data[s] = "MSE style URL"); 10647 } 10648 }); 10649 } }, { key: "_resetVideoData", value: function() { 10650 var a2 = this; 10651 Object.keys(this.data).forEach(function(n2) { 10652 n2.indexOf("video_") === 0 && delete a2.data[n2]; 10653 }); 10654 } }, { key: "_resetViewData", value: function() { 10655 var a2 = this; 10656 Object.keys(this.data).forEach(function(n2) { 10657 n2.indexOf("view_") === 0 && delete a2.data[n2]; 10658 }), this.data.view_sequence_number = 1; 10659 } }, { key: "_resetErrorData", value: function() { 10660 delete this.data.player_error_code, delete this.data.player_error_message, delete this.data.player_error_context, delete this.data.player_error_severity, delete this.data.player_error_business_exception; 10661 } }, { key: "_initializeViewData", value: function() { 10662 var a2 = this, n2 = this.data.view_id = ee(), o2 = function() { 10663 n2 === a2.data.view_id && P(a2.data, "player_view_count", 1); 10664 }; 10665 this.data.player_is_paused ? this.one("play", o2) : o2(); 10666 } }, { key: "_restartHeartBeat", value: function() { 10667 var a2 = this; 10668 window.clearTimeout(this._heartBeatTimeout), this._heartBeatTimeout = window.setTimeout(function() { 10669 a2.data.player_is_paused || a2.emit("hb"); 10670 }, 1e4); 10671 } }, { key: "addHLSJS", value: function(a2) { 10672 if (!a2.hlsjs) { 10673 this.mux.log.warn("You must pass a valid hlsjs instance in order to track it."); 10674 return; 10675 } 10676 if (this.hlsjs) { 10677 this.mux.log.warn("An instance of HLS.js is already being monitored for this player."); 10678 return; 10679 } 10680 this.hlsjs = a2.hlsjs, Ot(this.mux, this.id, a2.hlsjs, {}, a2.Hls || window.Hls); 10681 } }, { key: "removeHLSJS", value: function() { 10682 this.hlsjs && (It(this.hlsjs), this.hlsjs = void 0); 10683 } }, { key: "addDashJS", value: function(a2) { 10684 if (!a2.dashjs) { 10685 this.mux.log.warn("You must pass a valid dashjs instance in order to track it."); 10686 return; 10687 } 10688 if (this.dashjs) { 10689 this.mux.log.warn("An instance of Dash.js is already being monitored for this player."); 10690 return; 10691 } 10692 this.dashjs = a2.dashjs, Nt(this.mux, this.id, a2.dashjs); 10693 } }, { key: "removeDashJS", value: function() { 10694 this.dashjs && (Ct(this.dashjs), this.dashjs = void 0); 10695 } }]), t2; 10696}(Ht); 10697var Wr = xi; 10698var he = G(it()); 10699function nt2() { 10700 return he.default && !!(he.default.fullscreenElement || he.default.webkitFullscreenElement || he.default.mozFullScreenElement || he.default.msFullscreenElement); 10701} 10702var Di = ["loadstart", "pause", "play", "playing", "seeking", "seeked", "timeupdate", "ratechange", "stalled", "waiting", "error", "ended"]; 10703var Si = { 1: "MEDIA_ERR_ABORTED", 2: "MEDIA_ERR_NETWORK", 3: "MEDIA_ERR_DECODE", 4: "MEDIA_ERR_SRC_NOT_SUPPORTED" }; 10704function ot(r10, e, t2) { 10705 var i3 = H(se(e), 3), a2 = i3[0], n2 = i3[1], o2 = i3[2], s = r10.log, u3 = r10.utils.getComputedStyle, f = r10.utils.secondsToMs, g = { automaticErrorTracking: true }; 10706 if (a2) { 10707 if (o2 !== "video" && o2 !== "audio") return s.error("The element of `" + n2 + "` was not a media element."); 10708 } else return s.error("No element was found with the `" + n2 + "` query selector."); 10709 a2.mux && (a2.mux.destroy(), delete a2.mux, s.warn("Already monitoring this video element, replacing existing event listeners")); 10710 var k3 = { getPlayheadTime: function() { 10711 return f(a2.currentTime); 10712 }, getStateData: function() { 10713 var m2, w4, x2, v2 = ((m2 = (w4 = this).getPlayheadTime) === null || m2 === void 0 ? void 0 : m2.call(w4)) || f(a2.currentTime), p3 = this.hlsjs && this.hlsjs.url, _3 = this.dashjs && typeof this.dashjs.getSource == "function" && this.dashjs.getSource(), d2 = { player_is_paused: a2.paused, player_width: parseInt(u3(a2, "width")), player_height: parseInt(u3(a2, "height")), player_autoplay_on: a2.autoplay, player_preload_on: a2.preload, player_language_code: a2.lang, player_is_fullscreen: nt2(), video_poster_url: a2.poster, video_source_url: p3 || _3 || a2.currentSrc, video_source_duration: f(a2.duration), video_source_height: a2.videoHeight, video_source_width: a2.videoWidth, view_dropped_frame_count: a2 == null || (x2 = a2.getVideoPlaybackQuality) === null || x2 === void 0 ? void 0 : x2.call(a2).droppedVideoFrames }; 10714 if (a2.getStartDate && v2 > 0) { 10715 var y4 = a2.getStartDate(); 10716 if (y4 && typeof y4.getTime == "function" && y4.getTime()) { 10717 var T3 = y4.getTime(); 10718 if (d2.player_program_time = T3 + v2, a2.seekable.length > 0) { 10719 var E5 = T3 + a2.seekable.end(a2.seekable.length - 1); 10720 d2.player_live_edge_program_time = E5; 10721 } 10722 } 10723 } 10724 return d2; 10725 } }; 10726 t2 = Object.assign(g, t2, k3), t2.data = Object.assign({ player_software: "HTML5 Video Element", player_mux_plugin_name: "VideoElementMonitor", player_mux_plugin_version: r10.VERSION }, t2.data), a2.mux = a2.mux || {}, a2.mux.deleted = false, a2.mux.emit = function(c3, m2) { 10727 r10.emit(n2, c3, m2); 10728 }, a2.mux.updateData = function(c3) { 10729 a2.mux.emit("hb", c3); 10730 }; 10731 var h3 = function() { 10732 s.error("The monitor for this video element has already been destroyed."); 10733 }; 10734 a2.mux.destroy = function() { 10735 Object.keys(a2.mux.listeners).forEach(function(c3) { 10736 a2.removeEventListener(c3, a2.mux.listeners[c3], false); 10737 }), delete a2.mux.listeners, a2.mux.destroy = h3, a2.mux.swapElement = h3, a2.mux.emit = h3, a2.mux.addHLSJS = h3, a2.mux.addDashJS = h3, a2.mux.removeHLSJS = h3, a2.mux.removeDashJS = h3, a2.mux.updateData = h3, a2.mux.setEmitTranslator = h3, a2.mux.setStateDataTranslator = h3, a2.mux.setGetPlayheadTime = h3, a2.mux.deleted = true, r10.emit(n2, "destroy"); 10738 }, a2.mux.swapElement = function(c3) { 10739 var m2 = H(se(c3), 3), w4 = m2[0], x2 = m2[1], v2 = m2[2]; 10740 if (w4) { 10741 if (v2 !== "video" && v2 !== "audio") return r10.log.error("The element of `" + x2 + "` was not a media element."); 10742 } else return r10.log.error("No element was found with the `" + x2 + "` query selector."); 10743 w4.muxId = a2.muxId, delete a2.muxId, w4.mux = w4.mux || {}, w4.mux.listeners = Object.assign({}, a2.mux.listeners), delete a2.mux.listeners, Object.keys(w4.mux.listeners).forEach(function(p3) { 10744 a2.removeEventListener(p3, w4.mux.listeners[p3], false), w4.addEventListener(p3, w4.mux.listeners[p3], false); 10745 }), w4.mux.swapElement = a2.mux.swapElement, w4.mux.destroy = a2.mux.destroy, delete a2.mux, a2 = w4; 10746 }, a2.mux.addHLSJS = function(c3) { 10747 r10.addHLSJS(n2, c3); 10748 }, a2.mux.addDashJS = function(c3) { 10749 r10.addDashJS(n2, c3); 10750 }, a2.mux.removeHLSJS = function() { 10751 r10.removeHLSJS(n2); 10752 }, a2.mux.removeDashJS = function() { 10753 r10.removeDashJS(n2); 10754 }, a2.mux.setEmitTranslator = function(c3) { 10755 r10.setEmitTranslator(n2, c3); 10756 }, a2.mux.setStateDataTranslator = function(c3) { 10757 r10.setStateDataTranslator(n2, c3); 10758 }, a2.mux.setGetPlayheadTime = function(c3) { 10759 c3 || (c3 = t2.getPlayheadTime), r10.setGetPlayheadTime(n2, c3); 10760 }, r10.init(n2, t2), r10.emit(n2, "playerready"), a2.paused || (r10.emit(n2, "play"), a2.readyState > 2 && r10.emit(n2, "playing")), a2.mux.listeners = {}, Di.forEach(function(c3) { 10761 c3 === "error" && !t2.automaticErrorTracking || (a2.mux.listeners[c3] = function() { 10762 var m2 = {}; 10763 if (c3 === "error") { 10764 if (!a2.error || a2.error.code === 1) return; 10765 m2.player_error_code = a2.error.code, m2.player_error_message = Si[a2.error.code] || a2.error.message; 10766 } 10767 r10.emit(n2, c3, m2); 10768 }, a2.addEventListener(c3, a2.mux.listeners[c3], false)); 10769 }); 10770} 10771function st(r10, e, t2, i3) { 10772 var a2 = i3; 10773 if (r10 && typeof r10[e] == "function") try { 10774 a2 = r10[e].apply(r10, t2); 10775 } catch (n2) { 10776 R.info("safeCall error", n2); 10777 } 10778 return a2; 10779} 10780var ge = G(Q()); 10781var ye; 10782ge.default && ge.default.WeakMap && (ye = /* @__PURE__ */ new WeakMap()); 10783function ut(r10, e) { 10784 if (!r10 || !e || !ge.default || typeof ge.default.getComputedStyle != "function") return ""; 10785 var t2; 10786 return ye && ye.has(r10) && (t2 = ye.get(r10)), t2 || (t2 = ge.default.getComputedStyle(r10, null), ye && ye.set(r10, t2)), t2.getPropertyValue(e); 10787} 10788function dt2(r10) { 10789 return Math.floor(r10 * 1e3); 10790} 10791var le = { TARGET_DURATION: "#EXT-X-TARGETDURATION", PART_INF: "#EXT-X-PART-INF", SERVER_CONTROL: "#EXT-X-SERVER-CONTROL", INF: "#EXTINF", PROGRAM_DATE_TIME: "#EXT-X-PROGRAM-DATE-TIME", VERSION: "#EXT-X-VERSION", SESSION_DATA: "#EXT-X-SESSION-DATA" }; 10792var Fe = function(e) { 10793 return this.buffer = "", this.manifest = { segments: [], serverControl: {}, sessionData: {} }, this.currentUri = {}, this.process(e), this.manifest; 10794}; 10795Fe.prototype.process = function(r10) { 10796 var e; 10797 for (this.buffer += r10, e = this.buffer.indexOf("\n"); e > -1; e = this.buffer.indexOf("\n")) this.processLine(this.buffer.substring(0, e)), this.buffer = this.buffer.substring(e + 1); 10798}; 10799Fe.prototype.processLine = function(r10) { 10800 var e = r10.indexOf(":"), t2 = Pi(r10, e), i3 = t2[0], a2 = t2.length === 2 ? ct(t2[1]) : void 0; 10801 if (i3[0] !== "#") this.currentUri.uri = i3, this.manifest.segments.push(this.currentUri), this.manifest.targetDuration && !("duration" in this.currentUri) && (this.currentUri.duration = this.manifest.targetDuration), this.currentUri = {}; 10802 else switch (i3) { 10803 case le.TARGET_DURATION: { 10804 if (!isFinite(a2) || a2 < 0) return; 10805 this.manifest.targetDuration = a2, this.setHoldBack(); 10806 break; 10807 } 10808 case le.PART_INF: { 10809 lt(this.manifest, t2), this.manifest.partInf.partTarget && (this.manifest.partTargetDuration = this.manifest.partInf.partTarget), this.setHoldBack(); 10810 break; 10811 } 10812 case le.SERVER_CONTROL: { 10813 lt(this.manifest, t2), this.setHoldBack(); 10814 break; 10815 } 10816 case le.INF: { 10817 a2 === 0 ? this.currentUri.duration = 0.01 : a2 > 0 && (this.currentUri.duration = a2); 10818 break; 10819 } 10820 case le.PROGRAM_DATE_TIME: { 10821 var n2 = a2, o2 = new Date(n2); 10822 this.manifest.dateTimeString || (this.manifest.dateTimeString = n2, this.manifest.dateTimeObject = o2), this.currentUri.dateTimeString = n2, this.currentUri.dateTimeObject = o2; 10823 break; 10824 } 10825 case le.VERSION: { 10826 lt(this.manifest, t2); 10827 break; 10828 } 10829 case le.SESSION_DATA: { 10830 var s = Oi(t2[1]), u3 = Ce(s); 10831 Object.assign(this.manifest.sessionData, u3); 10832 } 10833 } 10834}; 10835Fe.prototype.setHoldBack = function() { 10836 var r10 = this.manifest, e = r10.serverControl, t2 = r10.targetDuration, i3 = r10.partTargetDuration; 10837 if (e) { 10838 var a2 = "holdBack", n2 = "partHoldBack", o2 = t2 && t2 * 3, s = i3 && i3 * 2; 10839 t2 && !e.hasOwnProperty(a2) && (e[a2] = o2), o2 && e[a2] < o2 && (e[a2] = o2), i3 && !e.hasOwnProperty(n2) && (e[n2] = i3 * 3), i3 && e[n2] < s && (e[n2] = s); 10840 } 10841}; 10842var lt = function(r10, e) { 10843 var t2 = Gr(e[0].replace("#EXT-X-", "")), i3; 10844 Ai(e[1]) ? (i3 = {}, i3 = Object.assign(Ri(e[1]), i3)) : i3 = ct(e[1]), r10[t2] = i3; 10845}; 10846var Gr = function(r10) { 10847 return r10.toLowerCase().replace(/-(\w)/g, function(e) { 10848 return e[1].toUpperCase(); 10849 }); 10850}; 10851var ct = function(r10) { 10852 if (r10.toLowerCase() === "yes" || r10.toLowerCase() === "no") return r10.toLowerCase() === "yes"; 10853 var e = r10.indexOf(":") !== -1 ? r10 : parseFloat(r10); 10854 return isNaN(e) ? r10 : e; 10855}; 10856var qi = function(r10) { 10857 var e = {}, t2 = r10.split("="); 10858 if (t2.length > 1) { 10859 var i3 = Gr(t2[0]); 10860 e[i3] = ct(t2[1]); 10861 } 10862 return e; 10863}; 10864var Ri = function(r10) { 10865 for (var e = r10.split(","), t2 = {}, i3 = 0; e.length > i3; i3++) { 10866 var a2 = e[i3], n2 = qi(a2); 10867 t2 = Object.assign(n2, t2); 10868 } 10869 return t2; 10870}; 10871var Ai = function(r10) { 10872 return r10.indexOf("=") > -1; 10873}; 10874var Pi = function(r10, e) { 10875 return e === -1 ? [r10] : [r10.substring(0, e), r10.substring(e + 1)]; 10876}; 10877var Oi = function(r10) { 10878 var e = {}; 10879 if (r10) { 10880 var t2 = r10.search(","), i3 = r10.slice(0, t2), a2 = r10.slice(t2 + 1), n2 = [i3, a2]; 10881 return n2.forEach(function(o2, s) { 10882 for (var u3 = o2.replace(/['"]+/g, "").split("="), f = 0; f < u3.length; f++) u3[f] === "DATA-ID" && (e["DATA-ID"] = u3[1 - f]), u3[f] === "VALUE" && (e.VALUE = u3[1 - f]); 10883 }), { data: e }; 10884 } 10885}; 10886var Jr = Fe; 10887var Ii = { safeCall: st, safeIncrement: P, getComputedStyle: ut, secondsToMs: dt2, assign: Object.assign, headersStringToObject: pe, cdnHeadersToRequestId: de, extractHostnameAndDomain: re, extractHostname: F, manifestParser: Jr, generateShortID: Pe, generateUUID: ee, now: A.now, findMediaElement: se }; 10888var Qr = Ii; 10889var Li = { PLAYER_READY: "playerready", VIEW_INIT: "viewinit", VIDEO_CHANGE: "videochange", PLAY: "play", PAUSE: "pause", PLAYING: "playing", TIME_UPDATE: "timeupdate", SEEKING: "seeking", SEEKED: "seeked", REBUFFER_START: "rebufferstart", REBUFFER_END: "rebufferend", ERROR: "error", ENDED: "ended", RENDITION_CHANGE: "renditionchange", ORIENTATION_CHANGE: "orientationchange", PLAYBACK_MODE_CHANGE: "playbackmodechange", AD_REQUEST: "adrequest", AD_RESPONSE: "adresponse", AD_BREAK_START: "adbreakstart", AD_PLAY: "adplay", AD_PLAYING: "adplaying", AD_PAUSE: "adpause", AD_FIRST_QUARTILE: "adfirstquartile", AD_MID_POINT: "admidpoint", AD_THIRD_QUARTILE: "adthirdquartile", AD_ENDED: "adended", AD_BREAK_END: "adbreakend", AD_ERROR: "aderror", REQUEST_COMPLETED: "requestcompleted", REQUEST_FAILED: "requestfailed", REQUEST_CANCELLED: "requestcanceled", HEARTBEAT: "hb", DESTROY: "destroy" }; 10890var zr = Li; 10891var Ni = "mux-embed"; 10892var Ci = "5.14.0"; 10893var Mi = "2.1"; 10894var C = {}; 10895var ne = function(e) { 10896 var t2 = arguments; 10897 typeof e == "string" ? ne.hasOwnProperty(e) ? be.default.setTimeout(function() { 10898 t2 = Array.prototype.splice.call(t2, 1), ne[e].apply(null, t2); 10899 }, 0) : R.warn("`" + e + "` is an unknown task") : typeof e == "function" ? be.default.setTimeout(function() { 10900 e(ne); 10901 }, 0) : R.warn("`" + e + "` is invalid."); 10902}; 10903var Hi = { loaded: A.now(), NAME: Ni, VERSION: Ci, API_VERSION: Mi, PLAYER_TRACKED: false, monitor: function(e, t2) { 10904 return ot(ne, e, t2); 10905}, destroyMonitor: function(e) { 10906 var t2 = H(se(e), 1), i3 = t2[0]; 10907 i3 && i3.mux && typeof i3.mux.destroy == "function" ? i3.mux.destroy() : R.error("A video element monitor for `" + e + "` has not been initialized via `mux.monitor`."); 10908}, addHLSJS: function(e, t2) { 10909 var i3 = J(e); 10910 C[i3] ? C[i3].addHLSJS(t2) : R.error("A monitor for `" + i3 + "` has not been initialized."); 10911}, addDashJS: function(e, t2) { 10912 var i3 = J(e); 10913 C[i3] ? C[i3].addDashJS(t2) : R.error("A monitor for `" + i3 + "` has not been initialized."); 10914}, removeHLSJS: function(e) { 10915 var t2 = J(e); 10916 C[t2] ? C[t2].removeHLSJS() : R.error("A monitor for `" + t2 + "` has not been initialized."); 10917}, removeDashJS: function(e) { 10918 var t2 = J(e); 10919 C[t2] ? C[t2].removeDashJS() : R.error("A monitor for `" + t2 + "` has not been initialized."); 10920}, init: function(e, t2) { 10921 ce() && t2 && t2.respectDoNotTrack && R.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled."); 10922 var i3 = J(e); 10923 C[i3] = new Wr(ne, i3, t2); 10924}, emit: function(e, t2, i3) { 10925 var a2 = J(e); 10926 C[a2] ? (C[a2].emit(t2, i3), t2 === "destroy" && delete C[a2]) : R.error("A monitor for `" + a2 + "` has not been initialized."); 10927}, updateData: function(e, t2) { 10928 var i3 = J(e); 10929 C[i3] ? C[i3].emit("hb", t2) : R.error("A monitor for `" + i3 + "` has not been initialized."); 10930}, setEmitTranslator: function(e, t2) { 10931 var i3 = J(e); 10932 C[i3] ? C[i3].emitTranslator = t2 : R.error("A monitor for `" + i3 + "` has not been initialized."); 10933}, setStateDataTranslator: function(e, t2) { 10934 var i3 = J(e); 10935 C[i3] ? C[i3].stateDataTranslator = t2 : R.error("A monitor for `" + i3 + "` has not been initialized."); 10936}, setGetPlayheadTime: function(e, t2) { 10937 var i3 = J(e); 10938 C[i3] ? C[i3].getPlayheadTime = t2 : R.error("A monitor for `" + i3 + "` has not been initialized."); 10939}, checkDoNotTrack: ce, log: R, utils: Qr, events: zr, WINDOW_HIDDEN: false, WINDOW_UNLOADING: false }; 10940Object.assign(ne, Hi); 10941typeof be.default != "undefined" && typeof be.default.addEventListener == "function" && be.default.addEventListener("pagehide", function(r10) { 10942 r10.persisted || (ne.WINDOW_UNLOADING = true); 10943}, false); 10944var Cd = ne; 10945
vendor: 397,627 bytes, lines 10946-22986
10946// node_modules/.pnpm/[email protected]/node_modules/hls.js/dist/hls.mjs 10947function getDefaultExportFromCjs(x2) { 10948 return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2; 10949} 10950var urlToolkit = { exports: {} }; 10951(function(module, exports) { 10952 (function(root) { 10953 var URL_REGEX = /^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/; 10954 var FIRST_SEGMENT_REGEX = /^(?=([^\/?#]*))\1([^]*)$/; 10955 var SLASH_DOT_REGEX = /(?:\/|^)\.(?=\/)/g; 10956 var SLASH_DOT_DOT_REGEX = /(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g; 10957 var URLToolkit = { 10958 // If opts.alwaysNormalize is true then the path will always be normalized even when it starts with / or // 10959 // E.g 10960 // With opts.alwaysNormalize = false (default, spec compliant) 10961 // http://a.com/b/cd + /e/f/../g => http://a.com/e/f/../g 10962 // With opts.alwaysNormalize = true (not spec compliant) 10963 // http://a.com/b/cd + /e/f/../g => http://a.com/e/g 10964 buildAbsoluteURL: function(baseURL, relativeURL, opts) { 10965 opts = opts || {}; 10966 baseURL = baseURL.trim(); 10967 relativeURL = relativeURL.trim(); 10968 if (!relativeURL) { 10969 if (!opts.alwaysNormalize) { 10970 return baseURL; 10971 } 10972 var basePartsForNormalise = URLToolkit.parseURL(baseURL); 10973 if (!basePartsForNormalise) { 10974 throw new Error("Error trying to parse base URL."); 10975 } 10976 basePartsForNormalise.path = URLToolkit.normalizePath( 10977 basePartsForNormalise.path 10978 ); 10979 return URLToolkit.buildURLFromParts(basePartsForNormalise); 10980 } 10981 var relativeParts = URLToolkit.parseURL(relativeURL); 10982 if (!relativeParts) { 10983 throw new Error("Error trying to parse relative URL."); 10984 } 10985 if (relativeParts.scheme) { 10986 if (!opts.alwaysNormalize) { 10987 return relativeURL; 10988 } 10989 relativeParts.path = URLToolkit.normalizePath(relativeParts.path); 10990 return URLToolkit.buildURLFromParts(relativeParts); 10991 } 10992 var baseParts = URLToolkit.parseURL(baseURL); 10993 if (!baseParts) { 10994 throw new Error("Error trying to parse base URL."); 10995 } 10996 if (!baseParts.netLoc && baseParts.path && baseParts.path[0] !== "/") { 10997 var pathParts = FIRST_SEGMENT_REGEX.exec(baseParts.path); 10998 baseParts.netLoc = pathParts[1]; 10999 baseParts.path = pathParts[2]; 11000 } 11001 if (baseParts.netLoc && !baseParts.path) { 11002 baseParts.path = "/"; 11003 } 11004 var builtParts = { 11005 // 2c) Otherwise, the embedded URL inherits the scheme of 11006 // the base URL. 11007 scheme: baseParts.scheme, 11008 netLoc: relativeParts.netLoc, 11009 path: null, 11010 params: relativeParts.params, 11011 query: relativeParts.query, 11012 fragment: relativeParts.fragment 11013 }; 11014 if (!relativeParts.netLoc) { 11015 builtParts.netLoc = baseParts.netLoc; 11016 if (relativeParts.path[0] !== "/") { 11017 if (!relativeParts.path) { 11018 builtParts.path = baseParts.path; 11019 if (!relativeParts.params) { 11020 builtParts.params = baseParts.params; 11021 if (!relativeParts.query) { 11022 builtParts.query = baseParts.query; 11023 } 11024 } 11025 } else { 11026 var baseURLPath = baseParts.path; 11027 var newPath = baseURLPath.substring(0, baseURLPath.lastIndexOf("/") + 1) + relativeParts.path; 11028 builtParts.path = URLToolkit.normalizePath(newPath); 11029 } 11030 } 11031 } 11032 if (builtParts.path === null) { 11033 builtParts.path = opts.alwaysNormalize ? URLToolkit.normalizePath(relativeParts.path) : relativeParts.path; 11034 } 11035 return URLToolkit.buildURLFromParts(builtParts); 11036 }, 11037 parseURL: function(url) { 11038 var parts = URL_REGEX.exec(url); 11039 if (!parts) { 11040 return null; 11041 } 11042 return { 11043 scheme: parts[1] || "", 11044 netLoc: parts[2] || "", 11045 path: parts[3] || "", 11046 params: parts[4] || "", 11047 query: parts[5] || "", 11048 fragment: parts[6] || "" 11049 }; 11050 }, 11051 normalizePath: function(path) { 11052 path = path.split("").reverse().join("").replace(SLASH_DOT_REGEX, ""); 11053 while (path.length !== (path = path.replace(SLASH_DOT_DOT_REGEX, "")).length) { 11054 } 11055 return path.split("").reverse().join(""); 11056 }, 11057 buildURLFromParts: function(parts) { 11058 return parts.scheme + parts.netLoc + parts.path + parts.params + parts.query + parts.fragment; 11059 } 11060 }; 11061 module.exports = URLToolkit; 11062 })(); 11063})(urlToolkit); 11064var urlToolkitExports = urlToolkit.exports; 11065function ownKeys2(e, r10) { 11066 var t2 = Object.keys(e); 11067 if (Object.getOwnPropertySymbols) { 11068 var o2 = Object.getOwnPropertySymbols(e); 11069 r10 && (o2 = o2.filter(function(r11) { 11070 return Object.getOwnPropertyDescriptor(e, r11).enumerable; 11071 })), t2.push.apply(t2, o2); 11072 } 11073 return t2; 11074} 11075function _objectSpread23(e) { 11076 for (var r10 = 1; r10 < arguments.length; r10++) { 11077 var t2 = null != arguments[r10] ? arguments[r10] : {}; 11078 r10 % 2 ? ownKeys2(Object(t2), true).forEach(function(r11) { 11079 _defineProperty3(e, r11, t2[r11]); 11080 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t2)) : ownKeys2(Object(t2)).forEach(function(r11) { 11081 Object.defineProperty(e, r11, Object.getOwnPropertyDescriptor(t2, r11)); 11082 }); 11083 } 11084 return e; 11085} 11086function _toPrimitive2(t2, r10) { 11087 if ("object" != typeof t2 || !t2) return t2; 11088 var e = t2[Symbol.toPrimitive]; 11089 if (void 0 !== e) { 11090 var i3 = e.call(t2, r10 || "default"); 11091 if ("object" != typeof i3) return i3; 11092 throw new TypeError("@@toPrimitive must return a primitive value."); 11093 } 11094 return ("string" === r10 ? String : Number)(t2); 11095} 11096function _toPropertyKey2(t2) { 11097 var i3 = _toPrimitive2(t2, "string"); 11098 return "symbol" == typeof i3 ? i3 : String(i3); 11099} 11100function _defineProperty3(obj, key, value) { 11101 key = _toPropertyKey2(key); 11102 if (key in obj) { 11103 Object.defineProperty(obj, key, { 11104 value, 11105 enumerable: true, 11106 configurable: true, 11107 writable: true 11108 }); 11109 } else { 11110 obj[key] = value; 11111 } 11112 return obj; 11113} 11114function _extends2() { 11115 _extends2 = Object.assign ? Object.assign.bind() : function(target) { 11116 for (var i3 = 1; i3 < arguments.length; i3++) { 11117 var source = arguments[i3]; 11118 for (var key in source) { 11119 if (Object.prototype.hasOwnProperty.call(source, key)) { 11120 target[key] = source[key]; 11121 } 11122 } 11123 } 11124 return target; 11125 }; 11126 return _extends2.apply(this, arguments); 11127} 11128var isFiniteNumber = Number.isFinite || function(value) { 11129 return typeof value === "number" && isFinite(value); 11130}; 11131var isSafeInteger = Number.isSafeInteger || function(value) { 11132 return typeof value === "number" && Math.abs(value) <= MAX_SAFE_INTEGER; 11133}; 11134var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; 11135var Events = function(Events2) { 11136 Events2["MEDIA_ATTACHING"] = "hlsMediaAttaching"; 11137 Events2["MEDIA_ATTACHED"] = "hlsMediaAttached"; 11138 Events2["MEDIA_DETACHING"] = "hlsMediaDetaching"; 11139 Events2["MEDIA_DETACHED"] = "hlsMediaDetached"; 11140 Events2["BUFFER_RESET"] = "hlsBufferReset"; 11141 Events2["BUFFER_CODECS"] = "hlsBufferCodecs"; 11142 Events2["BUFFER_CREATED"] = "hlsBufferCreated"; 11143 Events2["BUFFER_APPENDING"] = "hlsBufferAppending"; 11144 Events2["BUFFER_APPENDED"] = "hlsBufferAppended"; 11145 Events2["BUFFER_EOS"] = "hlsBufferEos"; 11146 Events2["BUFFER_FLUSHING"] = "hlsBufferFlushing"; 11147 Events2["BUFFER_FLUSHED"] = "hlsBufferFlushed"; 11148 Events2["MANIFEST_LOADING"] = "hlsManifestLoading"; 11149 Events2["MANIFEST_LOADED"] = "hlsManifestLoaded"; 11150 Events2["MANIFEST_PARSED"] = "hlsManifestParsed"; 11151 Events2["LEVEL_SWITCHING"] = "hlsLevelSwitching"; 11152 Events2["LEVEL_SWITCHED"] = "hlsLevelSwitched"; 11153 Events2["LEVEL_LOADING"] = "hlsLevelLoading"; 11154 Events2["LEVEL_LOADED"] = "hlsLevelLoaded"; 11155 Events2["LEVEL_UPDATED"] = "hlsLevelUpdated"; 11156 Events2["LEVEL_PTS_UPDATED"] = "hlsLevelPtsUpdated"; 11157 Events2["LEVELS_UPDATED"] = "hlsLevelsUpdated"; 11158 Events2["AUDIO_TRACKS_UPDATED"] = "hlsAudioTracksUpdated"; 11159 Events2["AUDIO_TRACK_SWITCHING"] = "hlsAudioTrackSwitching"; 11160 Events2["AUDIO_TRACK_SWITCHED"] = "hlsAudioTrackSwitched"; 11161 Events2["AUDIO_TRACK_LOADING"] = "hlsAudioTrackLoading"; 11162 Events2["AUDIO_TRACK_LOADED"] = "hlsAudioTrackLoaded"; 11163 Events2["SUBTITLE_TRACKS_UPDATED"] = "hlsSubtitleTracksUpdated"; 11164 Events2["SUBTITLE_TRACKS_CLEARED"] = "hlsSubtitleTracksCleared"; 11165 Events2["SUBTITLE_TRACK_SWITCH"] = "hlsSubtitleTrackSwitch"; 11166 Events2["SUBTITLE_TRACK_LOADING"] = "hlsSubtitleTrackLoading"; 11167 Events2["SUBTITLE_TRACK_LOADED"] = "hlsSubtitleTrackLoaded"; 11168 Events2["SUBTITLE_FRAG_PROCESSED"] = "hlsSubtitleFragProcessed"; 11169 Events2["CUES_PARSED"] = "hlsCuesParsed"; 11170 Events2["NON_NATIVE_TEXT_TRACKS_FOUND"] = "hlsNonNativeTextTracksFound"; 11171 Events2["INIT_PTS_FOUND"] = "hlsInitPtsFound"; 11172 Events2["FRAG_LOADING"] = "hlsFragLoading"; 11173 Events2["FRAG_LOAD_EMERGENCY_ABORTED"] = "hlsFragLoadEmergencyAborted"; 11174 Events2["FRAG_LOADED"] = "hlsFragLoaded"; 11175 Events2["FRAG_DECRYPTED"] = "hlsFragDecrypted"; 11176 Events2["FRAG_PARSING_INIT_SEGMENT"] = "hlsFragParsingInitSegment"; 11177 Events2["FRAG_PARSING_USERDATA"] = "hlsFragParsingUserdata"; 11178 Events2["FRAG_PARSING_METADATA"] = "hlsFragParsingMetadata"; 11179 Events2["FRAG_PARSED"] = "hlsFragParsed"; 11180 Events2["FRAG_BUFFERED"] = "hlsFragBuffered"; 11181 Events2["FRAG_CHANGED"] = "hlsFragChanged"; 11182 Events2["FPS_DROP"] = "hlsFpsDrop"; 11183 Events2["FPS_DROP_LEVEL_CAPPING"] = "hlsFpsDropLevelCapping"; 11184 Events2["MAX_AUTO_LEVEL_UPDATED"] = "hlsMaxAutoLevelUpdated"; 11185 Events2["ERROR"] = "hlsError"; 11186 Events2["DESTROYING"] = "hlsDestroying"; 11187 Events2["KEY_LOADING"] = "hlsKeyLoading"; 11188 Events2["KEY_LOADED"] = "hlsKeyLoaded"; 11189 Events2["LIVE_BACK_BUFFER_REACHED"] = "hlsLiveBackBufferReached"; 11190 Events2["BACK_BUFFER_REACHED"] = "hlsBackBufferReached"; 11191 Events2["STEERING_MANIFEST_LOADED"] = "hlsSteeringManifestLoaded"; 11192 return Events2; 11193}({}); 11194var ErrorTypes = function(ErrorTypes2) { 11195 ErrorTypes2["NETWORK_ERROR"] = "networkError"; 11196 ErrorTypes2["MEDIA_ERROR"] = "mediaError"; 11197 ErrorTypes2["KEY_SYSTEM_ERROR"] = "keySystemError"; 11198 ErrorTypes2["MUX_ERROR"] = "muxError"; 11199 ErrorTypes2["OTHER_ERROR"] = "otherError"; 11200 return ErrorTypes2; 11201}({}); 11202var ErrorDetails = function(ErrorDetails2) { 11203 ErrorDetails2["KEY_SYSTEM_NO_KEYS"] = "keySystemNoKeys"; 11204 ErrorDetails2["KEY_SYSTEM_NO_ACCESS"] = "keySystemNoAccess"; 11205 ErrorDetails2["KEY_SYSTEM_NO_SESSION"] = "keySystemNoSession"; 11206 ErrorDetails2["KEY_SYSTEM_NO_CONFIGURED_LICENSE"] = "keySystemNoConfiguredLicense"; 11207 ErrorDetails2["KEY_SYSTEM_LICENSE_REQUEST_FAILED"] = "keySystemLicenseRequestFailed"; 11208 ErrorDetails2["KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED"] = "keySystemServerCertificateRequestFailed"; 11209 ErrorDetails2["KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED"] = "keySystemServerCertificateUpdateFailed"; 11210 ErrorDetails2["KEY_SYSTEM_SESSION_UPDATE_FAILED"] = "keySystemSessionUpdateFailed"; 11211 ErrorDetails2["KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED"] = "keySystemStatusOutputRestricted"; 11212 ErrorDetails2["KEY_SYSTEM_STATUS_INTERNAL_ERROR"] = "keySystemStatusInternalError"; 11213 ErrorDetails2["MANIFEST_LOAD_ERROR"] = "manifestLoadError"; 11214 ErrorDetails2["MANIFEST_LOAD_TIMEOUT"] = "manifestLoadTimeOut"; 11215 ErrorDetails2["MANIFEST_PARSING_ERROR"] = "manifestParsingError"; 11216 ErrorDetails2["MANIFEST_INCOMPATIBLE_CODECS_ERROR"] = "manifestIncompatibleCodecsError"; 11217 ErrorDetails2["LEVEL_EMPTY_ERROR"] = "levelEmptyError"; 11218 ErrorDetails2["LEVEL_LOAD_ERROR"] = "levelLoadError"; 11219 ErrorDetails2["LEVEL_LOAD_TIMEOUT"] = "levelLoadTimeOut"; 11220 ErrorDetails2["LEVEL_PARSING_ERROR"] = "levelParsingError"; 11221 ErrorDetails2["LEVEL_SWITCH_ERROR"] = "levelSwitchError"; 11222 ErrorDetails2["AUDIO_TRACK_LOAD_ERROR"] = "audioTrackLoadError"; 11223 ErrorDetails2["AUDIO_TRACK_LOAD_TIMEOUT"] = "audioTrackLoadTimeOut"; 11224 ErrorDetails2["SUBTITLE_LOAD_ERROR"] = "subtitleTrackLoadError"; 11225 ErrorDetails2["SUBTITLE_TRACK_LOAD_TIMEOUT"] = "subtitleTrackLoadTimeOut"; 11226 ErrorDetails2["FRAG_LOAD_ERROR"] = "fragLoadError"; 11227 ErrorDetails2["FRAG_LOAD_TIMEOUT"] = "fragLoadTimeOut"; 11228 ErrorDetails2["FRAG_DECRYPT_ERROR"] = "fragDecryptError"; 11229 ErrorDetails2["FRAG_PARSING_ERROR"] = "fragParsingError"; 11230 ErrorDetails2["FRAG_GAP"] = "fragGap"; 11231 ErrorDetails2["REMUX_ALLOC_ERROR"] = "remuxAllocError"; 11232 ErrorDetails2["KEY_LOAD_ERROR"] = "keyLoadError"; 11233 ErrorDetails2["KEY_LOAD_TIMEOUT"] = "keyLoadTimeOut"; 11234 ErrorDetails2["BUFFER_ADD_CODEC_ERROR"] = "bufferAddCodecError"; 11235 ErrorDetails2["BUFFER_INCOMPATIBLE_CODECS_ERROR"] = "bufferIncompatibleCodecsError"; 11236 ErrorDetails2["BUFFER_APPEND_ERROR"] = "bufferAppendError"; 11237 ErrorDetails2["BUFFER_APPENDING_ERROR"] = "bufferAppendingError"; 11238 ErrorDetails2["BUFFER_STALLED_ERROR"] = "bufferStalledError"; 11239 ErrorDetails2["BUFFER_FULL_ERROR"] = "bufferFullError"; 11240 ErrorDetails2["BUFFER_SEEK_OVER_HOLE"] = "bufferSeekOverHole"; 11241 ErrorDetails2["BUFFER_NUDGE_ON_STALL"] = "bufferNudgeOnStall"; 11242 ErrorDetails2["INTERNAL_EXCEPTION"] = "internalException"; 11243 ErrorDetails2["INTERNAL_ABORTED"] = "aborted"; 11244 ErrorDetails2["UNKNOWN"] = "unknown"; 11245 return ErrorDetails2; 11246}({}); 11247var noop3 = function noop4() { 11248}; 11249var fakeLogger = { 11250 trace: noop3, 11251 debug: noop3, 11252 log: noop3, 11253 warn: noop3, 11254 info: noop3, 11255 error: noop3 11256}; 11257var exportedLogger = fakeLogger; 11258function consolePrintFn(type) { 11259 const func = self.console[type]; 11260 if (func) { 11261 return func.bind(self.console, `[${type}] >`); 11262 } 11263 return noop3; 11264} 11265function exportLoggerFunctions(debugConfig, ...functions) { 11266 functions.forEach(function(type) { 11267 exportedLogger[type] = debugConfig[type] ? debugConfig[type].bind(debugConfig) : consolePrintFn(type); 11268 }); 11269} 11270function enableLogs(debugConfig, id) { 11271 if (typeof console === "object" && debugConfig === true || typeof debugConfig === "object") { 11272 exportLoggerFunctions( 11273 debugConfig, 11274 // Remove out from list here to hard-disable a log-level 11275 // 'trace', 11276 "debug", 11277 "log", 11278 "info", 11279 "warn", 11280 "error" 11281 ); 11282 try { 11283 exportedLogger.log(`Debug logs enabled for "${id}" in hls.js version ${"1.5.20"}`); 11284 } catch (e) { 11285 exportedLogger = fakeLogger; 11286 } 11287 } else { 11288 exportedLogger = fakeLogger; 11289 } 11290} 11291var logger = exportedLogger; 11292var DECIMAL_RESOLUTION_REGEX = /^(\d+)x(\d+)$/; 11293var ATTR_LIST_REGEX = /(.+?)=(".*?"|.*?)(?:,|$)/g; 11294var AttrList = class _AttrList { 11295 constructor(attrs) { 11296 if (typeof attrs === "string") { 11297 attrs = _AttrList.parseAttrList(attrs); 11298 } 11299 _extends2(this, attrs); 11300 } 11301 get clientAttrs() { 11302 return Object.keys(this).filter((attr) => attr.substring(0, 2) === "X-"); 11303 } 11304 decimalInteger(attrName) { 11305 const intValue = parseInt(this[attrName], 10); 11306 if (intValue > Number.MAX_SAFE_INTEGER) { 11307 return Infinity; 11308 } 11309 return intValue; 11310 } 11311 hexadecimalInteger(attrName) { 11312 if (this[attrName]) { 11313 let stringValue = (this[attrName] || "0x").slice(2); 11314 stringValue = (stringValue.length & 1 ? "0" : "") + stringValue; 11315 const value = new Uint8Array(stringValue.length / 2); 11316 for (let i3 = 0; i3 < stringValue.length / 2; i3++) { 11317 value[i3] = parseInt(stringValue.slice(i3 * 2, i3 * 2 + 2), 16); 11318 } 11319 return value; 11320 } else { 11321 return null; 11322 } 11323 } 11324 hexadecimalIntegerAsNumber(attrName) { 11325 const intValue = parseInt(this[attrName], 16); 11326 if (intValue > Number.MAX_SAFE_INTEGER) { 11327 return Infinity; 11328 } 11329 return intValue; 11330 } 11331 decimalFloatingPoint(attrName) { 11332 return parseFloat(this[attrName]); 11333 } 11334 optionalFloat(attrName, defaultValue) { 11335 const value = this[attrName]; 11336 return value ? parseFloat(value) : defaultValue; 11337 } 11338 enumeratedString(attrName) { 11339 return this[attrName]; 11340 } 11341 bool(attrName) { 11342 return this[attrName] === "YES"; 11343 } 11344 decimalResolution(attrName) { 11345 const res = DECIMAL_RESOLUTION_REGEX.exec(this[attrName]); 11346 if (res === null) { 11347 return void 0; 11348 } 11349 return { 11350 width: parseInt(res[1], 10), 11351 height: parseInt(res[2], 10) 11352 }; 11353 } 11354 static parseAttrList(input) { 11355 let match2; 11356 const attrs = {}; 11357 const quote = '"'; 11358 ATTR_LIST_REGEX.lastIndex = 0; 11359 while ((match2 = ATTR_LIST_REGEX.exec(input)) !== null) { 11360 let value = match2[2]; 11361 if (value.indexOf(quote) === 0 && value.lastIndexOf(quote) === value.length - 1) { 11362 value = value.slice(1, -1); 11363 } 11364 const name = match2[1].trim(); 11365 attrs[name] = value; 11366 } 11367 return attrs; 11368 } 11369}; 11370function isDateRangeCueAttribute(attrName) { 11371 return attrName !== "ID" && attrName !== "CLASS" && attrName !== "START-DATE" && attrName !== "DURATION" && attrName !== "END-DATE" && attrName !== "END-ON-NEXT"; 11372} 11373function isSCTE35Attribute(attrName) { 11374 return attrName === "SCTE35-OUT" || attrName === "SCTE35-IN"; 11375} 11376var DateRange = class { 11377 constructor(dateRangeAttr, dateRangeWithSameId) { 11378 this.attr = void 0; 11379 this._startDate = void 0; 11380 this._endDate = void 0; 11381 this._badValueForSameId = void 0; 11382 if (dateRangeWithSameId) { 11383 const previousAttr = dateRangeWithSameId.attr; 11384 for (const key in previousAttr) { 11385 if (Object.prototype.hasOwnProperty.call(dateRangeAttr, key) && dateRangeAttr[key] !== previousAttr[key]) { 11386 logger.warn(`DATERANGE tag attribute: "${key}" does not match for tags with ID: "${dateRangeAttr.ID}"`); 11387 this._badValueForSameId = key; 11388 break; 11389 } 11390 } 11391 dateRangeAttr = _extends2(new AttrList({}), previousAttr, dateRangeAttr); 11392 } 11393 this.attr = dateRangeAttr; 11394 this._startDate = new Date(dateRangeAttr["START-DATE"]); 11395 if ("END-DATE" in this.attr) { 11396 const endDate = new Date(this.attr["END-DATE"]); 11397 if (isFiniteNumber(endDate.getTime())) { 11398 this._endDate = endDate; 11399 } 11400 } 11401 } 11402 get id() { 11403 return this.attr.ID; 11404 } 11405 get class() { 11406 return this.attr.CLASS; 11407 } 11408 get startDate() { 11409 return this._startDate; 11410 } 11411 get endDate() { 11412 if (this._endDate) { 11413 return this._endDate; 11414 } 11415 const duration = this.duration; 11416 if (duration !== null) { 11417 return new Date(this._startDate.getTime() + duration * 1e3); 11418 } 11419 return null; 11420 } 11421 get duration() { 11422 if ("DURATION" in this.attr) { 11423 const duration = this.attr.decimalFloatingPoint("DURATION"); 11424 if (isFiniteNumber(duration)) { 11425 return duration; 11426 } 11427 } else if (this._endDate) { 11428 return (this._endDate.getTime() - this._startDate.getTime()) / 1e3; 11429 } 11430 return null; 11431 } 11432 get plannedDuration() { 11433 if ("PLANNED-DURATION" in this.attr) { 11434 return this.attr.decimalFloatingPoint("PLANNED-DURATION"); 11435 } 11436 return null; 11437 } 11438 get endOnNext() { 11439 return this.attr.bool("END-ON-NEXT"); 11440 } 11441 get isValid() { 11442 return !!this.id && !this._badValueForSameId && isFiniteNumber(this.startDate.getTime()) && (this.duration === null || this.duration >= 0) && (!this.endOnNext || !!this.class); 11443 } 11444}; 11445var LoadStats = class { 11446 constructor() { 11447 this.aborted = false; 11448 this.loaded = 0; 11449 this.retry = 0; 11450 this.total = 0; 11451 this.chunkCount = 0; 11452 this.bwEstimate = 0; 11453 this.loading = { 11454 start: 0, 11455 first: 0, 11456 end: 0 11457 }; 11458 this.parsing = { 11459 start: 0, 11460 end: 0 11461 }; 11462 this.buffering = { 11463 start: 0, 11464 first: 0, 11465 end: 0 11466 }; 11467 } 11468}; 11469var ElementaryStreamTypes = { 11470 AUDIO: "audio", 11471 VIDEO: "video", 11472 AUDIOVIDEO: "audiovideo" 11473}; 11474var BaseSegment = class { 11475 constructor(baseurl) { 11476 this._byteRange = null; 11477 this._url = null; 11478 this.baseurl = void 0; 11479 this.relurl = void 0; 11480 this.elementaryStreams = { 11481 [ElementaryStreamTypes.AUDIO]: null, 11482 [ElementaryStreamTypes.VIDEO]: null, 11483 [ElementaryStreamTypes.AUDIOVIDEO]: null 11484 }; 11485 this.baseurl = baseurl; 11486 } 11487 // setByteRange converts a EXT-X-BYTERANGE attribute into a two element array 11488 setByteRange(value, previous) { 11489 const params = value.split("@", 2); 11490 let start; 11491 if (params.length === 1) { 11492 start = (previous == null ? void 0 : previous.byteRangeEndOffset) || 0; 11493 } else { 11494 start = parseInt(params[1]); 11495 } 11496 this._byteRange = [start, parseInt(params[0]) + start]; 11497 } 11498 get byteRange() { 11499 if (!this._byteRange) { 11500 return []; 11501 } 11502 return this._byteRange; 11503 } 11504 get byteRangeStartOffset() { 11505 return this.byteRange[0]; 11506 } 11507 get byteRangeEndOffset() { 11508 return this.byteRange[1]; 11509 } 11510 get url() { 11511 if (!this._url && this.baseurl && this.relurl) { 11512 this._url = urlToolkitExports.buildAbsoluteURL(this.baseurl, this.relurl, { 11513 alwaysNormalize: true 11514 }); 11515 } 11516 return this._url || ""; 11517 } 11518 set url(value) { 11519 this._url = value; 11520 } 11521}; 11522var Fragment4 = class extends BaseSegment { 11523 constructor(type, baseurl) { 11524 super(baseurl); 11525 this._decryptdata = null; 11526 this.rawProgramDateTime = null; 11527 this.programDateTime = null; 11528 this.tagList = []; 11529 this.duration = 0; 11530 this.sn = 0; 11531 this.levelkeys = void 0; 11532 this.type = void 0; 11533 this.loader = null; 11534 this.keyLoader = null; 11535 this.level = -1; 11536 this.cc = 0; 11537 this.startPTS = void 0; 11538 this.endPTS = void 0; 11539 this.startDTS = void 0; 11540 this.endDTS = void 0; 11541 this.start = 0; 11542 this.deltaPTS = void 0; 11543 this.maxStartPTS = void 0; 11544 this.minEndPTS = void 0; 11545 this.stats = new LoadStats(); 11546 this.data = void 0; 11547 this.bitrateTest = false; 11548 this.title = null; 11549 this.initSegment = null; 11550 this.endList = void 0; 11551 this.gap = void 0; 11552 this.urlId = 0; 11553 this.type = type; 11554 } 11555 get decryptdata() { 11556 const { 11557 levelkeys 11558 } = this; 11559 if (!levelkeys && !this._decryptdata) { 11560 return null; 11561 } 11562 if (!this._decryptdata && this.levelkeys && !this.levelkeys.NONE) { 11563 const key = this.levelkeys.identity; 11564 if (key) { 11565 this._decryptdata = key.getDecryptData(this.sn); 11566 } else { 11567 const keyFormats = Object.keys(this.levelkeys); 11568 if (keyFormats.length === 1) { 11569 return this._decryptdata = this.levelkeys[keyFormats[0]].getDecryptData(this.sn); 11570 } 11571 } 11572 } 11573 return this._decryptdata; 11574 } 11575 get end() { 11576 return this.start + this.duration; 11577 } 11578 get endProgramDateTime() { 11579 if (this.programDateTime === null) { 11580 return null; 11581 } 11582 if (!isFiniteNumber(this.programDateTime)) { 11583 return null; 11584 } 11585 const duration = !isFiniteNumber(this.duration) ? 0 : this.duration; 11586 return this.programDateTime + duration * 1e3; 11587 } 11588 get encrypted() { 11589 var _this$_decryptdata; 11590 if ((_this$_decryptdata = this._decryptdata) != null && _this$_decryptdata.encrypted) { 11591 return true; 11592 } else if (this.levelkeys) { 11593 const keyFormats = Object.keys(this.levelkeys); 11594 const len = keyFormats.length; 11595 if (len > 1 || len === 1 && this.levelkeys[keyFormats[0]].encrypted) { 11596 return true; 11597 } 11598 } 11599 return false; 11600 } 11601 setKeyFormat(keyFormat) { 11602 if (this.levelkeys) { 11603 const key = this.levelkeys[keyFormat]; 11604 if (key && !this._decryptdata) { 11605 this._decryptdata = key.getDecryptData(this.sn); 11606 } 11607 } 11608 } 11609 abortRequests() { 11610 var _this$loader, _this$keyLoader; 11611 (_this$loader = this.loader) == null ? void 0 : _this$loader.abort(); 11612 (_this$keyLoader = this.keyLoader) == null ? void 0 : _this$keyLoader.abort(); 11613 } 11614 setElementaryStreamInfo(type, startPTS, endPTS, startDTS, endDTS, partial = false) { 11615 const { 11616 elementaryStreams 11617 } = this; 11618 const info = elementaryStreams[type]; 11619 if (!info) { 11620 elementaryStreams[type] = { 11621 startPTS, 11622 endPTS, 11623 startDTS, 11624 endDTS, 11625 partial 11626 }; 11627 return; 11628 } 11629 info.startPTS = Math.min(info.startPTS, startPTS); 11630 info.endPTS = Math.max(info.endPTS, endPTS); 11631 info.startDTS = Math.min(info.startDTS, startDTS); 11632 info.endDTS = Math.max(info.endDTS, endDTS); 11633 } 11634 clearElementaryStreamInfo() { 11635 const { 11636 elementaryStreams 11637 } = this; 11638 elementaryStreams[ElementaryStreamTypes.AUDIO] = null; 11639 elementaryStreams[ElementaryStreamTypes.VIDEO] = null; 11640 elementaryStreams[ElementaryStreamTypes.AUDIOVIDEO] = null; 11641 } 11642}; 11643var Part = class extends BaseSegment { 11644 constructor(partAttrs, frag, baseurl, index2, previous) { 11645 super(baseurl); 11646 this.fragOffset = 0; 11647 this.duration = 0; 11648 this.gap = false; 11649 this.independent = false; 11650 this.relurl = void 0; 11651 this.fragment = void 0; 11652 this.index = void 0; 11653 this.stats = new LoadStats(); 11654 this.duration = partAttrs.decimalFloatingPoint("DURATION"); 11655 this.gap = partAttrs.bool("GAP"); 11656 this.independent = partAttrs.bool("INDEPENDENT"); 11657 this.relurl = partAttrs.enumeratedString("URI"); 11658 this.fragment = frag; 11659 this.index = index2; 11660 const byteRange = partAttrs.enumeratedString("BYTERANGE"); 11661 if (byteRange) { 11662 this.setByteRange(byteRange, previous); 11663 } 11664 if (previous) { 11665 this.fragOffset = previous.fragOffset + previous.duration; 11666 } 11667 } 11668 get start() { 11669 return this.fragment.start + this.fragOffset; 11670 } 11671 get end() { 11672 return this.start + this.duration; 11673 } 11674 get loaded() { 11675 const { 11676 elementaryStreams 11677 } = this; 11678 return !!(elementaryStreams.audio || elementaryStreams.video || elementaryStreams.audiovideo); 11679 } 11680}; 11681var DEFAULT_TARGET_DURATION = 10; 11682var LevelDetails = class { 11683 constructor(baseUrl) { 11684 this.PTSKnown = false; 11685 this.alignedSliding = false; 11686 this.averagetargetduration = void 0; 11687 this.endCC = 0; 11688 this.endSN = 0; 11689 this.fragments = void 0; 11690 this.fragmentHint = void 0; 11691 this.partList = null; 11692 this.dateRanges = void 0; 11693 this.live = true; 11694 this.ageHeader = 0; 11695 this.advancedDateTime = void 0; 11696 this.updated = true; 11697 this.advanced = true; 11698 this.availabilityDelay = void 0; 11699 this.misses = 0; 11700 this.startCC = 0; 11701 this.startSN = 0; 11702 this.startTimeOffset = null; 11703 this.targetduration = 0; 11704 this.totalduration = 0; 11705 this.type = null; 11706 this.url = void 0; 11707 this.m3u8 = ""; 11708 this.version = null; 11709 this.canBlockReload = false; 11710 this.canSkipUntil = 0; 11711 this.canSkipDateRanges = false; 11712 this.skippedSegments = 0; 11713 this.recentlyRemovedDateranges = void 0; 11714 this.partHoldBack = 0; 11715 this.holdBack = 0; 11716 this.partTarget = 0; 11717 this.preloadHint = void 0; 11718 this.renditionReports = void 0; 11719 this.tuneInGoal = 0; 11720 this.deltaUpdateFailed = void 0; 11721 this.driftStartTime = 0; 11722 this.driftEndTime = 0; 11723 this.driftStart = 0; 11724 this.driftEnd = 0; 11725 this.encryptedFragments = void 0; 11726 this.playlistParsingError = null; 11727 this.variableList = null; 11728 this.hasVariableRefs = false; 11729 this.fragments = []; 11730 this.encryptedFragments = []; 11731 this.dateRanges = {}; 11732 this.url = baseUrl; 11733 } 11734 reloaded(previous) { 11735 if (!previous) { 11736 this.advanced = true; 11737 this.updated = true; 11738 return; 11739 } 11740 const partSnDiff = this.lastPartSn - previous.lastPartSn; 11741 const partIndexDiff = this.lastPartIndex - previous.lastPartIndex; 11742 this.updated = this.endSN !== previous.endSN || !!partIndexDiff || !!partSnDiff || !this.live; 11743 this.advanced = this.endSN > previous.endSN || partSnDiff > 0 || partSnDiff === 0 && partIndexDiff > 0; 11744 if (this.updated || this.advanced) { 11745 this.misses = Math.floor(previous.misses * 0.6); 11746 } else { 11747 this.misses = previous.misses + 1; 11748 } 11749 this.availabilityDelay = previous.availabilityDelay; 11750 } 11751 get hasProgramDateTime() { 11752 if (this.fragments.length) { 11753 return isFiniteNumber(this.fragments[this.fragments.length - 1].programDateTime); 11754 } 11755 return false; 11756 } 11757 get levelTargetDuration() { 11758 return this.averagetargetduration || this.targetduration || DEFAULT_TARGET_DURATION; 11759 } 11760 get drift() { 11761 const runTime = this.driftEndTime - this.driftStartTime; 11762 if (runTime > 0) { 11763 const runDuration = this.driftEnd - this.driftStart; 11764 return runDuration * 1e3 / runTime; 11765 } 11766 return 1; 11767 } 11768 get edge() { 11769 return this.partEnd || this.fragmentEnd; 11770 } 11771 get partEnd() { 11772 var _this$partList; 11773 if ((_this$partList = this.partList) != null && _this$partList.length) { 11774 return this.partList[this.partList.length - 1].end; 11775 } 11776 return this.fragmentEnd; 11777 } 11778 get fragmentEnd() { 11779 var _this$fragments; 11780 if ((_this$fragments = this.fragments) != null && _this$fragments.length) { 11781 return this.fragments[this.fragments.length - 1].end; 11782 } 11783 return 0; 11784 } 11785 get age() { 11786 if (this.advancedDateTime) { 11787 return Math.max(Date.now() - this.advancedDateTime, 0) / 1e3; 11788 } 11789 return 0; 11790 } 11791 get lastPartIndex() { 11792 var _this$partList2; 11793 if ((_this$partList2 = this.partList) != null && _this$partList2.length) { 11794 return this.partList[this.partList.length - 1].index; 11795 } 11796 return -1; 11797 } 11798 get lastPartSn() { 11799 var _this$partList3; 11800 if ((_this$partList3 = this.partList) != null && _this$partList3.length) { 11801 return this.partList[this.partList.length - 1].fragment.sn; 11802 } 11803 return this.endSN; 11804 } 11805}; 11806function base64Decode(base64encodedStr) { 11807 return Uint8Array.from(atob(base64encodedStr), (c3) => c3.charCodeAt(0)); 11808} 11809function getKeyIdBytes(str) { 11810 const keyIdbytes = strToUtf8array(str).subarray(0, 16); 11811 const paddedkeyIdbytes = new Uint8Array(16); 11812 paddedkeyIdbytes.set(keyIdbytes, 16 - keyIdbytes.length); 11813 return paddedkeyIdbytes; 11814} 11815function changeEndianness(keyId) { 11816 const swap = function swap2(array, from2, to) { 11817 const cur = array[from2]; 11818 array[from2] = array[to]; 11819 array[to] = cur; 11820 }; 11821 swap(keyId, 0, 3); 11822 swap(keyId, 1, 2); 11823 swap(keyId, 4, 5); 11824 swap(keyId, 6, 7); 11825} 11826function convertDataUriToArrayBytes(uri) { 11827 const colonsplit = uri.split(":"); 11828 let keydata = null; 11829 if (colonsplit[0] === "data" && colonsplit.length === 2) { 11830 const semicolonsplit = colonsplit[1].split(";"); 11831 const commasplit = semicolonsplit[semicolonsplit.length - 1].split(","); 11832 if (commasplit.length === 2) { 11833 const isbase64 = commasplit[0] === "base64"; 11834 const data = commasplit[1]; 11835 if (isbase64) { 11836 semicolonsplit.splice(-1, 1); 11837 keydata = base64Decode(data); 11838 } else { 11839 keydata = getKeyIdBytes(data); 11840 } 11841 } 11842 } 11843 return keydata; 11844} 11845function strToUtf8array(str) { 11846 return Uint8Array.from(unescape(encodeURIComponent(str)), (c3) => c3.charCodeAt(0)); 11847} 11848var optionalSelf = typeof self !== "undefined" ? self : void 0; 11849var KeySystems = { 11850 CLEARKEY: "org.w3.clearkey", 11851 FAIRPLAY: "com.apple.fps", 11852 PLAYREADY: "com.microsoft.playready", 11853 WIDEVINE: "com.widevine.alpha" 11854}; 11855var KeySystemFormats = { 11856 CLEARKEY: "org.w3.clearkey", 11857 FAIRPLAY: "com.apple.streamingkeydelivery", 11858 PLAYREADY: "com.microsoft.playready", 11859 WIDEVINE: "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed" 11860}; 11861function keySystemFormatToKeySystemDomain(format2) { 11862 switch (format2) { 11863 case KeySystemFormats.FAIRPLAY: 11864 return KeySystems.FAIRPLAY; 11865 case KeySystemFormats.PLAYREADY: 11866 return KeySystems.PLAYREADY; 11867 case KeySystemFormats.WIDEVINE: 11868 return KeySystems.WIDEVINE; 11869 case KeySystemFormats.CLEARKEY: 11870 return KeySystems.CLEARKEY; 11871 } 11872} 11873var KeySystemIds = { 11874 CENC: "1077efecc0b24d02ace33c1e52e2fb4b", 11875 CLEARKEY: "e2719d58a985b3c9781ab030af78d30e", 11876 FAIRPLAY: "94ce86fb07ff4f43adb893d2fa968ca2", 11877 PLAYREADY: "9a04f07998404286ab92e65be0885f95", 11878 WIDEVINE: "edef8ba979d64acea3c827dcd51d21ed" 11879}; 11880function keySystemIdToKeySystemDomain(systemId) { 11881 if (systemId === KeySystemIds.WIDEVINE) { 11882 return KeySystems.WIDEVINE; 11883 } else if (systemId === KeySystemIds.PLAYREADY) { 11884 return KeySystems.PLAYREADY; 11885 } else if (systemId === KeySystemIds.CENC || systemId === KeySystemIds.CLEARKEY) { 11886 return KeySystems.CLEARKEY; 11887 } 11888} 11889function keySystemDomainToKeySystemFormat(keySystem) { 11890 switch (keySystem) { 11891 case KeySystems.FAIRPLAY: 11892 return KeySystemFormats.FAIRPLAY; 11893 case KeySystems.PLAYREADY: 11894 return KeySystemFormats.PLAYREADY; 11895 case KeySystems.WIDEVINE: 11896 return KeySystemFormats.WIDEVINE; 11897 case KeySystems.CLEARKEY: 11898 return KeySystemFormats.CLEARKEY; 11899 } 11900} 11901function getKeySystemsForConfig(config) { 11902 const { 11903 drmSystems, 11904 widevineLicenseUrl 11905 } = config; 11906 const keySystemsToAttempt = drmSystems ? [KeySystems.FAIRPLAY, KeySystems.WIDEVINE, KeySystems.PLAYREADY, KeySystems.CLEARKEY].filter((keySystem) => !!drmSystems[keySystem]) : []; 11907 if (!keySystemsToAttempt[KeySystems.WIDEVINE] && widevineLicenseUrl) { 11908 keySystemsToAttempt.push(KeySystems.WIDEVINE); 11909 } 11910 return keySystemsToAttempt; 11911} 11912var requestMediaKeySystemAccess = function(_optionalSelf$navigat) { 11913 if (optionalSelf != null && (_optionalSelf$navigat = optionalSelf.navigator) != null && _optionalSelf$navigat.requestMediaKeySystemAccess) { 11914 return self.navigator.requestMediaKeySystemAccess.bind(self.navigator); 11915 } else { 11916 return null; 11917 } 11918}(); 11919function getSupportedMediaKeySystemConfigurations(keySystem, audioCodecs, videoCodecs, drmSystemOptions) { 11920 let initDataTypes; 11921 switch (keySystem) { 11922 case KeySystems.FAIRPLAY: 11923 initDataTypes = ["cenc", "sinf"]; 11924 break; 11925 case KeySystems.WIDEVINE: 11926 case KeySystems.PLAYREADY: 11927 initDataTypes = ["cenc"]; 11928 break; 11929 case KeySystems.CLEARKEY: 11930 initDataTypes = ["cenc", "keyids"]; 11931 break; 11932 default: 11933 throw new Error(`Unknown key-system: ${keySystem}`); 11934 } 11935 return createMediaKeySystemConfigurations(initDataTypes, audioCodecs, videoCodecs, drmSystemOptions); 11936} 11937function createMediaKeySystemConfigurations(initDataTypes, audioCodecs, videoCodecs, drmSystemOptions) { 11938 const baseConfig = { 11939 initDataTypes, 11940 persistentState: drmSystemOptions.persistentState || "optional", 11941 distinctiveIdentifier: drmSystemOptions.distinctiveIdentifier || "optional", 11942 sessionTypes: drmSystemOptions.sessionTypes || [drmSystemOptions.sessionType || "temporary"], 11943 audioCapabilities: audioCodecs.map((codec) => ({ 11944 contentType: `audio/mp4; codecs="${codec}"`, 11945 robustness: drmSystemOptions.audioRobustness || "", 11946 encryptionScheme: drmSystemOptions.audioEncryptionScheme || null 11947 })), 11948 videoCapabilities: videoCodecs.map((codec) => ({ 11949 contentType: `video/mp4; codecs="${codec}"`, 11950 robustness: drmSystemOptions.videoRobustness || "", 11951 encryptionScheme: drmSystemOptions.videoEncryptionScheme || null 11952 })) 11953 }; 11954 return [baseConfig]; 11955} 11956function parsePlayReadyWRM(keyBytes) { 11957 const keyBytesUtf16 = new Uint16Array(keyBytes.buffer, keyBytes.byteOffset, keyBytes.byteLength / 2); 11958 const keyByteStr = String.fromCharCode.apply(null, Array.from(keyBytesUtf16)); 11959 const xmlKeyBytes = keyByteStr.substring(keyByteStr.indexOf("<"), keyByteStr.length); 11960 const parser = new DOMParser(); 11961 const xmlDoc = parser.parseFromString(xmlKeyBytes, "text/xml"); 11962 const keyData = xmlDoc.getElementsByTagName("KID")[0]; 11963 if (keyData) { 11964 const keyId = keyData.childNodes[0] ? keyData.childNodes[0].nodeValue : keyData.getAttribute("VALUE"); 11965 if (keyId) { 11966 const keyIdArray = base64Decode(keyId).subarray(0, 16); 11967 changeEndianness(keyIdArray); 11968 return keyIdArray; 11969 } 11970 } 11971 return null; 11972} 11973function sliceUint8(array, start, end) { 11974 return Uint8Array.prototype.slice ? array.slice(start, end) : new Uint8Array(Array.prototype.slice.call(array, start, end)); 11975} 11976var isHeader$2 = (data, offset) => { 11977 if (offset + 10 <= data.length) { 11978 if (data[offset] === 73 && data[offset + 1] === 68 && data[offset + 2] === 51) { 11979 if (data[offset + 3] < 255 && data[offset + 4] < 255) { 11980 if (data[offset + 6] < 128 && data[offset + 7] < 128 && data[offset + 8] < 128 && data[offset + 9] < 128) { 11981 return true; 11982 } 11983 } 11984 } 11985 } 11986 return false; 11987}; 11988var isFooter = (data, offset) => { 11989 if (offset + 10 <= data.length) { 11990 if (data[offset] === 51 && data[offset + 1] === 68 && data[offset + 2] === 73) { 11991 if (data[offset + 3] < 255 && data[offset + 4] < 255) { 11992 if (data[offset + 6] < 128 && data[offset + 7] < 128 && data[offset + 8] < 128 && data[offset + 9] < 128) { 11993 return true; 11994 } 11995 } 11996 } 11997 } 11998 return false; 11999}; 12000var getID3Data = (data, offset) => { 12001 const front = offset; 12002 let length2 = 0; 12003 while (isHeader$2(data, offset)) { 12004 length2 += 10; 12005 const size = readSize(data, offset + 6); 12006 length2 += size; 12007 if (isFooter(data, offset + 10)) { 12008 length2 += 10; 12009 } 12010 offset += length2; 12011 } 12012 if (length2 > 0) { 12013 return data.subarray(front, front + length2); 12014 } 12015 return void 0; 12016}; 12017var readSize = (data, offset) => { 12018 let size = 0; 12019 size = (data[offset] & 127) << 21; 12020 size |= (data[offset + 1] & 127) << 14; 12021 size |= (data[offset + 2] & 127) << 7; 12022 size |= data[offset + 3] & 127; 12023 return size; 12024}; 12025var canParse$2 = (data, offset) => { 12026 return isHeader$2(data, offset) && readSize(data, offset + 6) + 10 <= data.length - offset; 12027}; 12028var getTimeStamp = (data) => { 12029 const frames = getID3Frames(data); 12030 for (let i3 = 0; i3 < frames.length; i3++) { 12031 const frame = frames[i3]; 12032 if (isTimeStampFrame(frame)) { 12033 return readTimeStamp(frame); 12034 } 12035 } 12036 return void 0; 12037}; 12038var isTimeStampFrame = (frame) => { 12039 return frame && frame.key === "PRIV" && frame.info === "com.apple.streaming.transportStreamTimestamp"; 12040}; 12041var getFrameData = (data) => { 12042 const type = String.fromCharCode(data[0], data[1], data[2], data[3]); 12043 const size = readSize(data, 4); 12044 const offset = 10; 12045 return { 12046 type, 12047 size, 12048 data: data.subarray(offset, offset + size) 12049 }; 12050}; 12051var getID3Frames = (id3Data) => { 12052 let offset = 0; 12053 const frames = []; 12054 while (isHeader$2(id3Data, offset)) { 12055 const size = readSize(id3Data, offset + 6); 12056 offset += 10; 12057 const end = offset + size; 12058 while (offset + 8 < end) { 12059 const frameData = getFrameData(id3Data.subarray(offset)); 12060 const frame = decodeFrame(frameData); 12061 if (frame) { 12062 frames.push(frame); 12063 } 12064 offset += frameData.size + 10; 12065 } 12066 if (isFooter(id3Data, offset)) { 12067 offset += 10; 12068 } 12069 } 12070 return frames; 12071}; 12072var decodeFrame = (frame) => { 12073 if (frame.type === "PRIV") { 12074 return decodePrivFrame(frame); 12075 } else if (frame.type[0] === "W") { 12076 return decodeURLFrame(frame); 12077 } 12078 return decodeTextFrame(frame); 12079}; 12080var decodePrivFrame = (frame) => { 12081 if (frame.size < 2) { 12082 return void 0; 12083 } 12084 const owner = utf8ArrayToStr(frame.data, true); 12085 const privateData = new Uint8Array(frame.data.subarray(owner.length + 1)); 12086 return { 12087 key: frame.type, 12088 info: owner, 12089 data: privateData.buffer 12090 }; 12091}; 12092var decodeTextFrame = (frame) => { 12093 if (frame.size < 2) { 12094 return void 0; 12095 } 12096 if (frame.type === "TXXX") { 12097 let index2 = 1; 12098 const description = utf8ArrayToStr(frame.data.subarray(index2), true); 12099 index2 += description.length + 1; 12100 const value = utf8ArrayToStr(frame.data.subarray(index2)); 12101 return { 12102 key: frame.type, 12103 info: description, 12104 data: value 12105 }; 12106 } 12107 const text = utf8ArrayToStr(frame.data.subarray(1)); 12108 return { 12109 key: frame.type, 12110 data: text 12111 }; 12112}; 12113var decodeURLFrame = (frame) => { 12114 if (frame.type === "WXXX") { 12115 if (frame.size < 2) { 12116 return void 0; 12117 } 12118 let index2 = 1; 12119 const description = utf8ArrayToStr(frame.data.subarray(index2), true); 12120 index2 += description.length + 1; 12121 const value = utf8ArrayToStr(frame.data.subarray(index2)); 12122 return { 12123 key: frame.type, 12124 info: description, 12125 data: value 12126 }; 12127 } 12128 const url = utf8ArrayToStr(frame.data); 12129 return { 12130 key: frame.type, 12131 data: url 12132 }; 12133}; 12134var readTimeStamp = (timeStampFrame) => { 12135 if (timeStampFrame.data.byteLength === 8) { 12136 const data = new Uint8Array(timeStampFrame.data); 12137 const pts33Bit = data[3] & 1; 12138 let timestamp = (data[4] << 23) + (data[5] << 15) + (data[6] << 7) + data[7]; 12139 timestamp /= 45; 12140 if (pts33Bit) { 12141 timestamp += 4772185884e-2; 12142 } 12143 return Math.round(timestamp); 12144 } 12145 return void 0; 12146}; 12147var utf8ArrayToStr = (array, exitOnNull = false) => { 12148 const decoder2 = getTextDecoder(); 12149 if (decoder2) { 12150 const decoded = decoder2.decode(array); 12151 if (exitOnNull) { 12152 const idx = decoded.indexOf("\0"); 12153 return idx !== -1 ? decoded.substring(0, idx) : decoded; 12154 } 12155 return decoded.replace(/\0/g, ""); 12156 } 12157 const len = array.length; 12158 let c3; 12159 let char2; 12160 let char3; 12161 let out = ""; 12162 let i3 = 0; 12163 while (i3 < len) { 12164 c3 = array[i3++]; 12165 if (c3 === 0 && exitOnNull) { 12166 return out; 12167 } else if (c3 === 0 || c3 === 3) { 12168 continue; 12169 } 12170 switch (c3 >> 4) { 12171 case 0: 12172 case 1: 12173 case 2: 12174 case 3: 12175 case 4: 12176 case 5: 12177 case 6: 12178 case 7: 12179 out += String.fromCharCode(c3); 12180 break; 12181 case 12: 12182 case 13: 12183 char2 = array[i3++]; 12184 out += String.fromCharCode((c3 & 31) << 6 | char2 & 63); 12185 break; 12186 case 14: 12187 char2 = array[i3++]; 12188 char3 = array[i3++]; 12189 out += String.fromCharCode((c3 & 15) << 12 | (char2 & 63) << 6 | (char3 & 63) << 0); 12190 break; 12191 } 12192 } 12193 return out; 12194}; 12195var decoder; 12196function getTextDecoder() { 12197 if (navigator.userAgent.includes("PlayStation 4")) { 12198 return; 12199 } 12200 if (!decoder && typeof self.TextDecoder !== "undefined") { 12201 decoder = new self.TextDecoder("utf-8"); 12202 } 12203 return decoder; 12204} 12205var Hex = { 12206 hexDump: function(array) { 12207 let str = ""; 12208 for (let i3 = 0; i3 < array.length; i3++) { 12209 let h3 = array[i3].toString(16); 12210 if (h3.length < 2) { 12211 h3 = "0" + h3; 12212 } 12213 str += h3; 12214 } 12215 return str; 12216 } 12217}; 12218var UINT32_MAX$1 = Math.pow(2, 32) - 1; 12219var push = [].push; 12220var RemuxerTrackIdConfig = { 12221 video: 1, 12222 audio: 2, 12223 id3: 3, 12224 text: 4 12225}; 12226function bin2str(data) { 12227 return String.fromCharCode.apply(null, data); 12228} 12229function readUint16(buffer, offset) { 12230 const val = buffer[offset] << 8 | buffer[offset + 1]; 12231 return val < 0 ? 65536 + val : val; 12232} 12233function readUint32(buffer, offset) { 12234 const val = readSint32(buffer, offset); 12235 return val < 0 ? 4294967296 + val : val; 12236} 12237function readUint64(buffer, offset) { 12238 let result = readUint32(buffer, offset); 12239 result *= Math.pow(2, 32); 12240 result += readUint32(buffer, offset + 4); 12241 return result; 12242} 12243function readSint32(buffer, offset) { 12244 return buffer[offset] << 24 | buffer[offset + 1] << 16 | buffer[offset + 2] << 8 | buffer[offset + 3]; 12245} 12246function writeUint32(buffer, offset, value) { 12247 buffer[offset] = value >> 24; 12248 buffer[offset + 1] = value >> 16 & 255; 12249 buffer[offset + 2] = value >> 8 & 255; 12250 buffer[offset + 3] = value & 255; 12251} 12252function hasMoofData(data) { 12253 const end = data.byteLength; 12254 for (let i3 = 0; i3 < end; ) { 12255 const size = readUint32(data, i3); 12256 if (size > 8 && data[i3 + 4] === 109 && data[i3 + 5] === 111 && data[i3 + 6] === 111 && data[i3 + 7] === 102) { 12257 return true; 12258 } 12259 i3 = size > 1 ? i3 + size : end; 12260 } 12261 return false; 12262} 12263function findBox(data, path) { 12264 const results = []; 12265 if (!path.length) { 12266 return results; 12267 } 12268 const end = data.byteLength; 12269 for (let i3 = 0; i3 < end; ) { 12270 const size = readUint32(data, i3); 12271 const type = bin2str(data.subarray(i3 + 4, i3 + 8)); 12272 const endbox = size > 1 ? i3 + size : end; 12273 if (type === path[0]) { 12274 if (path.length === 1) { 12275 results.push(data.subarray(i3 + 8, endbox)); 12276 } else { 12277 const subresults = findBox(data.subarray(i3 + 8, endbox), path.slice(1)); 12278 if (subresults.length) { 12279 push.apply(results, subresults); 12280 } 12281 } 12282 } 12283 i3 = endbox; 12284 } 12285 return results; 12286} 12287function parseSegmentIndex(sidx) { 12288 const references = []; 12289 const version = sidx[0]; 12290 let index2 = 8; 12291 const timescale = readUint32(sidx, index2); 12292 index2 += 4; 12293 let earliestPresentationTime = 0; 12294 let firstOffset = 0; 12295 if (version === 0) { 12296 earliestPresentationTime = readUint32(sidx, index2); 12297 firstOffset = readUint32(sidx, index2 + 4); 12298 index2 += 8; 12299 } else { 12300 earliestPresentationTime = readUint64(sidx, index2); 12301 firstOffset = readUint64(sidx, index2 + 8); 12302 index2 += 16; 12303 } 12304 index2 += 2; 12305 let startByte = sidx.length + firstOffset; 12306 const referencesCount = readUint16(sidx, index2); 12307 index2 += 2; 12308 for (let i3 = 0; i3 < referencesCount; i3++) { 12309 let referenceIndex = index2; 12310 const referenceInfo = readUint32(sidx, referenceIndex); 12311 referenceIndex += 4; 12312 const referenceSize = referenceInfo & 2147483647; 12313 const referenceType = (referenceInfo & 2147483648) >>> 31; 12314 if (referenceType === 1) { 12315 logger.warn("SIDX has hierarchical references (not supported)"); 12316 return null; 12317 } 12318 const subsegmentDuration = readUint32(sidx, referenceIndex); 12319 referenceIndex += 4; 12320 references.push({ 12321 referenceSize, 12322 subsegmentDuration, 12323 // unscaled 12324 info: { 12325 duration: subsegmentDuration / timescale, 12326 start: startByte, 12327 end: startByte + referenceSize - 1 12328 } 12329 }); 12330 startByte += referenceSize; 12331 referenceIndex += 4; 12332 index2 = referenceIndex; 12333 } 12334 return { 12335 earliestPresentationTime, 12336 timescale, 12337 version, 12338 referencesCount, 12339 references 12340 }; 12341} 12342function parseInitSegment(initSegment) { 12343 const result = []; 12344 const traks = findBox(initSegment, ["moov", "trak"]); 12345 for (let i3 = 0; i3 < traks.length; i3++) { 12346 const trak = traks[i3]; 12347 const tkhd = findBox(trak, ["tkhd"])[0]; 12348 if (tkhd) { 12349 let version = tkhd[0]; 12350 const trackId = readUint32(tkhd, version === 0 ? 12 : 20); 12351 const mdhd = findBox(trak, ["mdia", "mdhd"])[0]; 12352 if (mdhd) { 12353 version = mdhd[0]; 12354 const timescale = readUint32(mdhd, version === 0 ? 12 : 20); 12355 const hdlr = findBox(trak, ["mdia", "hdlr"])[0]; 12356 if (hdlr) { 12357 const hdlrType = bin2str(hdlr.subarray(8, 12)); 12358 const type = { 12359 soun: ElementaryStreamTypes.AUDIO, 12360 vide: ElementaryStreamTypes.VIDEO 12361 }[hdlrType]; 12362 if (type) { 12363 const stsd = findBox(trak, ["mdia", "minf", "stbl", "stsd"])[0]; 12364 const stsdData = parseStsd(stsd); 12365 result[trackId] = { 12366 timescale, 12367 type 12368 }; 12369 result[type] = _objectSpread23({ 12370 timescale, 12371 id: trackId 12372 }, stsdData); 12373 } 12374 } 12375 } 12376 } 12377 } 12378 const trex = findBox(initSegment, ["moov", "mvex", "trex"]); 12379 trex.forEach((trex2) => { 12380 const trackId = readUint32(trex2, 4); 12381 const track = result[trackId]; 12382 if (track) { 12383 track.default = { 12384 duration: readUint32(trex2, 12), 12385 flags: readUint32(trex2, 20) 12386 }; 12387 } 12388 }); 12389 return result; 12390} 12391function parseStsd(stsd) { 12392 const sampleEntries = stsd.subarray(8); 12393 const sampleEntriesEnd = sampleEntries.subarray(8 + 78); 12394 const fourCC = bin2str(sampleEntries.subarray(4, 8)); 12395 let codec = fourCC; 12396 const encrypted = fourCC === "enca" || fourCC === "encv"; 12397 if (encrypted) { 12398 const encBox = findBox(sampleEntries, [fourCC])[0]; 12399 const encBoxChildren = encBox.subarray(fourCC === "enca" ? 28 : 78); 12400 const sinfs = findBox(encBoxChildren, ["sinf"]); 12401 sinfs.forEach((sinf) => { 12402 const schm = findBox(sinf, ["schm"])[0]; 12403 if (schm) { 12404 const scheme = bin2str(schm.subarray(4, 8)); 12405 if (scheme === "cbcs" || scheme === "cenc") { 12406 const frma = findBox(sinf, ["frma"])[0]; 12407 if (frma) { 12408 codec = bin2str(frma); 12409 } 12410 } 12411 } 12412 }); 12413 } 12414 switch (codec) { 12415 case "avc1": 12416 case "avc2": 12417 case "avc3": 12418 case "avc4": { 12419 const avcCBox = findBox(sampleEntriesEnd, ["avcC"])[0]; 12420 codec += "." + toHex(avcCBox[1]) + toHex(avcCBox[2]) + toHex(avcCBox[3]); 12421 break; 12422 } 12423 case "mp4a": { 12424 const codecBox = findBox(sampleEntries, [fourCC])[0]; 12425 const esdsBox = findBox(codecBox.subarray(28), ["esds"])[0]; 12426 if (esdsBox && esdsBox.length > 12) { 12427 let i3 = 4; 12428 if (esdsBox[i3++] !== 3) { 12429 break; 12430 } 12431 i3 = skipBERInteger(esdsBox, i3); 12432 i3 += 2; 12433 const flags = esdsBox[i3++]; 12434 if (flags & 128) { 12435 i3 += 2; 12436 } 12437 if (flags & 64) { 12438 i3 += esdsBox[i3++]; 12439 } 12440 if (esdsBox[i3++] !== 4) { 12441 break; 12442 } 12443 i3 = skipBERInteger(esdsBox, i3); 12444 const objectType = esdsBox[i3++]; 12445 if (objectType === 64) { 12446 codec += "." + toHex(objectType); 12447 } else { 12448 break; 12449 } 12450 i3 += 12; 12451 if (esdsBox[i3++] !== 5) { 12452 break; 12453 } 12454 i3 = skipBERInteger(esdsBox, i3); 12455 const firstByte = esdsBox[i3++]; 12456 let audioObjectType = (firstByte & 248) >> 3; 12457 if (audioObjectType === 31) { 12458 audioObjectType += 1 + ((firstByte & 7) << 3) + ((esdsBox[i3] & 224) >> 5); 12459 } 12460 codec += "." + audioObjectType; 12461 } 12462 break; 12463 } 12464 case "hvc1": 12465 case "hev1": { 12466 const hvcCBox = findBox(sampleEntriesEnd, ["hvcC"])[0]; 12467 const profileByte = hvcCBox[1]; 12468 const profileSpace = ["", "A", "B", "C"][profileByte >> 6]; 12469 const generalProfileIdc = profileByte & 31; 12470 const profileCompat = readUint32(hvcCBox, 2); 12471 const tierFlag = (profileByte & 32) >> 5 ? "H" : "L"; 12472 const levelIDC = hvcCBox[12]; 12473 const constraintIndicator = hvcCBox.subarray(6, 12); 12474 codec += "." + profileSpace + generalProfileIdc; 12475 codec += "." + profileCompat.toString(16).toUpperCase(); 12476 codec += "." + tierFlag + levelIDC; 12477 let constraintString = ""; 12478 for (let i3 = constraintIndicator.length; i3--; ) { 12479 const byte = constraintIndicator[i3]; 12480 if (byte || constraintString) { 12481 const encodedByte = byte.toString(16).toUpperCase(); 12482 constraintString = "." + encodedByte + constraintString; 12483 } 12484 } 12485 codec += constraintString; 12486 break; 12487 } 12488 case "dvh1": 12489 case "dvhe": { 12490 const dvcCBox = findBox(sampleEntriesEnd, ["dvcC"])[0]; 12491 const profile = dvcCBox[2] >> 1 & 127; 12492 const level = dvcCBox[2] << 5 & 32 | dvcCBox[3] >> 3 & 31; 12493 codec += "." + addLeadingZero(profile) + "." + addLeadingZero(level); 12494 break; 12495 } 12496 case "vp09": { 12497 const vpcCBox = findBox(sampleEntriesEnd, ["vpcC"])[0]; 12498 const profile = vpcCBox[4]; 12499 const level = vpcCBox[5]; 12500 const bitDepth = vpcCBox[6] >> 4 & 15; 12501 codec += "." + addLeadingZero(profile) + "." + addLeadingZero(level) + "." + addLeadingZero(bitDepth); 12502 break; 12503 } 12504 case "av01": { 12505 const av1CBox = findBox(sampleEntriesEnd, ["av1C"])[0]; 12506 const profile = av1CBox[1] >>> 5; 12507 const level = av1CBox[1] & 31; 12508 const tierFlag = av1CBox[2] >>> 7 ? "H" : "M"; 12509 const highBitDepth = (av1CBox[2] & 64) >> 6; 12510 const twelveBit = (av1CBox[2] & 32) >> 5; 12511 const bitDepth = profile === 2 && highBitDepth ? twelveBit ? 12 : 10 : highBitDepth ? 10 : 8; 12512 const monochrome = (av1CBox[2] & 16) >> 4; 12513 const chromaSubsamplingX = (av1CBox[2] & 8) >> 3; 12514 const chromaSubsamplingY = (av1CBox[2] & 4) >> 2; 12515 const chromaSamplePosition = av1CBox[2] & 3; 12516 const colorPrimaries = 1; 12517 const transferCharacteristics = 1; 12518 const matrixCoefficients = 1; 12519 const videoFullRangeFlag = 0; 12520 codec += "." + profile + "." + addLeadingZero(level) + tierFlag + "." + addLeadingZero(bitDepth) + "." + monochrome + "." + chromaSubsamplingX + chromaSubsamplingY + chromaSamplePosition + "." + addLeadingZero(colorPrimaries) + "." + addLeadingZero(transferCharacteristics) + "." + addLeadingZero(matrixCoefficients) + "." + videoFullRangeFlag; 12521 break; 12522 } 12523 } 12524 return { 12525 codec, 12526 encrypted 12527 }; 12528} 12529function skipBERInteger(bytes, i3) { 12530 const limit = i3 + 5; 12531 while (bytes[i3++] & 128 && i3 < limit) { 12532 } 12533 return i3; 12534} 12535function toHex(x2) { 12536 return ("0" + x2.toString(16).toUpperCase()).slice(-2); 12537} 12538function addLeadingZero(num) { 12539 return (num < 10 ? "0" : "") + num; 12540} 12541function patchEncyptionData(initSegment, decryptdata) { 12542 if (!initSegment || !decryptdata) { 12543 return initSegment; 12544 } 12545 const keyId = decryptdata.keyId; 12546 if (keyId && decryptdata.isCommonEncryption) { 12547 const traks = findBox(initSegment, ["moov", "trak"]); 12548 traks.forEach((trak) => { 12549 const stsd = findBox(trak, ["mdia", "minf", "stbl", "stsd"])[0]; 12550 const sampleEntries = stsd.subarray(8); 12551 let encBoxes = findBox(sampleEntries, ["enca"]); 12552 const isAudio = encBoxes.length > 0; 12553 if (!isAudio) { 12554 encBoxes = findBox(sampleEntries, ["encv"]); 12555 } 12556 encBoxes.forEach((enc) => { 12557 const encBoxChildren = isAudio ? enc.subarray(28) : enc.subarray(78); 12558 const sinfBoxes = findBox(encBoxChildren, ["sinf"]); 12559 sinfBoxes.forEach((sinf) => { 12560 const tenc = parseSinf(sinf); 12561 if (tenc) { 12562 const tencKeyId = tenc.subarray(8, 24); 12563 if (!tencKeyId.some((b3) => b3 !== 0)) { 12564 logger.log(`[eme] Patching keyId in 'enc${isAudio ? "a" : "v"}>sinf>>tenc' box: ${Hex.hexDump(tencKeyId)} -> ${Hex.hexDump(keyId)}`); 12565 tenc.set(keyId, 8); 12566 } 12567 } 12568 }); 12569 }); 12570 }); 12571 } 12572 return initSegment; 12573} 12574function parseSinf(sinf) { 12575 const schm = findBox(sinf, ["schm"])[0]; 12576 if (schm) { 12577 const scheme = bin2str(schm.subarray(4, 8)); 12578 if (scheme === "cbcs" || scheme === "cenc") { 12579 return findBox(sinf, ["schi", "tenc"])[0]; 12580 } 12581 } 12582 return null; 12583} 12584function getStartDTS(initData, fmp4) { 12585 return findBox(fmp4, ["moof", "traf"]).reduce((result, traf) => { 12586 const tfdt = findBox(traf, ["tfdt"])[0]; 12587 const version = tfdt[0]; 12588 const start = findBox(traf, ["tfhd"]).reduce((result2, tfhd) => { 12589 const id = readUint32(tfhd, 4); 12590 const track = initData[id]; 12591 if (track) { 12592 let baseTime = readUint32(tfdt, 4); 12593 if (version === 1) { 12594 if (baseTime === UINT32_MAX$1) { 12595 logger.warn(`[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time`); 12596 return result2; 12597 } 12598 baseTime *= UINT32_MAX$1 + 1; 12599 baseTime += readUint32(tfdt, 8); 12600 } 12601 const scale2 = track.timescale || 9e4; 12602 const startTime = baseTime / scale2; 12603 if (isFiniteNumber(startTime) && (result2 === null || startTime < result2)) { 12604 return startTime; 12605 } 12606 } 12607 return result2; 12608 }, null); 12609 if (start !== null && isFiniteNumber(start) && (result === null || start < result)) { 12610 return start; 12611 } 12612 return result; 12613 }, null); 12614} 12615function getDuration(data, initData) { 12616 let rawDuration = 0; 12617 let videoDuration = 0; 12618 let audioDuration = 0; 12619 const trafs = findBox(data, ["moof", "traf"]); 12620 for (let i3 = 0; i3 < trafs.length; i3++) { 12621 const traf = trafs[i3]; 12622 const tfhd = findBox(traf, ["tfhd"])[0]; 12623 const id = readUint32(tfhd, 4); 12624 const track = initData[id]; 12625 if (!track) { 12626 continue; 12627 } 12628 const trackDefault = track.default; 12629 const tfhdFlags = readUint32(tfhd, 0) | (trackDefault == null ? void 0 : trackDefault.flags); 12630 let sampleDuration = trackDefault == null ? void 0 : trackDefault.duration; 12631 if (tfhdFlags & 8) { 12632 if (tfhdFlags & 2) { 12633 sampleDuration = readUint32(tfhd, 12); 12634 } else { 12635 sampleDuration = readUint32(tfhd, 8); 12636 } 12637 } 12638 const timescale = track.timescale || 9e4; 12639 const truns = findBox(traf, ["trun"]); 12640 for (let j3 = 0; j3 < truns.length; j3++) { 12641 rawDuration = computeRawDurationFromSamples(truns[j3]); 12642 if (!rawDuration && sampleDuration) { 12643 const sampleCount = readUint32(truns[j3], 4); 12644 rawDuration = sampleDuration * sampleCount; 12645 } 12646 if (track.type === ElementaryStreamTypes.VIDEO) { 12647 videoDuration += rawDuration / timescale; 12648 } else if (track.type === ElementaryStreamTypes.AUDIO) { 12649 audioDuration += rawDuration / timescale; 12650 } 12651 } 12652 } 12653 if (videoDuration === 0 && audioDuration === 0) { 12654 let sidxMinStart = Infinity; 12655 let sidxMaxEnd = 0; 12656 let sidxDuration = 0; 12657 const sidxs = findBox(data, ["sidx"]); 12658 for (let i3 = 0; i3 < sidxs.length; i3++) { 12659 const sidx = parseSegmentIndex(sidxs[i3]); 12660 if (sidx != null && sidx.references) { 12661 sidxMinStart = Math.min(sidxMinStart, sidx.earliestPresentationTime / sidx.timescale); 12662 const subSegmentDuration = sidx.references.reduce((dur, ref) => dur + ref.info.duration || 0, 0); 12663 sidxMaxEnd = Math.max(sidxMaxEnd, subSegmentDuration + sidx.earliestPresentationTime / sidx.timescale); 12664 sidxDuration = sidxMaxEnd - sidxMinStart; 12665 } 12666 } 12667 if (sidxDuration && isFiniteNumber(sidxDuration)) { 12668 return sidxDuration; 12669 } 12670 } 12671 if (videoDuration) { 12672 return videoDuration; 12673 } 12674 return audioDuration; 12675} 12676function computeRawDurationFromSamples(trun) { 12677 const flags = readUint32(trun, 0); 12678 let offset = 8; 12679 if (flags & 1) { 12680 offset += 4; 12681 } 12682 if (flags & 4) { 12683 offset += 4; 12684 } 12685 let duration = 0; 12686 const sampleCount = readUint32(trun, 4); 12687 for (let i3 = 0; i3 < sampleCount; i3++) { 12688 if (flags & 256) { 12689 const sampleDuration = readUint32(trun, offset); 12690 duration += sampleDuration; 12691 offset += 4; 12692 } 12693 if (flags & 512) { 12694 offset += 4; 12695 } 12696 if (flags & 1024) { 12697 offset += 4; 12698 } 12699 if (flags & 2048) { 12700 offset += 4; 12701 } 12702 } 12703 return duration; 12704} 12705function offsetStartDTS(initData, fmp4, timeOffset) { 12706 findBox(fmp4, ["moof", "traf"]).forEach((traf) => { 12707 findBox(traf, ["tfhd"]).forEach((tfhd) => { 12708 const id = readUint32(tfhd, 4); 12709 const track = initData[id]; 12710 if (!track) { 12711 return; 12712 } 12713 const timescale = track.timescale || 9e4; 12714 findBox(traf, ["tfdt"]).forEach((tfdt) => { 12715 const version = tfdt[0]; 12716 const offset = timeOffset * timescale; 12717 if (offset) { 12718 let baseMediaDecodeTime = readUint32(tfdt, 4); 12719 if (version === 0) { 12720 baseMediaDecodeTime -= offset; 12721 baseMediaDecodeTime = Math.max(baseMediaDecodeTime, 0); 12722 writeUint32(tfdt, 4, baseMediaDecodeTime); 12723 } else { 12724 baseMediaDecodeTime *= Math.pow(2, 32); 12725 baseMediaDecodeTime += readUint32(tfdt, 8); 12726 baseMediaDecodeTime -= offset; 12727 baseMediaDecodeTime = Math.max(baseMediaDecodeTime, 0); 12728 const upper = Math.floor(baseMediaDecodeTime / (UINT32_MAX$1 + 1)); 12729 const lower = Math.floor(baseMediaDecodeTime % (UINT32_MAX$1 + 1)); 12730 writeUint32(tfdt, 4, upper); 12731 writeUint32(tfdt, 8, lower); 12732 } 12733 } 12734 }); 12735 }); 12736 }); 12737} 12738function segmentValidRange(data) { 12739 const segmentedRange = { 12740 valid: null, 12741 remainder: null 12742 }; 12743 const moofs = findBox(data, ["moof"]); 12744 if (moofs.length < 2) { 12745 segmentedRange.remainder = data; 12746 return segmentedRange; 12747 } 12748 const last = moofs[moofs.length - 1]; 12749 segmentedRange.valid = sliceUint8(data, 0, last.byteOffset - 8); 12750 segmentedRange.remainder = sliceUint8(data, last.byteOffset - 8); 12751 return segmentedRange; 12752} 12753function appendUint8Array(data1, data2) { 12754 const temp = new Uint8Array(data1.length + data2.length); 12755 temp.set(data1); 12756 temp.set(data2, data1.length); 12757 return temp; 12758} 12759function parseSamples(timeOffset, track) { 12760 const seiSamples = []; 12761 const videoData = track.samples; 12762 const timescale = track.timescale; 12763 const trackId = track.id; 12764 let isHEVCFlavor = false; 12765 const moofs = findBox(videoData, ["moof"]); 12766 moofs.map((moof) => { 12767 const moofOffset = moof.byteOffset - 8; 12768 const trafs = findBox(moof, ["traf"]); 12769 trafs.map((traf) => { 12770 const baseTime = findBox(traf, ["tfdt"]).map((tfdt) => { 12771 const version = tfdt[0]; 12772 let result = readUint32(tfdt, 4); 12773 if (version === 1) { 12774 result *= Math.pow(2, 32); 12775 result += readUint32(tfdt, 8); 12776 } 12777 return result / timescale; 12778 })[0]; 12779 if (baseTime !== void 0) { 12780 timeOffset = baseTime; 12781 } 12782 return findBox(traf, ["tfhd"]).map((tfhd) => { 12783 const id = readUint32(tfhd, 4); 12784 const tfhdFlags = readUint32(tfhd, 0) & 16777215; 12785 const baseDataOffsetPresent = (tfhdFlags & 1) !== 0; 12786 const sampleDescriptionIndexPresent = (tfhdFlags & 2) !== 0; 12787 const defaultSampleDurationPresent = (tfhdFlags & 8) !== 0; 12788 let defaultSampleDuration = 0; 12789 const defaultSampleSizePresent = (tfhdFlags & 16) !== 0; 12790 let defaultSampleSize = 0; 12791 const defaultSampleFlagsPresent = (tfhdFlags & 32) !== 0; 12792 let tfhdOffset = 8; 12793 if (id === trackId) { 12794 if (baseDataOffsetPresent) { 12795 tfhdOffset += 8; 12796 } 12797 if (sampleDescriptionIndexPresent) { 12798 tfhdOffset += 4; 12799 } 12800 if (defaultSampleDurationPresent) { 12801 defaultSampleDuration = readUint32(tfhd, tfhdOffset); 12802 tfhdOffset += 4; 12803 } 12804 if (defaultSampleSizePresent) { 12805 defaultSampleSize = readUint32(tfhd, tfhdOffset); 12806 tfhdOffset += 4; 12807 } 12808 if (defaultSampleFlagsPresent) { 12809 tfhdOffset += 4; 12810 } 12811 if (track.type === "video") { 12812 isHEVCFlavor = isHEVC(track.codec); 12813 } 12814 findBox(traf, ["trun"]).map((trun) => { 12815 const version = trun[0]; 12816 const flags = readUint32(trun, 0) & 16777215; 12817 const dataOffsetPresent = (flags & 1) !== 0; 12818 let dataOffset = 0; 12819 const firstSampleFlagsPresent = (flags & 4) !== 0; 12820 const sampleDurationPresent = (flags & 256) !== 0; 12821 let sampleDuration = 0; 12822 const sampleSizePresent = (flags & 512) !== 0; 12823 let sampleSize = 0; 12824 const sampleFlagsPresent = (flags & 1024) !== 0; 12825 const sampleCompositionOffsetsPresent = (flags & 2048) !== 0; 12826 let compositionOffset = 0; 12827 const sampleCount = readUint32(trun, 4); 12828 let trunOffset = 8; 12829 if (dataOffsetPresent) { 12830 dataOffset = readUint32(trun, trunOffset); 12831 trunOffset += 4; 12832 } 12833 if (firstSampleFlagsPresent) { 12834 trunOffset += 4; 12835 } 12836 let sampleOffset = dataOffset + moofOffset; 12837 for (let ix = 0; ix < sampleCount; ix++) { 12838 if (sampleDurationPresent) { 12839 sampleDuration = readUint32(trun, trunOffset); 12840 trunOffset += 4; 12841 } else { 12842 sampleDuration = defaultSampleDuration; 12843 } 12844 if (sampleSizePresent) { 12845 sampleSize = readUint32(trun, trunOffset); 12846 trunOffset += 4; 12847 } else { 12848 sampleSize = defaultSampleSize; 12849 } 12850 if (sampleFlagsPresent) { 12851 trunOffset += 4; 12852 } 12853 if (sampleCompositionOffsetsPresent) { 12854 if (version === 0) { 12855 compositionOffset = readUint32(trun, trunOffset); 12856 } else { 12857 compositionOffset = readSint32(trun, trunOffset); 12858 } 12859 trunOffset += 4; 12860 } 12861 if (track.type === ElementaryStreamTypes.VIDEO) { 12862 let naluTotalSize = 0; 12863 while (naluTotalSize < sampleSize) { 12864 const naluSize = readUint32(videoData, sampleOffset); 12865 sampleOffset += 4; 12866 if (isSEIMessage(isHEVCFlavor, videoData[sampleOffset])) { 12867 const data = videoData.subarray(sampleOffset, sampleOffset + naluSize); 12868 parseSEIMessageFromNALu(data, isHEVCFlavor ? 2 : 1, timeOffset + compositionOffset / timescale, seiSamples); 12869 } 12870 sampleOffset += naluSize; 12871 naluTotalSize += naluSize + 4; 12872 } 12873 } 12874 timeOffset += sampleDuration / timescale; 12875 } 12876 }); 12877 } 12878 }); 12879 }); 12880 }); 12881 return seiSamples; 12882} 12883function isHEVC(codec) { 12884 if (!codec) { 12885 return false; 12886 } 12887 const delimit2 = codec.indexOf("."); 12888 const baseCodec = delimit2 < 0 ? codec : codec.substring(0, delimit2); 12889 return baseCodec === "hvc1" || baseCodec === "hev1" || // Dolby Vision 12890 baseCodec === "dvh1" || baseCodec === "dvhe"; 12891} 12892function isSEIMessage(isHEVCFlavor, naluHeader) { 12893 if (isHEVCFlavor) { 12894 const naluType = naluHeader >> 1 & 63; 12895 return naluType === 39 || naluType === 40; 12896 } else { 12897 const naluType = naluHeader & 31; 12898 return naluType === 6; 12899 } 12900} 12901function parseSEIMessageFromNALu(unescapedData, headerSize, pts, samples) { 12902 const data = discardEPB(unescapedData); 12903 let seiPtr = 0; 12904 seiPtr += headerSize; 12905 let payloadType = 0; 12906 let payloadSize = 0; 12907 let b3 = 0; 12908 while (seiPtr < data.length) { 12909 payloadType = 0; 12910 do { 12911 if (seiPtr >= data.length) { 12912 break; 12913 } 12914 b3 = data[seiPtr++]; 12915 payloadType += b3; 12916 } while (b3 === 255); 12917 payloadSize = 0; 12918 do { 12919 if (seiPtr >= data.length) { 12920 break; 12921 } 12922 b3 = data[seiPtr++]; 12923 payloadSize += b3; 12924 } while (b3 === 255); 12925 const leftOver = data.length - seiPtr; 12926 let payPtr = seiPtr; 12927 if (payloadSize < leftOver) { 12928 seiPtr += payloadSize; 12929 } else if (payloadSize > leftOver) { 12930 logger.error(`Malformed SEI payload. ${payloadSize} is too small, only ${leftOver} bytes left to parse.`); 12931 break; 12932 } 12933 if (payloadType === 4) { 12934 const countryCode = data[payPtr++]; 12935 if (countryCode === 181) { 12936 const providerCode = readUint16(data, payPtr); 12937 payPtr += 2; 12938 if (providerCode === 49) { 12939 const userStructure = readUint32(data, payPtr); 12940 payPtr += 4; 12941 if (userStructure === 1195456820) { 12942 const userDataType = data[payPtr++]; 12943 if (userDataType === 3) { 12944 const firstByte = data[payPtr++]; 12945 const totalCCs = 31 & firstByte; 12946 const enabled = 64 & firstByte; 12947 const totalBytes = enabled ? 2 + totalCCs * 3 : 0; 12948 const byteArray = new Uint8Array(totalBytes); 12949 if (enabled) { 12950 byteArray[0] = firstByte; 12951 for (let i3 = 1; i3 < totalBytes; i3++) { 12952 byteArray[i3] = data[payPtr++]; 12953 } 12954 } 12955 samples.push({ 12956 type: userDataType, 12957 payloadType, 12958 pts, 12959 bytes: byteArray 12960 }); 12961 } 12962 } 12963 } 12964 } 12965 } else if (payloadType === 5) { 12966 if (payloadSize > 16) { 12967 const uuidStrArray = []; 12968 for (let i3 = 0; i3 < 16; i3++) { 12969 const _b = data[payPtr++].toString(16); 12970 uuidStrArray.push(_b.length == 1 ? "0" + _b : _b); 12971 if (i3 === 3 || i3 === 5 || i3 === 7 || i3 === 9) { 12972 uuidStrArray.push("-"); 12973 } 12974 } 12975 const length2 = payloadSize - 16; 12976 const userDataBytes = new Uint8Array(length2); 12977 for (let i3 = 0; i3 < length2; i3++) { 12978 userDataBytes[i3] = data[payPtr++]; 12979 } 12980 samples.push({ 12981 payloadType, 12982 pts, 12983 uuid: uuidStrArray.join(""), 12984 userData: utf8ArrayToStr(userDataBytes), 12985 userDataBytes 12986 }); 12987 } 12988 } 12989 } 12990} 12991function discardEPB(data) { 12992 const length2 = data.byteLength; 12993 const EPBPositions = []; 12994 let i3 = 1; 12995 while (i3 < length2 - 2) { 12996 if (data[i3] === 0 && data[i3 + 1] === 0 && data[i3 + 2] === 3) { 12997 EPBPositions.push(i3 + 2); 12998 i3 += 2; 12999 } else { 13000 i3++; 13001 } 13002 } 13003 if (EPBPositions.length === 0) { 13004 return data; 13005 } 13006 const newLength = length2 - EPBPositions.length; 13007 const newData = new Uint8Array(newLength); 13008 let sourceIndex = 0; 13009 for (i3 = 0; i3 < newLength; sourceIndex++, i3++) { 13010 if (sourceIndex === EPBPositions[0]) { 13011 sourceIndex++; 13012 EPBPositions.shift(); 13013 } 13014 newData[i3] = data[sourceIndex]; 13015 } 13016 return newData; 13017} 13018function parseEmsg(data) { 13019 const version = data[0]; 13020 let schemeIdUri = ""; 13021 let value = ""; 13022 let timeScale = 0; 13023 let presentationTimeDelta = 0; 13024 let presentationTime = 0; 13025 let eventDuration = 0; 13026 let id = 0; 13027 let offset = 0; 13028 if (version === 0) { 13029 while (bin2str(data.subarray(offset, offset + 1)) !== "\0") { 13030 schemeIdUri += bin2str(data.subarray(offset, offset + 1)); 13031 offset += 1; 13032 } 13033 schemeIdUri += bin2str(data.subarray(offset, offset + 1)); 13034 offset += 1; 13035 while (bin2str(data.subarray(offset, offset + 1)) !== "\0") { 13036 value += bin2str(data.subarray(offset, offset + 1)); 13037 offset += 1; 13038 } 13039 value += bin2str(data.subarray(offset, offset + 1)); 13040 offset += 1; 13041 timeScale = readUint32(data, 12); 13042 presentationTimeDelta = readUint32(data, 16); 13043 eventDuration = readUint32(data, 20); 13044 id = readUint32(data, 24); 13045 offset = 28; 13046 } else if (version === 1) { 13047 offset += 4; 13048 timeScale = readUint32(data, offset); 13049 offset += 4; 13050 const leftPresentationTime = readUint32(data, offset); 13051 offset += 4; 13052 const rightPresentationTime = readUint32(data, offset); 13053 offset += 4; 13054 presentationTime = 2 ** 32 * leftPresentationTime + rightPresentationTime; 13055 if (!isSafeInteger(presentationTime)) { 13056 presentationTime = Number.MAX_SAFE_INTEGER; 13057 logger.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box"); 13058 } 13059 eventDuration = readUint32(data, offset); 13060 offset += 4; 13061 id = readUint32(data, offset); 13062 offset += 4; 13063 while (bin2str(data.subarray(offset, offset + 1)) !== "\0") { 13064 schemeIdUri += bin2str(data.subarray(offset, offset + 1)); 13065 offset += 1; 13066 } 13067 schemeIdUri += bin2str(data.subarray(offset, offset + 1)); 13068 offset += 1; 13069 while (bin2str(data.subarray(offset, offset + 1)) !== "\0") { 13070 value += bin2str(data.subarray(offset, offset + 1)); 13071 offset += 1; 13072 } 13073 value += bin2str(data.subarray(offset, offset + 1)); 13074 offset += 1; 13075 } 13076 const payload = data.subarray(offset, data.byteLength); 13077 return { 13078 schemeIdUri, 13079 value, 13080 timeScale, 13081 presentationTime, 13082 presentationTimeDelta, 13083 eventDuration, 13084 id, 13085 payload 13086 }; 13087} 13088function mp4Box(type, ...payload) { 13089 const len = payload.length; 13090 let size = 8; 13091 let i3 = len; 13092 while (i3--) { 13093 size += payload[i3].byteLength; 13094 } 13095 const result = new Uint8Array(size); 13096 result[0] = size >> 24 & 255; 13097 result[1] = size >> 16 & 255; 13098 result[2] = size >> 8 & 255; 13099 result[3] = size & 255; 13100 result.set(type, 4); 13101 for (i3 = 0, size = 8; i3 < len; i3++) { 13102 result.set(payload[i3], size); 13103 size += payload[i3].byteLength; 13104 } 13105 return result; 13106} 13107function mp4pssh(systemId, keyids, data) { 13108 if (systemId.byteLength !== 16) { 13109 throw new RangeError("Invalid system id"); 13110 } 13111 let version; 13112 let kids; 13113 if (keyids) { 13114 version = 1; 13115 kids = new Uint8Array(keyids.length * 16); 13116 for (let ix = 0; ix < keyids.length; ix++) { 13117 const k3 = keyids[ix]; 13118 if (k3.byteLength !== 16) { 13119 throw new RangeError("Invalid key"); 13120 } 13121 kids.set(k3, ix * 16); 13122 } 13123 } else { 13124 version = 0; 13125 kids = new Uint8Array(); 13126 } 13127 let kidCount; 13128 if (version > 0) { 13129 kidCount = new Uint8Array(4); 13130 if (keyids.length > 0) { 13131 new DataView(kidCount.buffer).setUint32(0, keyids.length, false); 13132 } 13133 } else { 13134 kidCount = new Uint8Array(); 13135 } 13136 const dataSize = new Uint8Array(4); 13137 if (data && data.byteLength > 0) { 13138 new DataView(dataSize.buffer).setUint32(0, data.byteLength, false); 13139 } 13140 return mp4Box( 13141 [112, 115, 115, 104], 13142 new Uint8Array([ 13143 version, 13144 0, 13145 0, 13146 0 13147 // Flags 13148 ]), 13149 systemId, 13150 // 16 bytes 13151 kidCount, 13152 kids, 13153 dataSize, 13154 data || new Uint8Array() 13155 ); 13156} 13157function parseMultiPssh(initData) { 13158 const results = []; 13159 if (initData instanceof ArrayBuffer) { 13160 const length2 = initData.byteLength; 13161 let offset = 0; 13162 while (offset + 32 < length2) { 13163 const view = new DataView(initData, offset); 13164 const pssh = parsePssh(view); 13165 results.push(pssh); 13166 offset += pssh.size; 13167 } 13168 } 13169 return results; 13170} 13171function parsePssh(view) { 13172 const size = view.getUint32(0); 13173 const offset = view.byteOffset; 13174 const length2 = view.byteLength; 13175 if (length2 < size) { 13176 return { 13177 offset, 13178 size: length2 13179 }; 13180 } 13181 const type = view.getUint32(4); 13182 if (type !== 1886614376) { 13183 return { 13184 offset, 13185 size 13186 }; 13187 } 13188 const version = view.getUint32(8) >>> 24; 13189 if (version !== 0 && version !== 1) { 13190 return { 13191 offset, 13192 size 13193 }; 13194 } 13195 const buffer = view.buffer; 13196 const systemId = Hex.hexDump(new Uint8Array(buffer, offset + 12, 16)); 13197 const dataSizeOrKidCount = view.getUint32(28); 13198 let kids = null; 13199 let data = null; 13200 if (version === 0) { 13201 if (size - 32 < dataSizeOrKidCount || dataSizeOrKidCount < 22) { 13202 return { 13203 offset, 13204 size 13205 }; 13206 } 13207 data = new Uint8Array(buffer, offset + 32, dataSizeOrKidCount); 13208 } else if (version === 1) { 13209 if (!dataSizeOrKidCount || length2 < offset + 32 + dataSizeOrKidCount * 16 + 16) { 13210 return { 13211 offset, 13212 size 13213 }; 13214 } 13215 kids = []; 13216 for (let i3 = 0; i3 < dataSizeOrKidCount; i3++) { 13217 kids.push(new Uint8Array(buffer, offset + 32 + i3 * 16, 16)); 13218 } 13219 } 13220 return { 13221 version, 13222 systemId, 13223 kids, 13224 data, 13225 offset, 13226 size 13227 }; 13228} 13229var keyUriToKeyIdMap = {}; 13230var LevelKey = class _LevelKey { 13231 static clearKeyUriToKeyIdMap() { 13232 keyUriToKeyIdMap = {}; 13233 } 13234 constructor(method, uri, format2, formatversions = [1], iv = null) { 13235 this.uri = void 0; 13236 this.method = void 0; 13237 this.keyFormat = void 0; 13238 this.keyFormatVersions = void 0; 13239 this.encrypted = void 0; 13240 this.isCommonEncryption = void 0; 13241 this.iv = null; 13242 this.key = null; 13243 this.keyId = null; 13244 this.pssh = null; 13245 this.method = method; 13246 this.uri = uri; 13247 this.keyFormat = format2; 13248 this.keyFormatVersions = formatversions; 13249 this.iv = iv; 13250 this.encrypted = method ? method !== "NONE" : false; 13251 this.isCommonEncryption = this.encrypted && method !== "AES-128"; 13252 } 13253 isSupported() { 13254 if (this.method) { 13255 if (this.method === "AES-128" || this.method === "NONE") { 13256 return true; 13257 } 13258 if (this.keyFormat === "identity") { 13259 return this.method === "SAMPLE-AES"; 13260 } else { 13261 switch (this.keyFormat) { 13262 case KeySystemFormats.FAIRPLAY: 13263 case KeySystemFormats.WIDEVINE: 13264 case KeySystemFormats.PLAYREADY: 13265 case KeySystemFormats.CLEARKEY: 13266 return ["ISO-23001-7", "SAMPLE-AES", "SAMPLE-AES-CENC", "SAMPLE-AES-CTR"].indexOf(this.method) !== -1; 13267 } 13268 } 13269 } 13270 return false; 13271 } 13272 getDecryptData(sn) { 13273 if (!this.encrypted || !this.uri) { 13274 return null; 13275 } 13276 if (this.method === "AES-128" && this.uri && !this.iv) { 13277 if (typeof sn !== "number") { 13278 if (this.method === "AES-128" && !this.iv) { 13279 logger.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`); 13280 } 13281 sn = 0; 13282 } 13283 const iv = createInitializationVector(sn); 13284 const decryptdata = new _LevelKey(this.method, this.uri, "identity", this.keyFormatVersions, iv); 13285 return decryptdata; 13286 } 13287 const keyBytes = convertDataUriToArrayBytes(this.uri); 13288 if (keyBytes) { 13289 switch (this.keyFormat) { 13290 case KeySystemFormats.WIDEVINE: 13291 this.pssh = keyBytes; 13292 if (keyBytes.length >= 22) { 13293 this.keyId = keyBytes.subarray(keyBytes.length - 22, keyBytes.length - 6); 13294 } 13295 break; 13296 case KeySystemFormats.PLAYREADY: { 13297 const PlayReadyKeySystemUUID = new Uint8Array([154, 4, 240, 121, 152, 64, 66, 134, 171, 146, 230, 91, 224, 136, 95, 149]); 13298 this.pssh = mp4pssh(PlayReadyKeySystemUUID, null, keyBytes); 13299 this.keyId = parsePlayReadyWRM(keyBytes); 13300 break; 13301 } 13302 default: { 13303 let keydata = keyBytes.subarray(0, 16); 13304 if (keydata.length !== 16) { 13305 const padded = new Uint8Array(16); 13306 padded.set(keydata, 16 - keydata.length); 13307 keydata = padded; 13308 } 13309 this.keyId = keydata; 13310 break; 13311 } 13312 } 13313 } 13314 if (!this.keyId || this.keyId.byteLength !== 16) { 13315 let keyId = keyUriToKeyIdMap[this.uri]; 13316 if (!keyId) { 13317 const val = Object.keys(keyUriToKeyIdMap).length % Number.MAX_SAFE_INTEGER; 13318 keyId = new Uint8Array(16); 13319 const dv = new DataView(keyId.buffer, 12, 4); 13320 dv.setUint32(0, val); 13321 keyUriToKeyIdMap[this.uri] = keyId; 13322 } 13323 this.keyId = keyId; 13324 } 13325 return this; 13326 } 13327}; 13328function createInitializationVector(segmentNumber) { 13329 const uint8View = new Uint8Array(16); 13330 for (let i3 = 12; i3 < 16; i3++) { 13331 uint8View[i3] = segmentNumber >> 8 * (15 - i3) & 255; 13332 } 13333 return uint8View; 13334} 13335var VARIABLE_REPLACEMENT_REGEX = /\{\$([a-zA-Z0-9-_]+)\}/g; 13336function hasVariableReferences(str) { 13337 return VARIABLE_REPLACEMENT_REGEX.test(str); 13338} 13339function substituteVariablesInAttributes(parsed, attr, attributeNames) { 13340 if (parsed.variableList !== null || parsed.hasVariableRefs) { 13341 for (let i3 = attributeNames.length; i3--; ) { 13342 const name = attributeNames[i3]; 13343 const value = attr[name]; 13344 if (value) { 13345 attr[name] = substituteVariables(parsed, value); 13346 } 13347 } 13348 } 13349} 13350function substituteVariables(parsed, value) { 13351 if (parsed.variableList !== null || parsed.hasVariableRefs) { 13352 const variableList = parsed.variableList; 13353 return value.replace(VARIABLE_REPLACEMENT_REGEX, (variableReference) => { 13354 const variableName = variableReference.substring(2, variableReference.length - 1); 13355 const variableValue = variableList == null ? void 0 : variableList[variableName]; 13356 if (variableValue === void 0) { 13357 parsed.playlistParsingError || (parsed.playlistParsingError = new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${variableName}"`)); 13358 return variableReference; 13359 } 13360 return variableValue; 13361 }); 13362 } 13363 return value; 13364} 13365function addVariableDefinition(parsed, attr, parentUrl) { 13366 let variableList = parsed.variableList; 13367 if (!variableList) { 13368 parsed.variableList = variableList = {}; 13369 } 13370 let NAME; 13371 let VALUE; 13372 if ("QUERYPARAM" in attr) { 13373 NAME = attr.QUERYPARAM; 13374 try { 13375 const searchParams = new self.URL(parentUrl).searchParams; 13376 if (searchParams.has(NAME)) { 13377 VALUE = searchParams.get(NAME); 13378 } else { 13379 throw new Error(`"${NAME}" does not match any query parameter in URI: "${parentUrl}"`); 13380 } 13381 } catch (error) { 13382 parsed.playlistParsingError || (parsed.playlistParsingError = new Error(`EXT-X-DEFINE QUERYPARAM: ${error.message}`)); 13383 } 13384 } else { 13385 NAME = attr.NAME; 13386 VALUE = attr.VALUE; 13387 } 13388 if (NAME in variableList) { 13389 parsed.playlistParsingError || (parsed.playlistParsingError = new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${NAME}"`)); 13390 } else { 13391 variableList[NAME] = VALUE || ""; 13392 } 13393} 13394function importVariableDefinition(parsed, attr, sourceVariableList) { 13395 const IMPORT2 = attr.IMPORT; 13396 if (sourceVariableList && IMPORT2 in sourceVariableList) { 13397 let variableList = parsed.variableList; 13398 if (!variableList) { 13399 parsed.variableList = variableList = {}; 13400 } 13401 variableList[IMPORT2] = sourceVariableList[IMPORT2]; 13402 } else { 13403 parsed.playlistParsingError || (parsed.playlistParsingError = new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${IMPORT2}"`)); 13404 } 13405} 13406function getMediaSource(preferManagedMediaSource = true) { 13407 if (typeof self === "undefined") return void 0; 13408 const mms = (preferManagedMediaSource || !self.MediaSource) && self.ManagedMediaSource; 13409 return mms || self.MediaSource || self.WebKitMediaSource; 13410} 13411function isManagedMediaSource(source) { 13412 return typeof self !== "undefined" && source === self.ManagedMediaSource; 13413} 13414var sampleEntryCodesISO = { 13415 audio: { 13416 a3ds: 1, 13417 "ac-3": 0.95, 13418 "ac-4": 1, 13419 alac: 0.9, 13420 alaw: 1, 13421 dra1: 1, 13422 "dts+": 1, 13423 "dts-": 1, 13424 dtsc: 1, 13425 dtse: 1, 13426 dtsh: 1, 13427 "ec-3": 0.9, 13428 enca: 1, 13429 fLaC: 0.9, 13430 // MP4-RA listed codec entry for FLAC 13431 flac: 0.9, 13432 // legacy browser codec name for FLAC 13433 FLAC: 0.9, 13434 // some manifests may list "FLAC" with Apple's tools 13435 g719: 1, 13436 g726: 1, 13437 m4ae: 1, 13438 mha1: 1, 13439 mha2: 1, 13440 mhm1: 1, 13441 mhm2: 1, 13442 mlpa: 1, 13443 mp4a: 1, 13444 "raw ": 1, 13445 Opus: 1, 13446 opus: 1, 13447 // browsers expect this to be lowercase despite MP4RA says 'Opus' 13448 samr: 1, 13449 sawb: 1, 13450 sawp: 1, 13451 sevc: 1, 13452 sqcp: 1, 13453 ssmv: 1, 13454 twos: 1, 13455 ulaw: 1 13456 }, 13457 video: { 13458 avc1: 1, 13459 avc2: 1, 13460 avc3: 1, 13461 avc4: 1, 13462 avcp: 1, 13463 av01: 0.8, 13464 drac: 1, 13465 dva1: 1, 13466 dvav: 1, 13467 dvh1: 0.7, 13468 dvhe: 0.7, 13469 encv: 1, 13470 hev1: 0.75, 13471 hvc1: 0.75, 13472 mjp2: 1, 13473 mp4v: 1, 13474 mvc1: 1, 13475 mvc2: 1, 13476 mvc3: 1, 13477 mvc4: 1, 13478 resv: 1, 13479 rv60: 1, 13480 s263: 1, 13481 svc1: 1, 13482 svc2: 1, 13483 "vc-1": 1, 13484 vp08: 1, 13485 vp09: 0.9 13486 }, 13487 text: { 13488 stpp: 1, 13489 wvtt: 1 13490 } 13491}; 13492function isCodecType(codec, type) { 13493 const typeCodes = sampleEntryCodesISO[type]; 13494 return !!typeCodes && !!typeCodes[codec.slice(0, 4)]; 13495} 13496function areCodecsMediaSourceSupported(codecs, type, preferManagedMediaSource = true) { 13497 return !codecs.split(",").some((codec) => !isCodecMediaSourceSupported(codec, type, preferManagedMediaSource)); 13498} 13499function isCodecMediaSourceSupported(codec, type, preferManagedMediaSource = true) { 13500 var _MediaSource$isTypeSu; 13501 const MediaSource = getMediaSource(preferManagedMediaSource); 13502 return (_MediaSource$isTypeSu = MediaSource == null ? void 0 : MediaSource.isTypeSupported(mimeTypeForCodec(codec, type))) != null ? _MediaSource$isTypeSu : false; 13503} 13504function mimeTypeForCodec(codec, type) { 13505 return `${type}/mp4;codecs="${codec}"`; 13506} 13507function videoCodecPreferenceValue(videoCodec) { 13508 if (videoCodec) { 13509 const fourCC = videoCodec.substring(0, 4); 13510 return sampleEntryCodesISO.video[fourCC]; 13511 } 13512 return 2; 13513} 13514function codecsSetSelectionPreferenceValue(codecSet) { 13515 return codecSet.split(",").reduce((num, fourCC) => { 13516 const preferenceValue = sampleEntryCodesISO.video[fourCC]; 13517 if (preferenceValue) { 13518 return (preferenceValue * 2 + num) / (num ? 3 : 2); 13519 } 13520 return (sampleEntryCodesISO.audio[fourCC] + num) / (num ? 2 : 1); 13521 }, 0); 13522} 13523var CODEC_COMPATIBLE_NAMES = {}; 13524function getCodecCompatibleNameLower(lowerCaseCodec, preferManagedMediaSource = true) { 13525 if (CODEC_COMPATIBLE_NAMES[lowerCaseCodec]) { 13526 return CODEC_COMPATIBLE_NAMES[lowerCaseCodec]; 13527 } 13528 const codecsToCheck = { 13529 flac: ["flac", "fLaC", "FLAC"], 13530 opus: ["opus", "Opus"] 13531 }[lowerCaseCodec]; 13532 for (let i3 = 0; i3 < codecsToCheck.length; i3++) { 13533 if (isCodecMediaSourceSupported(codecsToCheck[i3], "audio", preferManagedMediaSource)) { 13534 CODEC_COMPATIBLE_NAMES[lowerCaseCodec] = codecsToCheck[i3]; 13535 return codecsToCheck[i3]; 13536 } 13537 } 13538 return lowerCaseCodec; 13539} 13540var AUDIO_CODEC_REGEXP = /flac|opus/i; 13541function getCodecCompatibleName(codec, preferManagedMediaSource = true) { 13542 return codec.replace(AUDIO_CODEC_REGEXP, (m2) => getCodecCompatibleNameLower(m2.toLowerCase(), preferManagedMediaSource)); 13543} 13544function pickMostCompleteCodecName(parsedCodec, levelCodec) { 13545 if (parsedCodec && parsedCodec !== "mp4a") { 13546 return parsedCodec; 13547 } 13548 return levelCodec ? levelCodec.split(",")[0] : levelCodec; 13549} 13550function convertAVC1ToAVCOTI(codec) { 13551 const codecs = codec.split(","); 13552 for (let i3 = 0; i3 < codecs.length; i3++) { 13553 const avcdata = codecs[i3].split("."); 13554 if (avcdata.length > 2) { 13555 let result = avcdata.shift() + "."; 13556 result += parseInt(avcdata.shift()).toString(16); 13557 result += ("000" + parseInt(avcdata.shift()).toString(16)).slice(-4); 13558 codecs[i3] = result; 13559 } 13560 } 13561 return codecs.join(","); 13562} 13563var MASTER_PLAYLIST_REGEX = /#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g; 13564var MASTER_PLAYLIST_MEDIA_REGEX = /#EXT-X-MEDIA:(.*)/g; 13565var IS_MEDIA_PLAYLIST = /^#EXT(?:INF|-X-TARGETDURATION):/m; 13566var LEVEL_PLAYLIST_REGEX_FAST = new RegExp([ 13567 /#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source, 13568 // duration (#EXTINF:<duration>,<title>), group 1 => duration, group 2 => title 13569 /(?!#) *(\S[^\r\n]*)/.source, 13570 // segment URI, group 3 => the URI (note newline is not eaten) 13571 /#EXT-X-BYTERANGE:*(.+)/.source, 13572 // next segment's byterange, group 4 => range spec (x@y) 13573 /#EXT-X-PROGRAM-DATE-TIME:(.+)/.source, 13574 // next segment's program date/time group 5 => the datetime spec 13575 /#.*/.source 13576 // All other non-segment oriented tags will match with all groups empty 13577].join("|"), "g"); 13578var LEVEL_PLAYLIST_REGEX_SLOW = new RegExp([/#(EXTM3U)/.source, /#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source, /#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source, /#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source, /(#)([^:]*):(.*)/.source, /(#)(.*)(?:.*)\r?\n?/.source].join("|")); 13579var M3U8Parser = class _M3U8Parser { 13580 static findGroup(groups, mediaGroupId) { 13581 for (let i3 = 0; i3 < groups.length; i3++) { 13582 const group = groups[i3]; 13583 if (group.id === mediaGroupId) { 13584 return group; 13585 } 13586 } 13587 } 13588 static resolve(url, baseUrl) { 13589 return urlToolkitExports.buildAbsoluteURL(baseUrl, url, { 13590 alwaysNormalize: true 13591 }); 13592 } 13593 static isMediaPlaylist(str) { 13594 return IS_MEDIA_PLAYLIST.test(str); 13595 } 13596 static parseMasterPlaylist(string, baseurl) { 13597 const hasVariableRefs = hasVariableReferences(string); 13598 const parsed = { 13599 contentSteering: null, 13600 levels: [], 13601 playlistParsingError: null, 13602 sessionData: null, 13603 sessionKeys: null, 13604 startTimeOffset: null, 13605 variableList: null, 13606 hasVariableRefs 13607 }; 13608 const levelsWithKnownCodecs = []; 13609 MASTER_PLAYLIST_REGEX.lastIndex = 0; 13610 let result; 13611 while ((result = MASTER_PLAYLIST_REGEX.exec(string)) != null) { 13612 if (result[1]) { 13613 var _level$unknownCodecs; 13614 const attrs = new AttrList(result[1]); 13615 { 13616 substituteVariablesInAttributes(parsed, attrs, ["CODECS", "SUPPLEMENTAL-CODECS", "ALLOWED-CPC", "PATHWAY-ID", "STABLE-VARIANT-ID", "AUDIO", "VIDEO", "SUBTITLES", "CLOSED-CAPTIONS", "NAME"]); 13617 } 13618 const uri = substituteVariables(parsed, result[2]); 13619 const level = { 13620 attrs, 13621 bitrate: attrs.decimalInteger("BANDWIDTH") || attrs.decimalInteger("AVERAGE-BANDWIDTH"), 13622 name: attrs.NAME, 13623 url: _M3U8Parser.resolve(uri, baseurl) 13624 }; 13625 const resolution = attrs.decimalResolution("RESOLUTION"); 13626 if (resolution) { 13627 level.width = resolution.width; 13628 level.height = resolution.height; 13629 } 13630 setCodecs(attrs.CODECS, level); 13631 if (!((_level$unknownCodecs = level.unknownCodecs) != null && _level$unknownCodecs.length)) { 13632 levelsWithKnownCodecs.push(level); 13633 } 13634 parsed.levels.push(level); 13635 } else if (result[3]) { 13636 const tag = result[3]; 13637 const attributes = result[4]; 13638 switch (tag) { 13639 case "SESSION-DATA": { 13640 const sessionAttrs = new AttrList(attributes); 13641 { 13642 substituteVariablesInAttributes(parsed, sessionAttrs, ["DATA-ID", "LANGUAGE", "VALUE", "URI"]); 13643 } 13644 const dataId = sessionAttrs["DATA-ID"]; 13645 if (dataId) { 13646 if (parsed.sessionData === null) { 13647 parsed.sessionData = {}; 13648 } 13649 parsed.sessionData[dataId] = sessionAttrs; 13650 } 13651 break; 13652 } 13653 case "SESSION-KEY": { 13654 const sessionKey = parseKey(attributes, baseurl, parsed); 13655 if (sessionKey.encrypted && sessionKey.isSupported()) { 13656 if (parsed.sessionKeys === null) { 13657 parsed.sessionKeys = []; 13658 } 13659 parsed.sessionKeys.push(sessionKey); 13660 } else { 13661 logger.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${attributes}"`); 13662 } 13663 break; 13664 } 13665 case "DEFINE": { 13666 { 13667 const variableAttributes = new AttrList(attributes); 13668 substituteVariablesInAttributes(parsed, variableAttributes, ["NAME", "VALUE", "QUERYPARAM"]); 13669 addVariableDefinition(parsed, variableAttributes, baseurl); 13670 } 13671 break; 13672 } 13673 case "CONTENT-STEERING": { 13674 const contentSteeringAttributes = new AttrList(attributes); 13675 { 13676 substituteVariablesInAttributes(parsed, contentSteeringAttributes, ["SERVER-URI", "PATHWAY-ID"]); 13677 } 13678 parsed.contentSteering = { 13679 uri: _M3U8Parser.resolve(contentSteeringAttributes["SERVER-URI"], baseurl), 13680 pathwayId: contentSteeringAttributes["PATHWAY-ID"] || "." 13681 }; 13682 break; 13683 } 13684 case "START": { 13685 parsed.startTimeOffset = parseStartTimeOffset(attributes); 13686 break; 13687 } 13688 } 13689 } 13690 } 13691 const stripUnknownCodecLevels = levelsWithKnownCodecs.length > 0 && levelsWithKnownCodecs.length < parsed.levels.length; 13692 parsed.levels = stripUnknownCodecLevels ? levelsWithKnownCodecs : parsed.levels; 13693 if (parsed.levels.length === 0) { 13694 parsed.playlistParsingError = new Error("no levels found in manifest"); 13695 } 13696 return parsed; 13697 } 13698 static parseMasterPlaylistMedia(string, baseurl, parsed) { 13699 let result; 13700 const results = {}; 13701 const levels = parsed.levels; 13702 const groupsByType = { 13703 AUDIO: levels.map((level) => ({ 13704 id: level.attrs.AUDIO, 13705 audioCodec: level.audioCodec 13706 })), 13707 SUBTITLES: levels.map((level) => ({ 13708 id: level.attrs.SUBTITLES, 13709 textCodec: level.textCodec 13710 })), 13711 "CLOSED-CAPTIONS": [] 13712 }; 13713 let id = 0; 13714 MASTER_PLAYLIST_MEDIA_REGEX.lastIndex = 0; 13715 while ((result = MASTER_PLAYLIST_MEDIA_REGEX.exec(string)) !== null) { 13716 const attrs = new AttrList(result[1]); 13717 const type = attrs.TYPE; 13718 if (type) { 13719 const groups = groupsByType[type]; 13720 const medias = results[type] || []; 13721 results[type] = medias; 13722 { 13723 substituteVariablesInAttributes(parsed, attrs, ["URI", "GROUP-ID", "LANGUAGE", "ASSOC-LANGUAGE", "STABLE-RENDITION-ID", "NAME", "INSTREAM-ID", "CHARACTERISTICS", "CHANNELS"]); 13724 } 13725 const lang = attrs.LANGUAGE; 13726 const assocLang = attrs["ASSOC-LANGUAGE"]; 13727 const channels = attrs.CHANNELS; 13728 const characteristics = attrs.CHARACTERISTICS; 13729 const instreamId = attrs["INSTREAM-ID"]; 13730 const media = { 13731 attrs, 13732 bitrate: 0, 13733 id: id++, 13734 groupId: attrs["GROUP-ID"] || "", 13735 name: attrs.NAME || lang || "", 13736 type, 13737 default: attrs.bool("DEFAULT"), 13738 autoselect: attrs.bool("AUTOSELECT"), 13739 forced: attrs.bool("FORCED"), 13740 lang, 13741 url: attrs.URI ? _M3U8Parser.resolve(attrs.URI, baseurl) : "" 13742 }; 13743 if (assocLang) { 13744 media.assocLang = assocLang; 13745 } 13746 if (channels) { 13747 media.channels = channels; 13748 } 13749 if (characteristics) { 13750 media.characteristics = characteristics; 13751 } 13752 if (instreamId) { 13753 media.instreamId = instreamId; 13754 } 13755 if (groups != null && groups.length) { 13756 const groupCodec = _M3U8Parser.findGroup(groups, media.groupId) || groups[0]; 13757 assignCodec(media, groupCodec, "audioCodec"); 13758 assignCodec(media, groupCodec, "textCodec"); 13759 } 13760 medias.push(media); 13761 } 13762 } 13763 return results; 13764 } 13765 static parseLevelPlaylist(string, baseurl, id, type, levelUrlId, multivariantVariableList) { 13766 const level = new LevelDetails(baseurl); 13767 const fragments = level.fragments; 13768 let currentInitSegment = null; 13769 let currentSN = 0; 13770 let currentPart = 0; 13771 let totalduration = 0; 13772 let discontinuityCounter = 0; 13773 let prevFrag = null; 13774 let frag = new Fragment4(type, baseurl); 13775 let result; 13776 let i3; 13777 let levelkeys; 13778 let firstPdtIndex = -1; 13779 let createNextFrag = false; 13780 let nextByteRange = null; 13781 LEVEL_PLAYLIST_REGEX_FAST.lastIndex = 0; 13782 level.m3u8 = string; 13783 level.hasVariableRefs = hasVariableReferences(string); 13784 while ((result = LEVEL_PLAYLIST_REGEX_FAST.exec(string)) !== null) { 13785 if (createNextFrag) { 13786 createNextFrag = false; 13787 frag = new Fragment4(type, baseurl); 13788 frag.start = totalduration; 13789 frag.sn = currentSN; 13790 frag.cc = discontinuityCounter; 13791 frag.level = id; 13792 if (currentInitSegment) { 13793 frag.initSegment = currentInitSegment; 13794 frag.rawProgramDateTime = currentInitSegment.rawProgramDateTime; 13795 currentInitSegment.rawProgramDateTime = null; 13796 if (nextByteRange) { 13797 frag.setByteRange(nextByteRange); 13798 nextByteRange = null; 13799 } 13800 } 13801 } 13802 const duration = result[1]; 13803 if (duration) { 13804 frag.duration = parseFloat(duration); 13805 const title = (" " + result[2]).slice(1); 13806 frag.title = title || null; 13807 frag.tagList.push(title ? ["INF", duration, title] : ["INF", duration]); 13808 } else if (result[3]) { 13809 if (isFiniteNumber(frag.duration)) { 13810 frag.start = totalduration; 13811 if (levelkeys) { 13812 setFragLevelKeys(frag, levelkeys, level); 13813 } 13814 frag.sn = currentSN; 13815 frag.level = id; 13816 frag.cc = discontinuityCounter; 13817 fragments.push(frag); 13818 const uri = (" " + result[3]).slice(1); 13819 frag.relurl = substituteVariables(level, uri); 13820 assignProgramDateTime(frag, prevFrag); 13821 prevFrag = frag; 13822 totalduration += frag.duration; 13823 currentSN++; 13824 currentPart = 0; 13825 createNextFrag = true; 13826 } 13827 } else if (result[4]) { 13828 const data = (" " + result[4]).slice(1); 13829 if (prevFrag) { 13830 frag.setByteRange(data, prevFrag); 13831 } else { 13832 frag.setByteRange(data); 13833 } 13834 } else if (result[5]) { 13835 frag.rawProgramDateTime = (" " + result[5]).slice(1); 13836 frag.tagList.push(["PROGRAM-DATE-TIME", frag.rawProgramDateTime]); 13837 if (firstPdtIndex === -1) { 13838 firstPdtIndex = fragments.length; 13839 } 13840 } else { 13841 result = result[0].match(LEVEL_PLAYLIST_REGEX_SLOW); 13842 if (!result) { 13843 logger.warn("No matches on slow regex match for level playlist!"); 13844 continue; 13845 } 13846 for (i3 = 1; i3 < result.length; i3++) { 13847 if (typeof result[i3] !== "undefined") { 13848 break; 13849 } 13850 } 13851 const tag = (" " + result[i3]).slice(1); 13852 const value1 = (" " + result[i3 + 1]).slice(1); 13853 const value2 = result[i3 + 2] ? (" " + result[i3 + 2]).slice(1) : ""; 13854 switch (tag) { 13855 case "PLAYLIST-TYPE": 13856 level.type = value1.toUpperCase(); 13857 break; 13858 case "MEDIA-SEQUENCE": 13859 currentSN = level.startSN = parseInt(value1); 13860 break; 13861 case "SKIP": { 13862 const skipAttrs = new AttrList(value1); 13863 { 13864 substituteVariablesInAttributes(level, skipAttrs, ["RECENTLY-REMOVED-DATERANGES"]); 13865 } 13866 const skippedSegments = skipAttrs.decimalInteger("SKIPPED-SEGMENTS"); 13867 if (isFiniteNumber(skippedSegments)) { 13868 level.skippedSegments = skippedSegments; 13869 for (let _i2 = skippedSegments; _i2--; ) { 13870 fragments.unshift(null); 13871 } 13872 currentSN += skippedSegments; 13873 } 13874 const recentlyRemovedDateranges = skipAttrs.enumeratedString("RECENTLY-REMOVED-DATERANGES"); 13875 if (recentlyRemovedDateranges) { 13876 level.recentlyRemovedDateranges = recentlyRemovedDateranges.split(" "); 13877 } 13878 break; 13879 } 13880 case "TARGETDURATION": 13881 level.targetduration = Math.max(parseInt(value1), 1); 13882 break; 13883 case "VERSION": 13884 level.version = parseInt(value1); 13885 break; 13886 case "INDEPENDENT-SEGMENTS": 13887 case "EXTM3U": 13888 break; 13889 case "ENDLIST": 13890 level.live = false; 13891 break; 13892 case "#": 13893 if (value1 || value2) { 13894 frag.tagList.push(value2 ? [value1, value2] : [value1]); 13895 } 13896 break; 13897 case "DISCONTINUITY": 13898 discontinuityCounter++; 13899 frag.tagList.push(["DIS"]); 13900 break; 13901 case "GAP": 13902 frag.gap = true; 13903 frag.tagList.push([tag]); 13904 break; 13905 case "BITRATE": 13906 frag.tagList.push([tag, value1]); 13907 break; 13908 case "DATERANGE": { 13909 const dateRangeAttr = new AttrList(value1); 13910 { 13911 substituteVariablesInAttributes(level, dateRangeAttr, ["ID", "CLASS", "START-DATE", "END-DATE", "SCTE35-CMD", "SCTE35-OUT", "SCTE35-IN"]); 13912 substituteVariablesInAttributes(level, dateRangeAttr, dateRangeAttr.clientAttrs); 13913 } 13914 const dateRange = new DateRange(dateRangeAttr, level.dateRanges[dateRangeAttr.ID]); 13915 if (dateRange.isValid || level.skippedSegments) { 13916 level.dateRanges[dateRange.id] = dateRange; 13917 } else { 13918 logger.warn(`Ignoring invalid DATERANGE tag: "${value1}"`); 13919 } 13920 frag.tagList.push(["EXT-X-DATERANGE", value1]); 13921 break; 13922 } 13923 case "DEFINE": { 13924 { 13925 const variableAttributes = new AttrList(value1); 13926 substituteVariablesInAttributes(level, variableAttributes, ["NAME", "VALUE", "IMPORT", "QUERYPARAM"]); 13927 if ("IMPORT" in variableAttributes) { 13928 importVariableDefinition(level, variableAttributes, multivariantVariableList); 13929 } else { 13930 addVariableDefinition(level, variableAttributes, baseurl); 13931 } 13932 } 13933 break; 13934 } 13935 case "DISCONTINUITY-SEQUENCE": 13936 discontinuityCounter = parseInt(value1); 13937 break; 13938 case "KEY": { 13939 const levelKey = parseKey(value1, baseurl, level); 13940 if (levelKey.isSupported()) { 13941 if (levelKey.method === "NONE") { 13942 levelkeys = void 0; 13943 break; 13944 } 13945 if (!levelkeys) { 13946 levelkeys = {}; 13947 } 13948 if (levelkeys[levelKey.keyFormat]) { 13949 levelkeys = _extends2({}, levelkeys); 13950 } 13951 levelkeys[levelKey.keyFormat] = levelKey; 13952 } else { 13953 logger.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${value1}"`); 13954 } 13955 break; 13956 } 13957 case "START": 13958 level.startTimeOffset = parseStartTimeOffset(value1); 13959 break; 13960 case "MAP": { 13961 const mapAttrs = new AttrList(value1); 13962 { 13963 substituteVariablesInAttributes(level, mapAttrs, ["BYTERANGE", "URI"]); 13964 } 13965 if (frag.duration) { 13966 const init = new Fragment4(type, baseurl); 13967 setInitSegment(init, mapAttrs, id, levelkeys); 13968 currentInitSegment = init; 13969 frag.initSegment = currentInitSegment; 13970 if (currentInitSegment.rawProgramDateTime && !frag.rawProgramDateTime) { 13971 frag.rawProgramDateTime = currentInitSegment.rawProgramDateTime; 13972 } 13973 } else { 13974 const end = frag.byteRangeEndOffset; 13975 if (end) { 13976 const start = frag.byteRangeStartOffset; 13977 nextByteRange = `${end - start}@${start}`; 13978 } else { 13979 nextByteRange = null; 13980 } 13981 setInitSegment(frag, mapAttrs, id, levelkeys); 13982 currentInitSegment = frag; 13983 createNextFrag = true; 13984 } 13985 break; 13986 } 13987 case "SERVER-CONTROL": { 13988 const serverControlAttrs = new AttrList(value1); 13989 level.canBlockReload = serverControlAttrs.bool("CAN-BLOCK-RELOAD"); 13990 level.canSkipUntil = serverControlAttrs.optionalFloat("CAN-SKIP-UNTIL", 0); 13991 level.canSkipDateRanges = level.canSkipUntil > 0 && serverControlAttrs.bool("CAN-SKIP-DATERANGES"); 13992 level.partHoldBack = serverControlAttrs.optionalFloat("PART-HOLD-BACK", 0); 13993 level.holdBack = serverControlAttrs.optionalFloat("HOLD-BACK", 0); 13994 break; 13995 } 13996 case "PART-INF": { 13997 const partInfAttrs = new AttrList(value1); 13998 level.partTarget = partInfAttrs.decimalFloatingPoint("PART-TARGET"); 13999 break; 14000 } 14001 case "PART": { 14002 let partList = level.partList; 14003 if (!partList) { 14004 partList = level.partList = []; 14005 } 14006 const previousFragmentPart = currentPart > 0 ? partList[partList.length - 1] : void 0; 14007 const index2 = currentPart++; 14008 const partAttrs = new AttrList(value1); 14009 { 14010 substituteVariablesInAttributes(level, partAttrs, ["BYTERANGE", "URI"]); 14011 } 14012 const part = new Part(partAttrs, frag, baseurl, index2, previousFragmentPart); 14013 partList.push(part); 14014 frag.duration += part.duration; 14015 break; 14016 } 14017 case "PRELOAD-HINT": { 14018 const preloadHintAttrs = new AttrList(value1); 14019 { 14020 substituteVariablesInAttributes(level, preloadHintAttrs, ["URI"]); 14021 } 14022 level.preloadHint = preloadHintAttrs; 14023 break; 14024 } 14025 case "RENDITION-REPORT": { 14026 const renditionReportAttrs = new AttrList(value1); 14027 { 14028 substituteVariablesInAttributes(level, renditionReportAttrs, ["URI"]); 14029 } 14030 level.renditionReports = level.renditionReports || []; 14031 level.renditionReports.push(renditionReportAttrs); 14032 break; 14033 } 14034 default: 14035 logger.warn(`line parsed but not handled: ${result}`); 14036 break; 14037 } 14038 } 14039 } 14040 if (prevFrag && !prevFrag.relurl) { 14041 fragments.pop(); 14042 totalduration -= prevFrag.duration; 14043 if (level.partList) { 14044 level.fragmentHint = prevFrag; 14045 } 14046 } else if (level.partList) { 14047 assignProgramDateTime(frag, prevFrag); 14048 frag.cc = discontinuityCounter; 14049 level.fragmentHint = frag; 14050 if (levelkeys) { 14051 setFragLevelKeys(frag, levelkeys, level); 14052 } 14053 } 14054 const fragmentLength = fragments.length; 14055 const firstFragment = fragments[0]; 14056 const lastFragment = fragments[fragmentLength - 1]; 14057 totalduration += level.skippedSegments * level.targetduration; 14058 if (totalduration > 0 && fragmentLength && lastFragment) { 14059 level.averagetargetduration = totalduration / fragmentLength; 14060 const lastSn = lastFragment.sn; 14061 level.endSN = lastSn !== "initSegment" ? lastSn : 0; 14062 if (!level.live) { 14063 lastFragment.endList = true; 14064 } 14065 if (firstFragment) { 14066 level.startCC = firstFragment.cc; 14067 } 14068 } else { 14069 level.endSN = 0; 14070 level.startCC = 0; 14071 } 14072 if (level.fragmentHint) { 14073 totalduration += level.fragmentHint.duration; 14074 } 14075 level.totalduration = totalduration; 14076 level.endCC = discontinuityCounter; 14077 if (firstPdtIndex > 0) { 14078 backfillProgramDateTimes(fragments, firstPdtIndex); 14079 } 14080 return level; 14081 } 14082}; 14083function parseKey(keyTagAttributes, baseurl, parsed) { 14084 var _keyAttrs$METHOD, _keyAttrs$KEYFORMAT; 14085 const keyAttrs = new AttrList(keyTagAttributes); 14086 { 14087 substituteVariablesInAttributes(parsed, keyAttrs, ["KEYFORMAT", "KEYFORMATVERSIONS", "URI", "IV", "URI"]); 14088 } 14089 const decryptmethod = (_keyAttrs$METHOD = keyAttrs.METHOD) != null ? _keyAttrs$METHOD : ""; 14090 const decrypturi = keyAttrs.URI; 14091 const decryptiv = keyAttrs.hexadecimalInteger("IV"); 14092 const decryptkeyformatversions = keyAttrs.KEYFORMATVERSIONS; 14093 const decryptkeyformat = (_keyAttrs$KEYFORMAT = keyAttrs.KEYFORMAT) != null ? _keyAttrs$KEYFORMAT : "identity"; 14094 if (decrypturi && keyAttrs.IV && !decryptiv) { 14095 logger.error(`Invalid IV: ${keyAttrs.IV}`); 14096 } 14097 const resolvedUri = decrypturi ? M3U8Parser.resolve(decrypturi, baseurl) : ""; 14098 const keyFormatVersions = (decryptkeyformatversions ? decryptkeyformatversions : "1").split("/").map(Number).filter(Number.isFinite); 14099 return new LevelKey(decryptmethod, resolvedUri, decryptkeyformat, keyFormatVersions, decryptiv); 14100} 14101function parseStartTimeOffset(startAttributes) { 14102 const startAttrs = new AttrList(startAttributes); 14103 const startTimeOffset = startAttrs.decimalFloatingPoint("TIME-OFFSET"); 14104 if (isFiniteNumber(startTimeOffset)) { 14105 return startTimeOffset; 14106 } 14107 return null; 14108} 14109function setCodecs(codecsAttributeValue, level) { 14110 let codecs = (codecsAttributeValue || "").split(/[ ,]+/).filter((c3) => c3); 14111 ["video", "audio", "text"].forEach((type) => { 14112 const filtered = codecs.filter((codec) => isCodecType(codec, type)); 14113 if (filtered.length) { 14114 level[`${type}Codec`] = filtered.join(","); 14115 codecs = codecs.filter((codec) => filtered.indexOf(codec) === -1); 14116 } 14117 }); 14118 level.unknownCodecs = codecs; 14119} 14120function assignCodec(media, groupItem, codecProperty) { 14121 const codecValue = groupItem[codecProperty]; 14122 if (codecValue) { 14123 media[codecProperty] = codecValue; 14124 } 14125} 14126function backfillProgramDateTimes(fragments, firstPdtIndex) { 14127 let fragPrev = fragments[firstPdtIndex]; 14128 for (let i3 = firstPdtIndex; i3--; ) { 14129 const frag = fragments[i3]; 14130 if (!frag) { 14131 return; 14132 } 14133 frag.programDateTime = fragPrev.programDateTime - frag.duration * 1e3; 14134 fragPrev = frag; 14135 } 14136} 14137function assignProgramDateTime(frag, prevFrag) { 14138 if (frag.rawProgramDateTime) { 14139 frag.programDateTime = Date.parse(frag.rawProgramDateTime); 14140 } else if (prevFrag != null && prevFrag.programDateTime) { 14141 frag.programDateTime = prevFrag.endProgramDateTime; 14142 } 14143 if (!isFiniteNumber(frag.programDateTime)) { 14144 frag.programDateTime = null; 14145 frag.rawProgramDateTime = null; 14146 } 14147} 14148function setInitSegment(frag, mapAttrs, id, levelkeys) { 14149 frag.relurl = mapAttrs.URI; 14150 if (mapAttrs.BYTERANGE) { 14151 frag.setByteRange(mapAttrs.BYTERANGE); 14152 } 14153 frag.level = id; 14154 frag.sn = "initSegment"; 14155 if (levelkeys) { 14156 frag.levelkeys = levelkeys; 14157 } 14158 frag.initSegment = null; 14159} 14160function setFragLevelKeys(frag, levelkeys, level) { 14161 frag.levelkeys = levelkeys; 14162 const { 14163 encryptedFragments 14164 } = level; 14165 if ((!encryptedFragments.length || encryptedFragments[encryptedFragments.length - 1].levelkeys !== levelkeys) && Object.keys(levelkeys).some((format2) => levelkeys[format2].isCommonEncryption)) { 14166 encryptedFragments.push(frag); 14167 } 14168} 14169var PlaylistContextType = { 14170 MANIFEST: "manifest", 14171 LEVEL: "level", 14172 AUDIO_TRACK: "audioTrack", 14173 SUBTITLE_TRACK: "subtitleTrack" 14174}; 14175var PlaylistLevelType = { 14176 MAIN: "main", 14177 AUDIO: "audio", 14178 SUBTITLE: "subtitle" 14179}; 14180function mapContextToLevelType(context) { 14181 const { 14182 type 14183 } = context; 14184 switch (type) { 14185 case PlaylistContextType.AUDIO_TRACK: 14186 return PlaylistLevelType.AUDIO; 14187 case PlaylistContextType.SUBTITLE_TRACK: 14188 return PlaylistLevelType.SUBTITLE; 14189 default: 14190 return PlaylistLevelType.MAIN; 14191 } 14192} 14193function getResponseUrl(response, context) { 14194 let url = response.url; 14195 if (url === void 0 || url.indexOf("data:") === 0) { 14196 url = context.url; 14197 } 14198 return url; 14199} 14200var PlaylistLoader = class { 14201 constructor(hls) { 14202 this.hls = void 0; 14203 this.loaders = /* @__PURE__ */ Object.create(null); 14204 this.variableList = null; 14205 this.hls = hls; 14206 this.registerListeners(); 14207 } 14208 startLoad(startPosition) { 14209 } 14210 stopLoad() { 14211 this.destroyInternalLoaders(); 14212 } 14213 registerListeners() { 14214 const { 14215 hls 14216 } = this; 14217 hls.on(Events.MANIFEST_LOADING, this.onManifestLoading, this); 14218 hls.on(Events.LEVEL_LOADING, this.onLevelLoading, this); 14219 hls.on(Events.AUDIO_TRACK_LOADING, this.onAudioTrackLoading, this); 14220 hls.on(Events.SUBTITLE_TRACK_LOADING, this.onSubtitleTrackLoading, this); 14221 } 14222 unregisterListeners() { 14223 const { 14224 hls 14225 } = this; 14226 hls.off(Events.MANIFEST_LOADING, this.onManifestLoading, this); 14227 hls.off(Events.LEVEL_LOADING, this.onLevelLoading, this); 14228 hls.off(Events.AUDIO_TRACK_LOADING, this.onAudioTrackLoading, this); 14229 hls.off(Events.SUBTITLE_TRACK_LOADING, this.onSubtitleTrackLoading, this); 14230 } 14231 /** 14232 * Returns defaults or configured loader-type overloads (pLoader and loader config params) 14233 */ 14234 createInternalLoader(context) { 14235 const config = this.hls.config; 14236 const PLoader = config.pLoader; 14237 const Loader2 = config.loader; 14238 const InternalLoader = PLoader || Loader2; 14239 const loader = new InternalLoader(config); 14240 this.loaders[context.type] = loader; 14241 return loader; 14242 } 14243 getInternalLoader(context) { 14244 return this.loaders[context.type]; 14245 } 14246 resetInternalLoader(contextType) { 14247 if (this.loaders[contextType]) { 14248 delete this.loaders[contextType]; 14249 } 14250 } 14251 /** 14252 * Call `destroy` on all internal loader instances mapped (one per context type) 14253 */ 14254 destroyInternalLoaders() { 14255 for (const contextType in this.loaders) { 14256 const loader = this.loaders[contextType]; 14257 if (loader) { 14258 loader.destroy(); 14259 } 14260 this.resetInternalLoader(contextType); 14261 } 14262 } 14263 destroy() { 14264 this.variableList = null; 14265 this.unregisterListeners(); 14266 this.destroyInternalLoaders(); 14267 } 14268 onManifestLoading(event, data) { 14269 const { 14270 url 14271 } = data; 14272 this.variableList = null; 14273 this.load({ 14274 id: null, 14275 level: 0, 14276 responseType: "text", 14277 type: PlaylistContextType.MANIFEST, 14278 url, 14279 deliveryDirectives: null 14280 }); 14281 } 14282 onLevelLoading(event, data) { 14283 const { 14284 id, 14285 level, 14286 pathwayId, 14287 url, 14288 deliveryDirectives 14289 } = data; 14290 this.load({ 14291 id, 14292 level, 14293 pathwayId, 14294 responseType: "text", 14295 type: PlaylistContextType.LEVEL, 14296 url, 14297 deliveryDirectives 14298 }); 14299 } 14300 onAudioTrackLoading(event, data) { 14301 const { 14302 id, 14303 groupId, 14304 url, 14305 deliveryDirectives 14306 } = data; 14307 this.load({ 14308 id, 14309 groupId, 14310 level: null, 14311 responseType: "text", 14312 type: PlaylistContextType.AUDIO_TRACK, 14313 url, 14314 deliveryDirectives 14315 }); 14316 } 14317 onSubtitleTrackLoading(event, data) { 14318 const { 14319 id, 14320 groupId, 14321 url, 14322 deliveryDirectives 14323 } = data; 14324 this.load({ 14325 id, 14326 groupId, 14327 level: null, 14328 responseType: "text", 14329 type: PlaylistContextType.SUBTITLE_TRACK, 14330 url, 14331 deliveryDirectives 14332 }); 14333 } 14334 load(context) { 14335 var _context$deliveryDire; 14336 const config = this.hls.config; 14337 let loader = this.getInternalLoader(context); 14338 if (loader) { 14339 const loaderContext = loader.context; 14340 if (loaderContext && loaderContext.url === context.url && loaderContext.level === context.level) { 14341 logger.trace("[playlist-loader]: playlist request ongoing"); 14342 return; 14343 } 14344 logger.log(`[playlist-loader]: aborting previous loader for type: ${context.type}`); 14345 loader.abort(); 14346 } 14347 let loadPolicy; 14348 if (context.type === PlaylistContextType.MANIFEST) { 14349 loadPolicy = config.manifestLoadPolicy.default; 14350 } else { 14351 loadPolicy = _extends2({}, config.playlistLoadPolicy.default, { 14352 timeoutRetry: null, 14353 errorRetry: null 14354 }); 14355 } 14356 loader = this.createInternalLoader(context); 14357 if (isFiniteNumber((_context$deliveryDire = context.deliveryDirectives) == null ? void 0 : _context$deliveryDire.part)) { 14358 let levelDetails; 14359 if (context.type === PlaylistContextType.LEVEL && context.level !== null) { 14360 levelDetails = this.hls.levels[context.level].details; 14361 } else if (context.type === PlaylistContextType.AUDIO_TRACK && context.id !== null) { 14362 levelDetails = this.hls.audioTracks[context.id].details; 14363 } else if (context.type === PlaylistContextType.SUBTITLE_TRACK && context.id !== null) { 14364 levelDetails = this.hls.subtitleTracks[context.id].details; 14365 } 14366 if (levelDetails) { 14367 const partTarget = levelDetails.partTarget; 14368 const targetDuration = levelDetails.targetduration; 14369 if (partTarget && targetDuration) { 14370 const maxLowLatencyPlaylistRefresh = Math.max(partTarget * 3, targetDuration * 0.8) * 1e3; 14371 loadPolicy = _extends2({}, loadPolicy, { 14372 maxTimeToFirstByteMs: Math.min(maxLowLatencyPlaylistRefresh, loadPolicy.maxTimeToFirstByteMs), 14373 maxLoadTimeMs: Math.min(maxLowLatencyPlaylistRefresh, loadPolicy.maxTimeToFirstByteMs) 14374 }); 14375 } 14376 } 14377 } 14378 const legacyRetryCompatibility = loadPolicy.errorRetry || loadPolicy.timeoutRetry || {}; 14379 const loaderConfig = { 14380 loadPolicy, 14381 timeout: loadPolicy.maxLoadTimeMs, 14382 maxRetry: legacyRetryCompatibility.maxNumRetry || 0, 14383 retryDelay: legacyRetryCompatibility.retryDelayMs || 0, 14384 maxRetryDelay: legacyRetryCompatibility.maxRetryDelayMs || 0 14385 }; 14386 const loaderCallbacks = { 14387 onSuccess: (response, stats, context2, networkDetails) => { 14388 const loader2 = this.getInternalLoader(context2); 14389 this.resetInternalLoader(context2.type); 14390 const string = response.data; 14391 if (string.indexOf("#EXTM3U") !== 0) { 14392 this.handleManifestParsingError(response, context2, new Error("no EXTM3U delimiter"), networkDetails || null, stats); 14393 return; 14394 } 14395 stats.parsing.start = performance.now(); 14396 if (M3U8Parser.isMediaPlaylist(string)) { 14397 this.handleTrackOrLevelPlaylist(response, stats, context2, networkDetails || null, loader2); 14398 } else { 14399 this.handleMasterPlaylist(response, stats, context2, networkDetails); 14400 } 14401 }, 14402 onError: (response, context2, networkDetails, stats) => { 14403 this.handleNetworkError(context2, networkDetails, false, response, stats); 14404 }, 14405 onTimeout: (stats, context2, networkDetails) => { 14406 this.handleNetworkError(context2, networkDetails, true, void 0, stats); 14407 } 14408 }; 14409 loader.load(context, loaderConfig, loaderCallbacks); 14410 } 14411 handleMasterPlaylist(response, stats, context, networkDetails) { 14412 const hls = this.hls; 14413 const string = response.data; 14414 const url = getResponseUrl(response, context); 14415 const parsedResult = M3U8Parser.parseMasterPlaylist(string, url); 14416 if (parsedResult.playlistParsingError) { 14417 this.handleManifestParsingError(response, context, parsedResult.playlistParsingError, networkDetails, stats); 14418 return; 14419 } 14420 const { 14421 contentSteering, 14422 levels, 14423 sessionData, 14424 sessionKeys, 14425 startTimeOffset, 14426 variableList 14427 } = parsedResult; 14428 this.variableList = variableList; 14429 const { 14430 AUDIO: audioTracks = [], 14431 SUBTITLES: subtitles, 14432 "CLOSED-CAPTIONS": captions 14433 } = M3U8Parser.parseMasterPlaylistMedia(string, url, parsedResult); 14434 if (audioTracks.length) { 14435 const embeddedAudioFound = audioTracks.some((audioTrack) => !audioTrack.url); 14436 if (!embeddedAudioFound && levels[0].audioCodec && !levels[0].attrs.AUDIO) { 14437 logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"); 14438 audioTracks.unshift({ 14439 type: "main", 14440 name: "main", 14441 groupId: "main", 14442 default: false, 14443 autoselect: false, 14444 forced: false, 14445 id: -1, 14446 attrs: new AttrList({}), 14447 bitrate: 0, 14448 url: "" 14449 }); 14450 } 14451 } 14452 hls.trigger(Events.MANIFEST_LOADED, { 14453 levels, 14454 audioTracks, 14455 subtitles, 14456 captions, 14457 contentSteering, 14458 url, 14459 stats, 14460 networkDetails, 14461 sessionData, 14462 sessionKeys, 14463 startTimeOffset, 14464 variableList 14465 }); 14466 } 14467 handleTrackOrLevelPlaylist(response, stats, context, networkDetails, loader) { 14468 const hls = this.hls; 14469 const { 14470 id, 14471 level, 14472 type 14473 } = context; 14474 const url = getResponseUrl(response, context); 14475 const levelUrlId = 0; 14476 const levelId = isFiniteNumber(level) ? level : isFiniteNumber(id) ? id : 0; 14477 const levelType = mapContextToLevelType(context); 14478 const levelDetails = M3U8Parser.parseLevelPlaylist(response.data, url, levelId, levelType, levelUrlId, this.variableList); 14479 if (type === PlaylistContextType.MANIFEST) { 14480 const singleLevel = { 14481 attrs: new AttrList({}), 14482 bitrate: 0, 14483 details: levelDetails, 14484 name: "", 14485 url 14486 }; 14487 hls.trigger(Events.MANIFEST_LOADED, { 14488 levels: [singleLevel], 14489 audioTracks: [], 14490 url, 14491 stats, 14492 networkDetails, 14493 sessionData: null, 14494 sessionKeys: null, 14495 contentSteering: null, 14496 startTimeOffset: null, 14497 variableList: null 14498 }); 14499 } 14500 stats.parsing.end = performance.now(); 14501 context.levelDetails = levelDetails; 14502 this.handlePlaylistLoaded(levelDetails, response, stats, context, networkDetails, loader); 14503 } 14504 handleManifestParsingError(response, context, error, networkDetails, stats) { 14505 this.hls.trigger(Events.ERROR, { 14506 type: ErrorTypes.NETWORK_ERROR, 14507 details: ErrorDetails.MANIFEST_PARSING_ERROR, 14508 fatal: context.type === PlaylistContextType.MANIFEST, 14509 url: response.url, 14510 err: error, 14511 error, 14512 reason: error.message, 14513 response, 14514 context, 14515 networkDetails, 14516 stats 14517 }); 14518 } 14519 handleNetworkError(context, networkDetails, timeout = false, response, stats) { 14520 let message = `A network ${timeout ? "timeout" : "error" + (response ? " (status " + response.code + ")" : "")} occurred while loading ${context.type}`; 14521 if (context.type === PlaylistContextType.LEVEL) { 14522 message += `: ${context.level} id: ${context.id}`; 14523 } else if (context.type === PlaylistContextType.AUDIO_TRACK || context.type === PlaylistContextType.SUBTITLE_TRACK) { 14524 message += ` id: ${context.id} group-id: "${context.groupId}"`; 14525 } 14526 const error = new Error(message); 14527 logger.warn(`[playlist-loader]: ${message}`); 14528 let details = ErrorDetails.UNKNOWN; 14529 let fatal = false; 14530 const loader = this.getInternalLoader(context); 14531 switch (context.type) { 14532 case PlaylistContextType.MANIFEST: 14533 details = timeout ? ErrorDetails.MANIFEST_LOAD_TIMEOUT : ErrorDetails.MANIFEST_LOAD_ERROR; 14534 fatal = true; 14535 break; 14536 case PlaylistContextType.LEVEL: 14537 details = timeout ? ErrorDetails.LEVEL_LOAD_TIMEOUT : ErrorDetails.LEVEL_LOAD_ERROR; 14538 fatal = false; 14539 break; 14540 case PlaylistContextType.AUDIO_TRACK: 14541 details = timeout ? ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT : ErrorDetails.AUDIO_TRACK_LOAD_ERROR; 14542 fatal = false; 14543 break; 14544 case PlaylistContextType.SUBTITLE_TRACK: 14545 details = timeout ? ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT : ErrorDetails.SUBTITLE_LOAD_ERROR; 14546 fatal = false; 14547 break; 14548 } 14549 if (loader) { 14550 this.resetInternalLoader(context.type); 14551 } 14552 const errorData = { 14553 type: ErrorTypes.NETWORK_ERROR, 14554 details, 14555 fatal, 14556 url: context.url, 14557 loader, 14558 context, 14559 error, 14560 networkDetails, 14561 stats 14562 }; 14563 if (response) { 14564 const url = (networkDetails == null ? void 0 : networkDetails.url) || context.url; 14565 errorData.response = _objectSpread23({ 14566 url, 14567 data: void 0 14568 }, response); 14569 } 14570 this.hls.trigger(Events.ERROR, errorData); 14571 } 14572 handlePlaylistLoaded(levelDetails, response, stats, context, networkDetails, loader) { 14573 const hls = this.hls; 14574 const { 14575 type, 14576 level, 14577 id, 14578 groupId, 14579 deliveryDirectives 14580 } = context; 14581 const url = getResponseUrl(response, context); 14582 const parent = mapContextToLevelType(context); 14583 const levelIndex = typeof context.level === "number" && parent === PlaylistLevelType.MAIN ? level : void 0; 14584 if (!levelDetails.fragments.length) { 14585 const _error = new Error("No Segments found in Playlist"); 14586 hls.trigger(Events.ERROR, { 14587 type: ErrorTypes.NETWORK_ERROR, 14588 details: ErrorDetails.LEVEL_EMPTY_ERROR, 14589 fatal: false, 14590 url, 14591 error: _error, 14592 reason: _error.message, 14593 response, 14594 context, 14595 level: levelIndex, 14596 parent, 14597 networkDetails, 14598 stats 14599 }); 14600 return; 14601 } 14602 if (!levelDetails.targetduration) { 14603 levelDetails.playlistParsingError = new Error("Missing Target Duration"); 14604 } 14605 const error = levelDetails.playlistParsingError; 14606 if (error) { 14607 hls.trigger(Events.ERROR, { 14608 type: ErrorTypes.NETWORK_ERROR, 14609 details: ErrorDetails.LEVEL_PARSING_ERROR, 14610 fatal: false, 14611 url, 14612 error, 14613 reason: error.message, 14614 response, 14615 context, 14616 level: levelIndex, 14617 parent, 14618 networkDetails, 14619 stats 14620 }); 14621 return; 14622 } 14623 if (levelDetails.live && loader) { 14624 if (loader.getCacheAge) { 14625 levelDetails.ageHeader = loader.getCacheAge() || 0; 14626 } 14627 if (!loader.getCacheAge || isNaN(levelDetails.ageHeader)) { 14628 levelDetails.ageHeader = 0; 14629 } 14630 } 14631 switch (type) { 14632 case PlaylistContextType.MANIFEST: 14633 case PlaylistContextType.LEVEL: 14634 hls.trigger(Events.LEVEL_LOADED, { 14635 details: levelDetails, 14636 level: levelIndex || 0, 14637 id: id || 0, 14638 stats, 14639 networkDetails, 14640 deliveryDirectives 14641 }); 14642 break; 14643 case PlaylistContextType.AUDIO_TRACK: 14644 hls.trigger(Events.AUDIO_TRACK_LOADED, { 14645 details: levelDetails, 14646 id: id || 0, 14647 groupId: groupId || "", 14648 stats, 14649 networkDetails, 14650 deliveryDirectives 14651 }); 14652 break; 14653 case PlaylistContextType.SUBTITLE_TRACK: 14654 hls.trigger(Events.SUBTITLE_TRACK_LOADED, { 14655 details: levelDetails, 14656 id: id || 0, 14657 groupId: groupId || "", 14658 stats, 14659 networkDetails, 14660 deliveryDirectives 14661 }); 14662 break; 14663 } 14664 } 14665}; 14666function sendAddTrackEvent(track, videoEl) { 14667 let event; 14668 try { 14669 event = new Event("addtrack"); 14670 } catch (err) { 14671 event = document.createEvent("Event"); 14672 event.initEvent("addtrack", false, false); 14673 } 14674 event.track = track; 14675 videoEl.dispatchEvent(event); 14676} 14677function addCueToTrack(track, cue) { 14678 const mode = track.mode; 14679 if (mode === "disabled") { 14680 track.mode = "hidden"; 14681 } 14682 if (track.cues && !track.cues.getCueById(cue.id)) { 14683 try { 14684 track.addCue(cue); 14685 if (!track.cues.getCueById(cue.id)) { 14686 throw new Error(`addCue is failed for: ${cue}`); 14687 } 14688 } catch (err) { 14689 logger.debug(`[texttrack-utils]: ${err}`); 14690 try { 14691 const textTrackCue = new self.TextTrackCue(cue.startTime, cue.endTime, cue.text); 14692 textTrackCue.id = cue.id; 14693 track.addCue(textTrackCue); 14694 } catch (err2) { 14695 logger.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${err2}`); 14696 } 14697 } 14698 } 14699 if (mode === "disabled") { 14700 track.mode = mode; 14701 } 14702} 14703function clearCurrentCues(track) { 14704 const mode = track.mode; 14705 if (mode === "disabled") { 14706 track.mode = "hidden"; 14707 } 14708 if (track.cues) { 14709 for (let i3 = track.cues.length; i3--; ) { 14710 track.removeCue(track.cues[i3]); 14711 } 14712 } 14713 if (mode === "disabled") { 14714 track.mode = mode; 14715 } 14716} 14717function removeCuesInRange(track, start, end, predicate) { 14718 const mode = track.mode; 14719 if (mode === "disabled") { 14720 track.mode = "hidden"; 14721 } 14722 if (track.cues && track.cues.length > 0) { 14723 const cues = getCuesInRange(track.cues, start, end); 14724 for (let i3 = 0; i3 < cues.length; i3++) { 14725 if (!predicate || predicate(cues[i3])) { 14726 track.removeCue(cues[i3]); 14727 } 14728 } 14729 } 14730 if (mode === "disabled") { 14731 track.mode = mode; 14732 } 14733} 14734function getFirstCueIndexAfterTime(cues, time) { 14735 if (time < cues[0].startTime) { 14736 return 0; 14737 } 14738 const len = cues.length - 1; 14739 if (time > cues[len].endTime) { 14740 return -1; 14741 } 14742 let left = 0; 14743 let right = len; 14744 while (left <= right) { 14745 const mid = Math.floor((right + left) / 2); 14746 if (time < cues[mid].startTime) { 14747 right = mid - 1; 14748 } else if (time > cues[mid].startTime && left < len) { 14749 left = mid + 1; 14750 } else { 14751 return mid; 14752 } 14753 } 14754 return cues[left].startTime - time < time - cues[right].startTime ? left : right; 14755} 14756function getCuesInRange(cues, start, end) { 14757 const cuesFound = []; 14758 const firstCueInRange = getFirstCueIndexAfterTime(cues, start); 14759 if (firstCueInRange > -1) { 14760 for (let i3 = firstCueInRange, len = cues.length; i3 < len; i3++) { 14761 const cue = cues[i3]; 14762 if (cue.startTime >= start && cue.endTime <= end) { 14763 cuesFound.push(cue); 14764 } else if (cue.startTime > end) { 14765 return cuesFound; 14766 } 14767 } 14768 } 14769 return cuesFound; 14770} 14771function filterSubtitleTracks(textTrackList) { 14772 const tracks = []; 14773 for (let i3 = 0; i3 < textTrackList.length; i3++) { 14774 const track = textTrackList[i3]; 14775 if ((track.kind === "subtitles" || track.kind === "captions") && track.label) { 14776 tracks.push(textTrackList[i3]); 14777 } 14778 } 14779 return tracks; 14780} 14781var MetadataSchema = { 14782 audioId3: "org.id3", 14783 dateRange: "com.apple.quicktime.HLS", 14784 emsg: "https://aomedia.org/emsg/ID3" 14785}; 14786var MIN_CUE_DURATION = 0.25; 14787function getCueClass() { 14788 if (typeof self === "undefined") return void 0; 14789 return self.VTTCue || self.TextTrackCue; 14790} 14791function createCueWithDataFields(Cue, startTime, endTime, data, type) { 14792 let cue = new Cue(startTime, endTime, ""); 14793 try { 14794 cue.value = data; 14795 if (type) { 14796 cue.type = type; 14797 } 14798 } catch (e) { 14799 cue = new Cue(startTime, endTime, JSON.stringify(type ? _objectSpread23({ 14800 type 14801 }, data) : data)); 14802 } 14803 return cue; 14804} 14805var MAX_CUE_ENDTIME = (() => { 14806 const Cue = getCueClass(); 14807 try { 14808 Cue && new Cue(0, Number.POSITIVE_INFINITY, ""); 14809 } catch (e) { 14810 return Number.MAX_VALUE; 14811 } 14812 return Number.POSITIVE_INFINITY; 14813})(); 14814function dateRangeDateToTimelineSeconds(date, offset) { 14815 return date.getTime() / 1e3 - offset; 14816} 14817function hexToArrayBuffer(str) { 14818 return Uint8Array.from(str.replace(/^0x/, "").replace(/([\da-fA-F]{2}) ?/g, "0x$1 ").replace(/ +$/, "").split(" ")).buffer; 14819} 14820var ID3TrackController = class { 14821 constructor(hls) { 14822 this.hls = void 0; 14823 this.id3Track = null; 14824 this.media = null; 14825 this.dateRangeCuesAppended = {}; 14826 this.hls = hls; 14827 this._registerListeners(); 14828 } 14829 destroy() { 14830 this._unregisterListeners(); 14831 this.id3Track = null; 14832 this.media = null; 14833 this.dateRangeCuesAppended = {}; 14834 this.hls = null; 14835 } 14836 _registerListeners() { 14837 const { 14838 hls 14839 } = this; 14840 hls.on(Events.MEDIA_ATTACHED, this.onMediaAttached, this); 14841 hls.on(Events.MEDIA_DETACHING, this.onMediaDetaching, this); 14842 hls.on(Events.MANIFEST_LOADING, this.onManifestLoading, this); 14843 hls.on(Events.FRAG_PARSING_METADATA, this.onFragParsingMetadata, this); 14844 hls.on(Events.BUFFER_FLUSHING, this.onBufferFlushing, this); 14845 hls.on(Events.LEVEL_UPDATED, this.onLevelUpdated, this); 14846 } 14847 _unregisterListeners() { 14848 const { 14849 hls 14850 } = this; 14851 hls.off(Events.MEDIA_ATTACHED, this.onMediaAttached, this); 14852 hls.off(Events.MEDIA_DETACHING, this.onMediaDetaching, this); 14853 hls.off(Events.MANIFEST_LOADING, this.onManifestLoading, this); 14854 hls.off(Events.FRAG_PARSING_METADATA, this.onFragParsingMetadata, this); 14855 hls.off(Events.BUFFER_FLUSHING, this.onBufferFlushing, this); 14856 hls.off(Events.LEVEL_UPDATED, this.onLevelUpdated, this); 14857 } 14858 // Add ID3 metatadata text track. 14859 onMediaAttached(event, data) { 14860 this.media = data.media; 14861 } 14862 onMediaDetaching() { 14863 if (!this.id3Track) { 14864 return; 14865 } 14866 clearCurrentCues(this.id3Track); 14867 this.id3Track = null; 14868 this.media = null; 14869 this.dateRangeCuesAppended = {}; 14870 } 14871 onManifestLoading() { 14872 this.dateRangeCuesAppended = {}; 14873 } 14874 createTrack(media) { 14875 const track = this.getID3Track(media.textTracks); 14876 track.mode = "hidden"; 14877 return track; 14878 } 14879 getID3Track(textTracks) { 14880 if (!this.media) { 14881 return; 14882 } 14883 for (let i3 = 0; i3 < textTracks.length; i3++) { 14884 const textTrack = textTracks[i3]; 14885 if (textTrack.kind === "metadata" && textTrack.label === "id3") { 14886 sendAddTrackEvent(textTrack, this.media); 14887 return textTrack; 14888 } 14889 } 14890 return this.media.addTextTrack("metadata", "id3"); 14891 } 14892 onFragParsingMetadata(event, data) { 14893 if (!this.media) { 14894 return; 14895 } 14896 const { 14897 hls: { 14898 config: { 14899 enableEmsgMetadataCues, 14900 enableID3MetadataCues 14901 } 14902 } 14903 } = this; 14904 if (!enableEmsgMetadataCues && !enableID3MetadataCues) { 14905 return; 14906 } 14907 const { 14908 samples 14909 } = data; 14910 if (!this.id3Track) { 14911 this.id3Track = this.createTrack(this.media); 14912 } 14913 const Cue = getCueClass(); 14914 if (!Cue) { 14915 return; 14916 } 14917 for (let i3 = 0; i3 < samples.length; i3++) { 14918 const type = samples[i3].type; 14919 if (type === MetadataSchema.emsg && !enableEmsgMetadataCues || !enableID3MetadataCues) { 14920 continue; 14921 } 14922 const frames = getID3Frames(samples[i3].data); 14923 if (frames) { 14924 const startTime = samples[i3].pts; 14925 let endTime = startTime + samples[i3].duration; 14926 if (endTime > MAX_CUE_ENDTIME) { 14927 endTime = MAX_CUE_ENDTIME; 14928 } 14929 const timeDiff = endTime - startTime; 14930 if (timeDiff <= 0) { 14931 endTime = startTime + MIN_CUE_DURATION; 14932 } 14933 for (let j3 = 0; j3 < frames.length; j3++) { 14934 const frame = frames[j3]; 14935 if (!isTimeStampFrame(frame)) { 14936 this.updateId3CueEnds(startTime, type); 14937 const cue = createCueWithDataFields(Cue, startTime, endTime, frame, type); 14938 if (cue) { 14939 this.id3Track.addCue(cue); 14940 } 14941 } 14942 } 14943 } 14944 } 14945 } 14946 updateId3CueEnds(startTime, type) { 14947 var _this$id3Track; 14948 const cues = (_this$id3Track = this.id3Track) == null ? void 0 : _this$id3Track.cues; 14949 if (cues) { 14950 for (let i3 = cues.length; i3--; ) { 14951 const cue = cues[i3]; 14952 if (cue.type === type && cue.startTime < startTime && cue.endTime === MAX_CUE_ENDTIME) { 14953 cue.endTime = startTime; 14954 } 14955 } 14956 } 14957 } 14958 onBufferFlushing(event, { 14959 startOffset, 14960 endOffset, 14961 type 14962 }) { 14963 const { 14964 id3Track, 14965 hls 14966 } = this; 14967 if (!hls) { 14968 return; 14969 } 14970 const { 14971 config: { 14972 enableEmsgMetadataCues, 14973 enableID3MetadataCues 14974 } 14975 } = hls; 14976 if (id3Track && (enableEmsgMetadataCues || enableID3MetadataCues)) { 14977 let predicate; 14978 if (type === "audio") { 14979 predicate = (cue) => cue.type === MetadataSchema.audioId3 && enableID3MetadataCues; 14980 } else if (type === "video") { 14981 predicate = (cue) => cue.type === MetadataSchema.emsg && enableEmsgMetadataCues; 14982 } else { 14983 predicate = (cue) => cue.type === MetadataSchema.audioId3 && enableID3MetadataCues || cue.type === MetadataSchema.emsg && enableEmsgMetadataCues; 14984 } 14985 removeCuesInRange(id3Track, startOffset, endOffset, predicate); 14986 } 14987 } 14988 onLevelUpdated(event, { 14989 details 14990 }) { 14991 if (!this.media || !details.hasProgramDateTime || !this.hls.config.enableDateRangeMetadataCues) { 14992 return; 14993 } 14994 const { 14995 dateRangeCuesAppended, 14996 id3Track 14997 } = this; 14998 const { 14999 dateRanges 15000 } = details; 15001 const ids = Object.keys(dateRanges); 15002 if (id3Track) { 15003 const idsToRemove = Object.keys(dateRangeCuesAppended).filter((id) => !ids.includes(id)); 15004 for (let i3 = idsToRemove.length; i3--; ) { 15005 const id = idsToRemove[i3]; 15006 Object.keys(dateRangeCuesAppended[id].cues).forEach((key) => { 15007 id3Track.removeCue(dateRangeCuesAppended[id].cues[key]); 15008 }); 15009 delete dateRangeCuesAppended[id]; 15010 } 15011 } 15012 const lastFragment = details.fragments[details.fragments.length - 1]; 15013 if (ids.length === 0 || !isFiniteNumber(lastFragment == null ? void 0 : lastFragment.programDateTime)) { 15014 return; 15015 } 15016 if (!this.id3Track) { 15017 this.id3Track = this.createTrack(this.media); 15018 } 15019 const dateTimeOffset = lastFragment.programDateTime / 1e3 - lastFragment.start; 15020 const Cue = getCueClass(); 15021 for (let i3 = 0; i3 < ids.length; i3++) { 15022 const id = ids[i3]; 15023 const dateRange = dateRanges[id]; 15024 const startTime = dateRangeDateToTimelineSeconds(dateRange.startDate, dateTimeOffset); 15025 const appendedDateRangeCues = dateRangeCuesAppended[id]; 15026 const cues = (appendedDateRangeCues == null ? void 0 : appendedDateRangeCues.cues) || {}; 15027 let durationKnown = (appendedDateRangeCues == null ? void 0 : appendedDateRangeCues.durationKnown) || false; 15028 let endTime = MAX_CUE_ENDTIME; 15029 const endDate = dateRange.endDate; 15030 if (endDate) { 15031 endTime = dateRangeDateToTimelineSeconds(endDate, dateTimeOffset); 15032 durationKnown = true; 15033 } else if (dateRange.endOnNext && !durationKnown) { 15034 const nextDateRangeWithSameClass = ids.reduce((candidateDateRange, id2) => { 15035 if (id2 !== dateRange.id) { 15036 const otherDateRange = dateRanges[id2]; 15037 if (otherDateRange.class === dateRange.class && otherDateRange.startDate > dateRange.startDate && (!candidateDateRange || dateRange.startDate < candidateDateRange.startDate)) { 15038 return otherDateRange; 15039 } 15040 } 15041 return candidateDateRange; 15042 }, null); 15043 if (nextDateRangeWithSameClass) { 15044 endTime = dateRangeDateToTimelineSeconds(nextDateRangeWithSameClass.startDate, dateTimeOffset); 15045 durationKnown = true; 15046 } 15047 } 15048 const attributes = Object.keys(dateRange.attr); 15049 for (let j3 = 0; j3 < attributes.length; j3++) { 15050 const key = attributes[j3]; 15051 if (!isDateRangeCueAttribute(key)) { 15052 continue; 15053 } 15054 const cue = cues[key]; 15055 if (cue) { 15056 if (durationKnown && !appendedDateRangeCues.durationKnown) { 15057 cue.endTime = endTime; 15058 } 15059 } else if (Cue) { 15060 let data = dateRange.attr[key]; 15061 if (isSCTE35Attribute(key)) { 15062 data = hexToArrayBuffer(data); 15063 } 15064 const _cue = createCueWithDataFields(Cue, startTime, endTime, { 15065 key, 15066 data 15067 }, MetadataSchema.dateRange); 15068 if (_cue) { 15069 _cue.id = id; 15070 this.id3Track.addCue(_cue); 15071 cues[key] = _cue; 15072 } 15073 } 15074 } 15075 dateRangeCuesAppended[id] = { 15076 cues, 15077 dateRange, 15078 durationKnown 15079 }; 15080 } 15081 } 15082}; 15083var LatencyController = class { 15084 constructor(hls) { 15085 this.hls = void 0; 15086 this.config = void 0; 15087 this.media = null; 15088 this.levelDetails = null; 15089 this.currentTime = 0; 15090 this.stallCount = 0; 15091 this._latency = null; 15092 this.timeupdateHandler = () => this.timeupdate(); 15093 this.hls = hls; 15094 this.config = hls.config; 15095 this.registerListeners(); 15096 } 15097 get latency() { 15098 return this._latency || 0; 15099 } 15100 get maxLatency() { 15101 const { 15102 config, 15103 levelDetails 15104 } = this; 15105 if (config.liveMaxLatencyDuration !== void 0) { 15106 return config.liveMaxLatencyDuration; 15107 } 15108 return levelDetails ? config.liveMaxLatencyDurationCount * levelDetails.targetduration : 0; 15109 } 15110 get targetLatency() { 15111 const { 15112 levelDetails 15113 } = this; 15114 if (levelDetails === null) { 15115 return null; 15116 } 15117 const { 15118 holdBack, 15119 partHoldBack, 15120 targetduration 15121 } = levelDetails; 15122 const { 15123 liveSyncDuration, 15124 liveSyncDurationCount, 15125 lowLatencyMode 15126 } = this.config; 15127 const userConfig = this.hls.userConfig; 15128 let targetLatency = lowLatencyMode ? partHoldBack || holdBack : holdBack; 15129 if (userConfig.liveSyncDuration || userConfig.liveSyncDurationCount || targetLatency === 0) { 15130 targetLatency = liveSyncDuration !== void 0 ? liveSyncDuration : liveSyncDurationCount * targetduration; 15131 } 15132 const maxLiveSyncOnStallIncrease = targetduration; 15133 const liveSyncOnStallIncrease = 1; 15134 return targetLatency + Math.min(this.stallCount * liveSyncOnStallIncrease, maxLiveSyncOnStallIncrease); 15135 } 15136 get liveSyncPosition() { 15137 const liveEdge = this.estimateLiveEdge(); 15138 const targetLatency = this.targetLatency; 15139 const levelDetails = this.levelDetails; 15140 if (liveEdge === null || targetLatency === null || levelDetails === null) { 15141 return null; 15142 } 15143 const edge = levelDetails.edge; 15144 const syncPosition = liveEdge - targetLatency - this.edgeStalled; 15145 const min = edge - levelDetails.totalduration; 15146 const max = edge - (this.config.lowLatencyMode && levelDetails.partTarget || levelDetails.targetduration); 15147 return Math.min(Math.max(min, syncPosition), max); 15148 } 15149 get drift() { 15150 const { 15151 levelDetails 15152 } = this; 15153 if (levelDetails === null) { 15154 return 1; 15155 } 15156 return levelDetails.drift; 15157 } 15158 get edgeStalled() { 15159 const { 15160 levelDetails 15161 } = this; 15162 if (levelDetails === null) { 15163 return 0; 15164 } 15165 const maxLevelUpdateAge = (this.config.lowLatencyMode && levelDetails.partTarget || levelDetails.targetduration) * 3; 15166 return Math.max(levelDetails.age - maxLevelUpdateAge, 0); 15167 } 15168 get forwardBufferLength() { 15169 const { 15170 media, 15171 levelDetails 15172 } = this; 15173 if (!media || !levelDetails) { 15174 return 0; 15175 } 15176 const bufferedRanges = media.buffered.length; 15177 return (bufferedRanges ? media.buffered.end(bufferedRanges - 1) : levelDetails.edge) - this.currentTime; 15178 } 15179 destroy() { 15180 this.unregisterListeners(); 15181 this.onMediaDetaching(); 15182 this.levelDetails = null; 15183 this.hls = this.timeupdateHandler = null; 15184 } 15185 registerListeners() { 15186 this.hls.on(Events.MEDIA_ATTACHED, this.onMediaAttached, this); 15187 this.hls.on(Events.MEDIA_DETACHING, this.onMediaDetaching, this); 15188 this.hls.on(Events.MANIFEST_LOADING, this.onManifestLoading, this); 15189 this.hls.on(Events.LEVEL_UPDATED, this.onLevelUpdated, this); 15190 this.hls.on(Events.ERROR, this.onError, this); 15191 } 15192 unregisterListeners() { 15193 this.hls.off(Events.MEDIA_ATTACHED, this.onMediaAttached, this); 15194 this.hls.off(Events.MEDIA_DETACHING, this.onMediaDetaching, this); 15195 this.hls.off(Events.MANIFEST_LOADING, this.onManifestLoading, this); 15196 this.hls.off(Events.LEVEL_UPDATED, this.onLevelUpdated, this); 15197 this.hls.off(Events.ERROR, this.onError, this); 15198 } 15199 onMediaAttached(event, data) { 15200 this.media = data.media; 15201 this.media.addEventListener("timeupdate", this.timeupdateHandler); 15202 } 15203 onMediaDetaching() { 15204 if (this.media) { 15205 this.media.removeEventListener("timeupdate", this.timeupdateHandler); 15206 this.media = null; 15207 } 15208 } 15209 onManifestLoading() { 15210 this.levelDetails = null; 15211 this._latency = null; 15212 this.stallCount = 0; 15213 } 15214 onLevelUpdated(event, { 15215 details 15216 }) { 15217 this.levelDetails = details; 15218 if (details.advanced) { 15219 this.timeupdate(); 15220 } 15221 if (!details.live && this.media) { 15222 this.media.removeEventListener("timeupdate", this.timeupdateHandler); 15223 } 15224 } 15225 onError(event, data) { 15226 var _this$levelDetails; 15227 if (data.details !== ErrorDetails.BUFFER_STALLED_ERROR) { 15228 return; 15229 } 15230 this.stallCount++; 15231 if ((_this$levelDetails = this.levelDetails) != null && _this$levelDetails.live) { 15232 logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"); 15233 } 15234 } 15235 timeupdate() { 15236 const { 15237 media, 15238 levelDetails 15239 } = this; 15240 if (!media || !levelDetails) { 15241 return; 15242 } 15243 this.currentTime = media.currentTime; 15244 const latency = this.computeLatency(); 15245 if (latency === null) { 15246 return; 15247 } 15248 this._latency = latency; 15249 const { 15250 lowLatencyMode, 15251 maxLiveSyncPlaybackRate 15252 } = this.config; 15253 if (!lowLatencyMode || maxLiveSyncPlaybackRate === 1 || !levelDetails.live) { 15254 return; 15255 } 15256 const targetLatency = this.targetLatency; 15257 if (targetLatency === null) { 15258 return; 15259 } 15260 const distanceFromTarget = latency - targetLatency; 15261 const liveMinLatencyDuration = Math.min(this.maxLatency, targetLatency + levelDetails.targetduration); 15262 const inLiveRange = distanceFromTarget < liveMinLatencyDuration; 15263 if (inLiveRange && distanceFromTarget > 0.05 && this.forwardBufferLength > 1) { 15264 const max = Math.min(2, Math.max(1, maxLiveSyncPlaybackRate)); 15265 const rate = Math.round(2 / (1 + Math.exp(-0.75 * distanceFromTarget - this.edgeStalled)) * 20) / 20; 15266 media.playbackRate = Math.min(max, Math.max(1, rate)); 15267 } else if (media.playbackRate !== 1 && media.playbackRate !== 0) { 15268 media.playbackRate = 1; 15269 } 15270 } 15271 estimateLiveEdge() { 15272 const { 15273 levelDetails 15274 } = this; 15275 if (levelDetails === null) { 15276 return null; 15277 } 15278 return levelDetails.edge + levelDetails.age; 15279 } 15280 computeLatency() { 15281 const liveEdge = this.estimateLiveEdge(); 15282 if (liveEdge === null) { 15283 return null; 15284 } 15285 return liveEdge - this.currentTime; 15286 } 15287}; 15288var HdcpLevels = ["NONE", "TYPE-0", "TYPE-1", null]; 15289function isHdcpLevel(value) { 15290 return HdcpLevels.indexOf(value) > -1; 15291} 15292var VideoRangeValues = ["SDR", "PQ", "HLG"]; 15293function isVideoRange(value) { 15294 return !!value && VideoRangeValues.indexOf(value) > -1; 15295} 15296var HlsSkip = { 15297 No: "", 15298 Yes: "YES", 15299 v2: "v2" 15300}; 15301function getSkipValue(details) { 15302 const { 15303 canSkipUntil, 15304 canSkipDateRanges, 15305 age 15306 } = details; 15307 const playlistRecentEnough = age < canSkipUntil / 2; 15308 if (canSkipUntil && playlistRecentEnough) { 15309 if (canSkipDateRanges) { 15310 return HlsSkip.v2; 15311 } 15312 return HlsSkip.Yes; 15313 } 15314 return HlsSkip.No; 15315} 15316var HlsUrlParameters = class { 15317 constructor(msn, part, skip) { 15318 this.msn = void 0; 15319 this.part = void 0; 15320 this.skip = void 0; 15321 this.msn = msn; 15322 this.part = part; 15323 this.skip = skip; 15324 } 15325 addDirectives(uri) { 15326 const url = new self.URL(uri); 15327 if (this.msn !== void 0) { 15328 url.searchParams.set("_HLS_msn", this.msn.toString()); 15329 } 15330 if (this.part !== void 0) { 15331 url.searchParams.set("_HLS_part", this.part.toString()); 15332 } 15333 if (this.skip) { 15334 url.searchParams.set("_HLS_skip", this.skip); 15335 } 15336 return url.href; 15337 } 15338}; 15339var Level = class { 15340 constructor(data) { 15341 this._attrs = void 0; 15342 this.audioCodec = void 0; 15343 this.bitrate = void 0; 15344 this.codecSet = void 0; 15345 this.url = void 0; 15346 this.frameRate = void 0; 15347 this.height = void 0; 15348 this.id = void 0; 15349 this.name = void 0; 15350 this.videoCodec = void 0; 15351 this.width = void 0; 15352 this.details = void 0; 15353 this.fragmentError = 0; 15354 this.loadError = 0; 15355 this.loaded = void 0; 15356 this.realBitrate = 0; 15357 this.supportedPromise = void 0; 15358 this.supportedResult = void 0; 15359 this._avgBitrate = 0; 15360 this._audioGroups = void 0; 15361 this._subtitleGroups = void 0; 15362 this._urlId = 0; 15363 this.url = [data.url]; 15364 this._attrs = [data.attrs]; 15365 this.bitrate = data.bitrate; 15366 if (data.details) { 15367 this.details = data.details; 15368 } 15369 this.id = data.id || 0; 15370 this.name = data.name; 15371 this.width = data.width || 0; 15372 this.height = data.height || 0; 15373 this.frameRate = data.attrs.optionalFloat("FRAME-RATE", 0); 15374 this._avgBitrate = data.attrs.decimalInteger("AVERAGE-BANDWIDTH"); 15375 this.audioCodec = data.audioCodec; 15376 this.videoCodec = data.videoCodec; 15377 this.codecSet = [data.videoCodec, data.audioCodec].filter((c3) => !!c3).map((s) => s.substring(0, 4)).join(","); 15378 this.addGroupId("audio", data.attrs.AUDIO); 15379 this.addGroupId("text", data.attrs.SUBTITLES); 15380 } 15381 get maxBitrate() { 15382 return Math.max(this.realBitrate, this.bitrate); 15383 } 15384 get averageBitrate() { 15385 return this._avgBitrate || this.realBitrate || this.bitrate; 15386 } 15387 get attrs() { 15388 return this._attrs[0]; 15389 } 15390 get codecs() { 15391 return this.attrs.CODECS || ""; 15392 } 15393 get pathwayId() { 15394 return this.attrs["PATHWAY-ID"] || "."; 15395 } 15396 get videoRange() { 15397 return this.attrs["VIDEO-RANGE"] || "SDR"; 15398 } 15399 get score() { 15400 return this.attrs.optionalFloat("SCORE", 0); 15401 } 15402 get uri() { 15403 return this.url[0] || ""; 15404 } 15405 hasAudioGroup(groupId) { 15406 return hasGroup(this._audioGroups, groupId); 15407 } 15408 hasSubtitleGroup(groupId) { 15409 return hasGroup(this._subtitleGroups, groupId); 15410 } 15411 get audioGroups() { 15412 return this._audioGroups; 15413 } 15414 get subtitleGroups() { 15415 return this._subtitleGroups; 15416 } 15417 addGroupId(type, groupId) { 15418 if (!groupId) { 15419 return; 15420 } 15421 if (type === "audio") { 15422 let audioGroups = this._audioGroups; 15423 if (!audioGroups) { 15424 audioGroups = this._audioGroups = []; 15425 } 15426 if (audioGroups.indexOf(groupId) === -1) { 15427 audioGroups.push(groupId); 15428 } 15429 } else if (type === "text") { 15430 let subtitleGroups = this._subtitleGroups; 15431 if (!subtitleGroups) { 15432 subtitleGroups = this._subtitleGroups = []; 15433 } 15434 if (subtitleGroups.indexOf(groupId) === -1) { 15435 subtitleGroups.push(groupId); 15436 } 15437 } 15438 } 15439 // Deprecated methods (retained for backwards compatibility) 15440 get urlId() { 15441 return 0; 15442 } 15443 set urlId(value) { 15444 } 15445 get audioGroupIds() { 15446 return this.audioGroups ? [this.audioGroupId] : void 0; 15447 } 15448 get textGroupIds() { 15449 return this.subtitleGroups ? [this.textGroupId] : void 0; 15450 } 15451 get audioGroupId() { 15452 var _this$audioGroups; 15453 return (_this$audioGroups = this.audioGroups) == null ? void 0 : _this$audioGroups[0]; 15454 } 15455 get textGroupId() { 15456 var _this$subtitleGroups; 15457 return (_this$subtitleGroups = this.subtitleGroups) == null ? void 0 : _this$subtitleGroups[0]; 15458 } 15459 addFallback() { 15460 } 15461}; 15462function hasGroup(groups, groupId) { 15463 if (!groupId || !groups) { 15464 return false; 15465 } 15466 return groups.indexOf(groupId) !== -1; 15467} 15468function updateFromToPTS(fragFrom, fragTo) { 15469 const fragToPTS = fragTo.startPTS; 15470 if (isFiniteNumber(fragToPTS)) { 15471 let duration = 0; 15472 let frag; 15473 if (fragTo.sn > fragFrom.sn) { 15474 duration = fragToPTS - fragFrom.start; 15475 frag = fragFrom; 15476 } else { 15477 duration = fragFrom.start - fragToPTS; 15478 frag = fragTo; 15479 } 15480 if (frag.duration !== duration) { 15481 frag.duration = duration; 15482 } 15483 } else if (fragTo.sn > fragFrom.sn) { 15484 const contiguous = fragFrom.cc === fragTo.cc; 15485 if (contiguous && fragFrom.minEndPTS) { 15486 fragTo.start = fragFrom.start + (fragFrom.minEndPTS - fragFrom.start); 15487 } else { 15488 fragTo.start = fragFrom.start + fragFrom.duration; 15489 } 15490 } else { 15491 fragTo.start = Math.max(fragFrom.start - fragTo.duration, 0); 15492 } 15493} 15494function updateFragPTSDTS(details, frag, startPTS, endPTS, startDTS, endDTS) { 15495 const parsedMediaDuration = endPTS - startPTS; 15496 if (parsedMediaDuration <= 0) { 15497 logger.warn("Fragment should have a positive duration", frag); 15498 endPTS = startPTS + frag.duration; 15499 endDTS = startDTS + frag.duration; 15500 } 15501 let maxStartPTS = startPTS; 15502 let minEndPTS = endPTS; 15503 const fragStartPts = frag.startPTS; 15504 const fragEndPts = frag.endPTS; 15505 if (isFiniteNumber(fragStartPts)) { 15506 const deltaPTS = Math.abs(fragStartPts - startPTS); 15507 if (!isFiniteNumber(frag.deltaPTS)) { 15508 frag.deltaPTS = deltaPTS; 15509 } else { 15510 frag.deltaPTS = Math.max(deltaPTS, frag.deltaPTS); 15511 } 15512 maxStartPTS = Math.max(startPTS, fragStartPts); 15513 startPTS = Math.min(startPTS, fragStartPts); 15514 startDTS = Math.min(startDTS, frag.startDTS); 15515 minEndPTS = Math.min(endPTS, fragEndPts); 15516 endPTS = Math.max(endPTS, fragEndPts); 15517 endDTS = Math.max(endDTS, frag.endDTS); 15518 } 15519 const drift = startPTS - frag.start; 15520 if (frag.start !== 0) { 15521 frag.start = startPTS; 15522 } 15523 frag.duration = endPTS - frag.start; 15524 frag.startPTS = startPTS; 15525 frag.maxStartPTS = maxStartPTS; 15526 frag.startDTS = startDTS; 15527 frag.endPTS = endPTS; 15528 frag.minEndPTS = minEndPTS; 15529 frag.endDTS = endDTS; 15530 const sn = frag.sn; 15531 if (!details || sn < details.startSN || sn > details.endSN) { 15532 return 0; 15533 } 15534 let i3; 15535 const fragIdx = sn - details.startSN; 15536 const fragments = details.fragments; 15537 fragments[fragIdx] = frag; 15538 for (i3 = fragIdx; i3 > 0; i3--) { 15539 updateFromToPTS(fragments[i3], fragments[i3 - 1]); 15540 } 15541 for (i3 = fragIdx; i3 < fragments.length - 1; i3++) { 15542 updateFromToPTS(fragments[i3], fragments[i3 + 1]); 15543 } 15544 if (details.fragmentHint) { 15545 updateFromToPTS(fragments[fragments.length - 1], details.fragmentHint); 15546 } 15547 details.PTSKnown = details.alignedSliding = true; 15548 return drift; 15549} 15550function mergeDetails(oldDetails, newDetails) { 15551 let currentInitSegment = null; 15552 const oldFragments = oldDetails.fragments; 15553 for (let i3 = oldFragments.length - 1; i3 >= 0; i3--) { 15554 const oldInit = oldFragments[i3].initSegment; 15555 if (oldInit) { 15556 currentInitSegment = oldInit; 15557 break; 15558 } 15559 } 15560 if (oldDetails.fragmentHint) { 15561 delete oldDetails.fragmentHint.endPTS; 15562 } 15563 let PTSFrag; 15564 mapFragmentIntersection(oldDetails, newDetails, (oldFrag, newFrag, newFragIndex, newFragments2) => { 15565 if (newDetails.skippedSegments) { 15566 if (newFrag.cc !== oldFrag.cc) { 15567 const ccOffset = oldFrag.cc - newFrag.cc; 15568 for (let i3 = newFragIndex; i3 < newFragments2.length; i3++) { 15569 newFragments2[i3].cc += ccOffset; 15570 } 15571 } 15572 } 15573 if (isFiniteNumber(oldFrag.startPTS) && isFiniteNumber(oldFrag.endPTS)) { 15574 newFrag.start = newFrag.startPTS = oldFrag.startPTS; 15575 newFrag.startDTS = oldFrag.startDTS; 15576 newFrag.maxStartPTS = oldFrag.maxStartPTS; 15577 newFrag.endPTS = oldFrag.endPTS; 15578 newFrag.endDTS = oldFrag.endDTS; 15579 newFrag.minEndPTS = oldFrag.minEndPTS; 15580 newFrag.duration = oldFrag.endPTS - oldFrag.startPTS; 15581 if (newFrag.duration) { 15582 PTSFrag = newFrag; 15583 } 15584 newDetails.PTSKnown = newDetails.alignedSliding = true; 15585 } 15586 newFrag.elementaryStreams = oldFrag.elementaryStreams; 15587 newFrag.loader = oldFrag.loader; 15588 newFrag.stats = oldFrag.stats; 15589 if (oldFrag.initSegment) { 15590 newFrag.initSegment = oldFrag.initSegment; 15591 currentInitSegment = oldFrag.initSegment; 15592 } 15593 }); 15594 const newFragments = newDetails.fragments; 15595 if (currentInitSegment) { 15596 const fragmentsToCheck = newDetails.fragmentHint ? newFragments.concat(newDetails.fragmentHint) : newFragments; 15597 fragmentsToCheck.forEach((frag) => { 15598 var _currentInitSegment; 15599 if (frag && (!frag.initSegment || frag.initSegment.relurl === ((_currentInitSegment = currentInitSegment) == null ? void 0 : _currentInitSegment.relurl))) { 15600 frag.initSegment = currentInitSegment; 15601 } 15602 }); 15603 } 15604 if (newDetails.skippedSegments) { 15605 newDetails.deltaUpdateFailed = newFragments.some((frag) => !frag); 15606 if (newDetails.deltaUpdateFailed) { 15607 logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist"); 15608 for (let i3 = newDetails.skippedSegments; i3--; ) { 15609 newFragments.shift(); 15610 } 15611 newDetails.startSN = newFragments[0].sn; 15612 } else { 15613 if (newDetails.canSkipDateRanges) { 15614 newDetails.dateRanges = mergeDateRanges(oldDetails.dateRanges, newDetails.dateRanges, newDetails.recentlyRemovedDateranges); 15615 } 15616 } 15617 newDetails.startCC = newDetails.fragments[0].cc; 15618 newDetails.endCC = newFragments[newFragments.length - 1].cc; 15619 } 15620 mapPartIntersection(oldDetails.partList, newDetails.partList, (oldPart, newPart) => { 15621 newPart.elementaryStreams = oldPart.elementaryStreams; 15622 newPart.stats = oldPart.stats; 15623 }); 15624 if (PTSFrag) { 15625 updateFragPTSDTS(newDetails, PTSFrag, PTSFrag.startPTS, PTSFrag.endPTS, PTSFrag.startDTS, PTSFrag.endDTS); 15626 } else { 15627 adjustSliding(oldDetails, newDetails); 15628 } 15629 if (newFragments.length) { 15630 newDetails.totalduration = newDetails.edge - newFragments[0].start; 15631 } 15632 newDetails.driftStartTime = oldDetails.driftStartTime; 15633 newDetails.driftStart = oldDetails.driftStart; 15634 const advancedDateTime = newDetails.advancedDateTime; 15635 if (newDetails.advanced && advancedDateTime) { 15636 const edge = newDetails.edge; 15637 if (!newDetails.driftStart) { 15638 newDetails.driftStartTime = advancedDateTime; 15639 newDetails.driftStart = edge; 15640 } 15641 newDetails.driftEndTime = advancedDateTime; 15642 newDetails.driftEnd = edge; 15643 } else { 15644 newDetails.driftEndTime = oldDetails.driftEndTime; 15645 newDetails.driftEnd = oldDetails.driftEnd; 15646 newDetails.advancedDateTime = oldDetails.advancedDateTime; 15647 } 15648} 15649function mergeDateRanges(oldDateRanges, deltaDateRanges, recentlyRemovedDateranges) { 15650 const dateRanges = _extends2({}, oldDateRanges); 15651 if (recentlyRemovedDateranges) { 15652 recentlyRemovedDateranges.forEach((id) => { 15653 delete dateRanges[id]; 15654 }); 15655 } 15656 Object.keys(deltaDateRanges).forEach((id) => { 15657 const dateRange = new DateRange(deltaDateRanges[id].attr, dateRanges[id]); 15658 if (dateRange.isValid) { 15659 dateRanges[id] = dateRange; 15660 } else { 15661 logger.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(deltaDateRanges[id].attr)}"`); 15662 } 15663 }); 15664 return dateRanges; 15665} 15666function mapPartIntersection(oldParts, newParts, intersectionFn) { 15667 if (oldParts && newParts) { 15668 let delta = 0; 15669 for (let i3 = 0, len = oldParts.length; i3 <= len; i3++) { 15670 const oldPart = oldParts[i3]; 15671 const newPart = newParts[i3 + delta]; 15672 if (oldPart && newPart && oldPart.index === newPart.index && oldPart.fragment.sn === newPart.fragment.sn) { 15673 intersectionFn(oldPart, newPart); 15674 } else { 15675 delta--; 15676 } 15677 } 15678 } 15679} 15680function mapFragmentIntersection(oldDetails, newDetails, intersectionFn) { 15681 const skippedSegments = newDetails.skippedSegments; 15682 const start = Math.max(oldDetails.startSN, newDetails.startSN) - newDetails.startSN; 15683 const end = (oldDetails.fragmentHint ? 1 : 0) + (skippedSegments ? newDetails.endSN : Math.min(oldDetails.endSN, newDetails.endSN)) - newDetails.startSN; 15684 const delta = newDetails.startSN - oldDetails.startSN; 15685 const newFrags = newDetails.fragmentHint ? newDetails.fragments.concat(newDetails.fragmentHint) : newDetails.fragments; 15686 const oldFrags = oldDetails.fragmentHint ? oldDetails.fragments.concat(oldDetails.fragmentHint) : oldDetails.fragments; 15687 for (let i3 = start; i3 <= end; i3++) { 15688 const oldFrag = oldFrags[delta + i3]; 15689 let newFrag = newFrags[i3]; 15690 if (skippedSegments && !newFrag && i3 < skippedSegments) { 15691 newFrag = newDetails.fragments[i3] = oldFrag; 15692 } 15693 if (oldFrag && newFrag) { 15694 intersectionFn(oldFrag, newFrag, i3, newFrags); 15695 } 15696 } 15697} 15698function adjustSliding(oldDetails, newDetails) { 15699 const delta = newDetails.startSN + newDetails.skippedSegments - oldDetails.startSN; 15700 const oldFragments = oldDetails.fragments; 15701 if (delta < 0 || delta >= oldFragments.length) { 15702 return; 15703 } 15704 addSliding(newDetails, oldFragments[delta].start); 15705} 15706function addSliding(details, start) { 15707 if (start) { 15708 const fragments = details.fragments; 15709 for (let i3 = details.skippedSegments; i3 < fragments.length; i3++) { 15710 fragments[i3].start += start; 15711 } 15712 if (details.fragmentHint) { 15713 details.fragmentHint.start += start; 15714 } 15715 } 15716} 15717function computeReloadInterval(newDetails, distanceToLiveEdgeMs = Infinity) { 15718 let reloadInterval = 1e3 * newDetails.targetduration; 15719 if (newDetails.updated) { 15720 const fragments = newDetails.fragments; 15721 const liveEdgeMaxTargetDurations = 4; 15722 if (fragments.length && reloadInterval * liveEdgeMaxTargetDurations > distanceToLiveEdgeMs) { 15723 const lastSegmentDuration = fragments[fragments.length - 1].duration * 1e3; 15724 if (lastSegmentDuration < reloadInterval) { 15725 reloadInterval = lastSegmentDuration; 15726 } 15727 } 15728 } else { 15729 reloadInterval /= 2; 15730 } 15731 return Math.round(reloadInterval); 15732} 15733function getFragmentWithSN(level, sn, fragCurrent) { 15734 if (!(level != null && level.details)) { 15735 return null; 15736 } 15737 const levelDetails = level.details; 15738 let fragment = levelDetails.fragments[sn - levelDetails.startSN]; 15739 if (fragment) { 15740 return fragment; 15741 } 15742 fragment = levelDetails.fragmentHint; 15743 if (fragment && fragment.sn === sn) { 15744 return fragment; 15745 } 15746 if (sn < levelDetails.startSN && fragCurrent && fragCurrent.sn === sn) { 15747 return fragCurrent; 15748 } 15749 return null; 15750} 15751function getPartWith(level, sn, partIndex) { 15752 var _level$details; 15753 if (!(level != null && level.details)) { 15754 return null; 15755 } 15756 return findPart((_level$details = level.details) == null ? void 0 : _level$details.partList, sn, partIndex); 15757} 15758function findPart(partList, sn, partIndex) { 15759 if (partList) { 15760 for (let i3 = partList.length; i3--; ) { 15761 const part = partList[i3]; 15762 if (part.index === partIndex && part.fragment.sn === sn) { 15763 return part; 15764 } 15765 } 15766 } 15767 return null; 15768} 15769function reassignFragmentLevelIndexes(levels) { 15770 levels.forEach((level, index2) => { 15771 const { 15772 details 15773 } = level; 15774 if (details != null && details.fragments) { 15775 details.fragments.forEach((fragment) => { 15776 fragment.level = index2; 15777 }); 15778 } 15779 }); 15780} 15781function isTimeoutError(error) { 15782 switch (error.details) { 15783 case ErrorDetails.FRAG_LOAD_TIMEOUT: 15784 case ErrorDetails.KEY_LOAD_TIMEOUT: 15785 case ErrorDetails.LEVEL_LOAD_TIMEOUT: 15786 case ErrorDetails.MANIFEST_LOAD_TIMEOUT: 15787 return true; 15788 } 15789 return false; 15790} 15791function getRetryConfig(loadPolicy, error) { 15792 const isTimeout = isTimeoutError(error); 15793 return loadPolicy.default[`${isTimeout ? "timeout" : "error"}Retry`]; 15794} 15795function getRetryDelay(retryConfig, retryCount) { 15796 const backoffFactor = retryConfig.backoff === "linear" ? 1 : Math.pow(2, retryCount); 15797 return Math.min(backoffFactor * retryConfig.retryDelayMs, retryConfig.maxRetryDelayMs); 15798} 15799function getLoaderConfigWithoutReties(loderConfig) { 15800 return _objectSpread23(_objectSpread23({}, loderConfig), { 15801 errorRetry: null, 15802 timeoutRetry: null 15803 }); 15804} 15805function shouldRetry(retryConfig, retryCount, isTimeout, loaderResponse) { 15806 if (!retryConfig) { 15807 return false; 15808 } 15809 const httpStatus = loaderResponse == null ? void 0 : loaderResponse.code; 15810 const retry = retryCount < retryConfig.maxNumRetry && (retryForHttpStatus(httpStatus) || !!isTimeout); 15811 return retryConfig.shouldRetry ? retryConfig.shouldRetry(retryConfig, retryCount, isTimeout, loaderResponse, retry) : retry; 15812} 15813function retryForHttpStatus(httpStatus) { 15814 return httpStatus === 0 && navigator.onLine === false || !!httpStatus && (httpStatus < 400 || httpStatus > 499); 15815} 15816var BinarySearch = { 15817 /** 15818 * Searches for an item in an array which matches a certain condition. 15819 * This requires the condition to only match one item in the array, 15820 * and for the array to be ordered. 15821 * 15822 * @param list The array to search. 15823 * @param comparisonFn 15824 * Called and provided a candidate item as the first argument. 15825 * Should return: 15826 * > -1 if the item should be located at a lower index than the provided item. 15827 * > 1 if the item should be located at a higher index than the provided item. 15828 * > 0 if the item is the item you're looking for. 15829 * 15830 * @returns the object if found, otherwise returns null 15831 */ 15832 search: function(list, comparisonFn) { 15833 let minIndex = 0; 15834 let maxIndex = list.length - 1; 15835 let currentIndex = null; 15836 let currentElement = null; 15837 while (minIndex <= maxIndex) { 15838 currentIndex = (minIndex + maxIndex) / 2 | 0; 15839 currentElement = list[currentIndex]; 15840 const comparisonResult = comparisonFn(currentElement); 15841 if (comparisonResult > 0) { 15842 minIndex = currentIndex + 1; 15843 } else if (comparisonResult < 0) { 15844 maxIndex = currentIndex - 1; 15845 } else { 15846 return currentElement; 15847 } 15848 } 15849 return null; 15850 } 15851}; 15852function findFragmentByPDT(fragments, PDTValue, maxFragLookUpTolerance) { 15853 if (PDTValue === null || !Array.isArray(fragments) || !fragments.length || !isFiniteNumber(PDTValue)) { 15854 return null; 15855 } 15856 const startPDT = fragments[0].programDateTime; 15857 if (PDTValue < (startPDT || 0)) { 15858 return null; 15859 } 15860 const endPDT = fragments[fragments.length - 1].endProgramDateTime; 15861 if (PDTValue >= (endPDT || 0)) { 15862 return null; 15863 } 15864 maxFragLookUpTolerance = maxFragLookUpTolerance || 0; 15865 for (let seg = 0; seg < fragments.length; ++seg) { 15866 const frag = fragments[seg]; 15867 if (pdtWithinToleranceTest(PDTValue, maxFragLookUpTolerance, frag)) { 15868 return frag; 15869 } 15870 } 15871 return null; 15872} 15873function findFragmentByPTS(fragPrevious, fragments, bufferEnd = 0, maxFragLookUpTolerance = 0, nextFragLookupTolerance = 5e-3) { 15874 let fragNext = null; 15875 if (fragPrevious) { 15876 fragNext = fragments[fragPrevious.sn - fragments[0].sn + 1] || null; 15877 const bufferEdgeError = fragPrevious.endDTS - bufferEnd; 15878 if (bufferEdgeError > 0 && bufferEdgeError < 15e-7) { 15879 bufferEnd += 15e-7; 15880 } 15881 } else if (bufferEnd === 0 && fragments[0].start === 0) { 15882 fragNext = fragments[0]; 15883 } 15884 if (fragNext && ((!fragPrevious || fragPrevious.level === fragNext.level) && fragmentWithinToleranceTest(bufferEnd, maxFragLookUpTolerance, fragNext) === 0 || fragmentWithinFastStartSwitch(fragNext, fragPrevious, Math.min(nextFragLookupTolerance, maxFragLookUpTolerance)))) { 15885 return fragNext; 15886 } 15887 const foundFragment = BinarySearch.search(fragments, fragmentWithinToleranceTest.bind(null, bufferEnd, maxFragLookUpTolerance)); 15888 if (foundFragment && (foundFragment !== fragPrevious || !fragNext)) { 15889 return foundFragment; 15890 } 15891 return fragNext; 15892} 15893function fragmentWithinFastStartSwitch(fragNext, fragPrevious, nextFragLookupTolerance) { 15894 if (fragPrevious && fragPrevious.start === 0 && fragPrevious.level < fragNext.level && (fragPrevious.endPTS || 0) > 0) { 15895 const firstDuration = fragPrevious.tagList.reduce((duration, tag) => { 15896 if (tag[0] === "INF") { 15897 duration += parseFloat(tag[1]); 15898 } 15899 return duration; 15900 }, nextFragLookupTolerance); 15901 return fragNext.start <= firstDuration; 15902 } 15903 return false; 15904} 15905function fragmentWithinToleranceTest(bufferEnd = 0, maxFragLookUpTolerance = 0, candidate) { 15906 if (candidate.start <= bufferEnd && candidate.start + candidate.duration > bufferEnd) { 15907 return 0; 15908 } 15909 const candidateLookupTolerance = Math.min(maxFragLookUpTolerance, candidate.duration + (candidate.deltaPTS ? candidate.deltaPTS : 0)); 15910 if (candidate.start + candidate.duration - candidateLookupTolerance <= bufferEnd) { 15911 return 1; 15912 } else if (candidate.start - candidateLookupTolerance > bufferEnd && candidate.start) { 15913 return -1; 15914 } 15915 return 0; 15916} 15917function pdtWithinToleranceTest(pdtBufferEnd, maxFragLookUpTolerance, candidate) { 15918 const candidateLookupTolerance = Math.min(maxFragLookUpTolerance, candidate.duration + (candidate.deltaPTS ? candidate.deltaPTS : 0)) * 1e3; 15919 const endProgramDateTime = candidate.endProgramDateTime || 0; 15920 return endProgramDateTime - candidateLookupTolerance > pdtBufferEnd; 15921} 15922function findFragWithCC(fragments, cc) { 15923 return BinarySearch.search(fragments, (candidate) => { 15924 if (candidate.cc < cc) { 15925 return 1; 15926 } else if (candidate.cc > cc) { 15927 return -1; 15928 } else { 15929 return 0; 15930 } 15931 }); 15932} 15933var NetworkErrorAction = { 15934 DoNothing: 0, 15935 SendEndCallback: 1, 15936 SendAlternateToPenaltyBox: 2, 15937 RemoveAlternatePermanently: 3, 15938 InsertDiscontinuity: 4, 15939 RetryRequest: 5 15940}; 15941var ErrorActionFlags = { 15942 None: 0, 15943 MoveAllAlternatesMatchingHost: 1, 15944 MoveAllAlternatesMatchingHDCP: 2, 15945 SwitchToSDR: 4 15946}; 15947var ErrorController = class { 15948 constructor(hls) { 15949 this.hls = void 0; 15950 this.playlistError = 0; 15951 this.penalizedRenditions = {}; 15952 this.log = void 0; 15953 this.warn = void 0; 15954 this.error = void 0; 15955 this.hls = hls; 15956 this.log = logger.log.bind(logger, `[info]:`); 15957 this.warn = logger.warn.bind(logger, `[warning]:`); 15958 this.error = logger.error.bind(logger, `[error]:`); 15959 this.registerListeners(); 15960 } 15961 registerListeners() { 15962 const hls = this.hls; 15963 hls.on(Events.ERROR, this.onError, this); 15964 hls.on(Events.MANIFEST_LOADING, this.onManifestLoading, this); 15965 hls.on(Events.LEVEL_UPDATED, this.onLevelUpdated, this); 15966 } 15967 unregisterListeners() { 15968 const hls = this.hls; 15969 if (!hls) { 15970 return; 15971 } 15972 hls.off(Events.ERROR, this.onError, this); 15973 hls.off(Events.ERROR, this.onErrorOut, this); 15974 hls.off(Events.MANIFEST_LOADING, this.onManifestLoading, this); 15975 hls.off(Events.LEVEL_UPDATED, this.onLevelUpdated, this); 15976 } 15977 destroy() { 15978 this.unregisterListeners(); 15979 this.hls = null; 15980 this.penalizedRenditions = {}; 15981 } 15982 startLoad(startPosition) { 15983 } 15984 stopLoad() { 15985 this.playlistError = 0; 15986 } 15987 getVariantLevelIndex(frag) { 15988 return (frag == null ? void 0 : frag.type) === PlaylistLevelType.MAIN ? frag.level : this.hls.loadLevel; 15989 } 15990 onManifestLoading() { 15991 this.playlistError = 0; 15992 this.penalizedRenditions = {}; 15993 } 15994 onLevelUpdated() { 15995 this.playlistError = 0; 15996 } 15997 onError(event, data) { 15998 var _data$frag, _data$level; 15999 if (data.fatal) { 16000 return; 16001 } 16002 const hls = this.hls; 16003 const context = data.context; 16004 switch (data.details) { 16005 case ErrorDetails.FRAG_LOAD_ERROR: 16006 case ErrorDetails.FRAG_LOAD_TIMEOUT: 16007 case ErrorDetails.KEY_LOAD_ERROR: 16008 case ErrorDetails.KEY_LOAD_TIMEOUT: 16009 data.errorAction = this.getFragRetryOrSwitchAction(data); 16010 return; 16011 case ErrorDetails.FRAG_PARSING_ERROR: 16012 if ((_data$frag = data.frag) != null && _data$frag.gap) { 16013 data.errorAction = { 16014 action: NetworkErrorAction.DoNothing, 16015 flags: ErrorActionFlags.None 16016 }; 16017 return; 16018 } 16019 case ErrorDetails.FRAG_GAP: 16020 case ErrorDetails.FRAG_DECRYPT_ERROR: { 16021 data.errorAction = this.getFragRetryOrSwitchAction(data); 16022 data.errorAction.action = NetworkErrorAction.SendAlternateToPenaltyBox; 16023 return; 16024 } 16025 case ErrorDetails.LEVEL_EMPTY_ERROR: 16026 case ErrorDetails.LEVEL_PARSING_ERROR: 16027 { 16028 var _data$context, _data$context$levelDe; 16029 const levelIndex = data.parent === PlaylistLevelType.MAIN ? data.level : hls.loadLevel; 16030 if (data.details === ErrorDetails.LEVEL_EMPTY_ERROR && !!((_data$context = data.context) != null && (_data$context$levelDe = _data$context.levelDetails) != null && _data$context$levelDe.live)) { 16031 data.errorAction = this.getPlaylistRetryOrSwitchAction(data, levelIndex); 16032 } else { 16033 data.levelRetry = false; 16034 data.errorAction = this.getLevelSwitchAction(data, levelIndex); 16035 } 16036 } 16037 return; 16038 case ErrorDetails.LEVEL_LOAD_ERROR: 16039 case ErrorDetails.LEVEL_LOAD_TIMEOUT: 16040 if (typeof (context == null ? void 0 : context.level) === "number") { 16041 data.errorAction = this.getPlaylistRetryOrSwitchAction(data, context.level); 16042 } 16043 return; 16044 case ErrorDetails.AUDIO_TRACK_LOAD_ERROR: 16045 case ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT: 16046 case ErrorDetails.SUBTITLE_LOAD_ERROR: 16047 case ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT: 16048 if (context) { 16049 const level = hls.levels[hls.loadLevel]; 16050 if (level && (context.type === PlaylistContextType.AUDIO_TRACK && level.hasAudioGroup(context.groupId) || context.type === PlaylistContextType.SUBTITLE_TRACK && level.hasSubtitleGroup(context.groupId))) { 16051 data.errorAction = this.getPlaylistRetryOrSwitchAction(data, hls.loadLevel); 16052 data.errorAction.action = NetworkErrorAction.SendAlternateToPenaltyBox; 16053 data.errorAction.flags = ErrorActionFlags.MoveAllAlternatesMatchingHost; 16054 return; 16055 } 16056 } 16057 return; 16058 case ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED: 16059 { 16060 const level = hls.levels[hls.loadLevel]; 16061 const restrictedHdcpLevel = level == null ? void 0 : level.attrs["HDCP-LEVEL"]; 16062 if (restrictedHdcpLevel) { 16063 data.errorAction = { 16064 action: NetworkErrorAction.SendAlternateToPenaltyBox, 16065 flags: ErrorActionFlags.MoveAllAlternatesMatchingHDCP, 16066 hdcpLevel: restrictedHdcpLevel 16067 }; 16068 } else { 16069 this.keySystemError(data); 16070 } 16071 } 16072 return; 16073 case ErrorDetails.BUFFER_ADD_CODEC_ERROR: 16074 case ErrorDetails.REMUX_ALLOC_ERROR: 16075 case ErrorDetails.BUFFER_APPEND_ERROR: 16076 data.errorAction = this.getLevelSwitchAction(data, (_data$level = data.level) != null ? _data$level : hls.loadLevel); 16077 return; 16078 case ErrorDetails.INTERNAL_EXCEPTION: 16079 case ErrorDetails.BUFFER_APPENDING_ERROR: 16080 case ErrorDetails.BUFFER_FULL_ERROR: 16081 case ErrorDetails.LEVEL_SWITCH_ERROR: 16082 case ErrorDetails.BUFFER_STALLED_ERROR: 16083 case ErrorDetails.BUFFER_SEEK_OVER_HOLE: 16084 case ErrorDetails.BUFFER_NUDGE_ON_STALL: 16085 data.errorAction = { 16086 action: NetworkErrorAction.DoNothing, 16087 flags: ErrorActionFlags.None 16088 }; 16089 return; 16090 } 16091 if (data.type === ErrorTypes.KEY_SYSTEM_ERROR) { 16092 this.keySystemError(data); 16093 } 16094 } 16095 keySystemError(data) { 16096 const levelIndex = this.getVariantLevelIndex(data.frag); 16097 data.levelRetry = false; 16098 data.errorAction = this.getLevelSwitchAction(data, levelIndex); 16099 } 16100 getPlaylistRetryOrSwitchAction(data, levelIndex) { 16101 const hls = this.hls; 16102 const retryConfig = getRetryConfig(hls.config.playlistLoadPolicy, data); 16103 const retryCount = this.playlistError++; 16104 const retry = shouldRetry(retryConfig, retryCount, isTimeoutError(data), data.response); 16105 if (retry) { 16106 return { 16107 action: NetworkErrorAction.RetryRequest, 16108 flags: ErrorActionFlags.None, 16109 retryConfig, 16110 retryCount 16111 }; 16112 } 16113 const errorAction = this.getLevelSwitchAction(data, levelIndex); 16114 if (retryConfig) { 16115 errorAction.retryConfig = retryConfig; 16116 errorAction.retryCount = retryCount; 16117 } 16118 return errorAction; 16119 } 16120 getFragRetryOrSwitchAction(data) { 16121 const hls = this.hls; 16122 const variantLevelIndex = this.getVariantLevelIndex(data.frag); 16123 const level = hls.levels[variantLevelIndex]; 16124 const { 16125 fragLoadPolicy, 16126 keyLoadPolicy 16127 } = hls.config; 16128 const retryConfig = getRetryConfig(data.details.startsWith("key") ? keyLoadPolicy : fragLoadPolicy, data); 16129 const fragmentErrors = hls.levels.reduce((acc, level2) => acc + level2.fragmentError, 0); 16130 if (level) { 16131 if (data.details !== ErrorDetails.FRAG_GAP) { 16132 level.fragmentError++; 16133 } 16134 const retry = shouldRetry(retryConfig, fragmentErrors, isTimeoutError(data), data.response); 16135 if (retry) { 16136 return { 16137 action: NetworkErrorAction.RetryRequest, 16138 flags: ErrorActionFlags.None, 16139 retryConfig, 16140 retryCount: fragmentErrors 16141 }; 16142 } 16143 } 16144 const errorAction = this.getLevelSwitchAction(data, variantLevelIndex); 16145 if (retryConfig) { 16146 errorAction.retryConfig = retryConfig; 16147 errorAction.retryCount = fragmentErrors; 16148 } 16149 return errorAction; 16150 } 16151 getLevelSwitchAction(data, levelIndex) { 16152 const hls = this.hls; 16153 if (levelIndex === null || levelIndex === void 0) { 16154 levelIndex = hls.loadLevel; 16155 } 16156 const level = this.hls.levels[levelIndex]; 16157 if (level) { 16158 var _data$frag2, _data$context2; 16159 const errorDetails = data.details; 16160 level.loadError++; 16161 if (errorDetails === ErrorDetails.BUFFER_APPEND_ERROR) { 16162 level.fragmentError++; 16163 } 16164 let nextLevel = -1; 16165 const { 16166 levels, 16167 loadLevel, 16168 minAutoLevel, 16169 maxAutoLevel 16170 } = hls; 16171 if (!hls.autoLevelEnabled) { 16172 hls.loadLevel = -1; 16173 } 16174 const fragErrorType = (_data$frag2 = data.frag) == null ? void 0 : _data$frag2.type; 16175 const isAudioCodecError = fragErrorType === PlaylistLevelType.AUDIO && errorDetails === ErrorDetails.FRAG_PARSING_ERROR || data.sourceBufferName === "audio" && (errorDetails === ErrorDetails.BUFFER_ADD_CODEC_ERROR || errorDetails === ErrorDetails.BUFFER_APPEND_ERROR); 16176 const findAudioCodecAlternate = isAudioCodecError && levels.some(({ 16177 audioCodec 16178 }) => level.audioCodec !== audioCodec); 16179 const isVideoCodecError = data.sourceBufferName === "video" && (errorDetails === ErrorDetails.BUFFER_ADD_CODEC_ERROR || errorDetails === ErrorDetails.BUFFER_APPEND_ERROR); 16180 const findVideoCodecAlternate = isVideoCodecError && levels.some(({ 16181 codecSet, 16182 audioCodec 16183 }) => level.codecSet !== codecSet && level.audioCodec === audioCodec); 16184 const { 16185 type: playlistErrorType, 16186 groupId: playlistErrorGroupId 16187 } = (_data$context2 = data.context) != null ? _data$context2 : {}; 16188 for (let i3 = levels.length; i3--; ) { 16189 const candidate = (i3 + loadLevel) % levels.length; 16190 if (candidate !== loadLevel && candidate >= minAutoLevel && candidate <= maxAutoLevel && levels[candidate].loadError === 0) { 16191 var _level$audioGroups, _level$subtitleGroups; 16192 const levelCandidate = levels[candidate]; 16193 if (errorDetails === ErrorDetails.FRAG_GAP && fragErrorType === PlaylistLevelType.MAIN && data.frag) { 16194 const levelDetails = levels[candidate].details; 16195 if (levelDetails) { 16196 const fragCandidate = findFragmentByPTS(data.frag, levelDetails.fragments, data.frag.start); 16197 if (fragCandidate != null && fragCandidate.gap) { 16198 continue; 16199 } 16200 } 16201 } else if (playlistErrorType === PlaylistContextType.AUDIO_TRACK && levelCandidate.hasAudioGroup(playlistErrorGroupId) || playlistErrorType === PlaylistContextType.SUBTITLE_TRACK && levelCandidate.hasSubtitleGroup(playlistErrorGroupId)) { 16202 continue; 16203 } else if (fragErrorType === PlaylistLevelType.AUDIO && (_level$audioGroups = level.audioGroups) != null && _level$audioGroups.some((groupId) => levelCandidate.hasAudioGroup(groupId)) || fragErrorType === PlaylistLevelType.SUBTITLE && (_level$subtitleGroups = level.subtitleGroups) != null && _level$subtitleGroups.some((groupId) => levelCandidate.hasSubtitleGroup(groupId)) || findAudioCodecAlternate && level.audioCodec === levelCandidate.audioCodec || !findAudioCodecAlternate && level.audioCodec !== levelCandidate.audioCodec || findVideoCodecAlternate && level.codecSet === levelCandidate.codecSet) { 16204 continue; 16205 } 16206 nextLevel = candidate; 16207 break; 16208 } 16209 } 16210 if (nextLevel > -1 && hls.loadLevel !== nextLevel) { 16211 data.levelRetry = true; 16212 this.playlistError = 0; 16213 return { 16214 action: NetworkErrorAction.SendAlternateToPenaltyBox, 16215 flags: ErrorActionFlags.None, 16216 nextAutoLevel: nextLevel 16217 }; 16218 } 16219 } 16220 return { 16221 action: NetworkErrorAction.SendAlternateToPenaltyBox, 16222 flags: ErrorActionFlags.MoveAllAlternatesMatchingHost 16223 }; 16224 } 16225 onErrorOut(event, data) { 16226 var _data$errorAction; 16227 switch ((_data$errorAction = data.errorAction) == null ? void 0 : _data$errorAction.action) { 16228 case NetworkErrorAction.DoNothing: 16229 break; 16230 case NetworkErrorAction.SendAlternateToPenaltyBox: 16231 this.sendAlternateToPenaltyBox(data); 16232 if (!data.errorAction.resolved && data.details !== ErrorDetails.FRAG_GAP) { 16233 data.fatal = true; 16234 } else if (/MediaSource readyState: ended/.test(data.error.message)) { 16235 this.warn(`MediaSource ended after "${data.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`); 16236 this.hls.recoverMediaError(); 16237 } 16238 break; 16239 case NetworkErrorAction.RetryRequest: 16240 break; 16241 } 16242 if (data.fatal) { 16243 this.hls.stopLoad(); 16244 return; 16245 } 16246 } 16247 sendAlternateToPenaltyBox(data) { 16248 const hls = this.hls; 16249 const errorAction = data.errorAction; 16250 if (!errorAction) { 16251 return; 16252 } 16253 const { 16254 flags, 16255 hdcpLevel, 16256 nextAutoLevel 16257 } = errorAction; 16258 switch (flags) { 16259 case ErrorActionFlags.None: 16260 this.switchLevel(data, nextAutoLevel); 16261 break; 16262 case ErrorActionFlags.MoveAllAlternatesMatchingHDCP: 16263 if (hdcpLevel) { 16264 hls.maxHdcpLevel = HdcpLevels[HdcpLevels.indexOf(hdcpLevel) - 1]; 16265 errorAction.resolved = true; 16266 } 16267 this.warn(`Restricting playback to HDCP-LEVEL of "${hls.maxHdcpLevel}" or lower`); 16268 break; 16269 } 16270 if (!errorAction.resolved) { 16271 this.switchLevel(data, nextAutoLevel); 16272 } 16273 } 16274 switchLevel(data, levelIndex) { 16275 if (levelIndex !== void 0 && data.errorAction) { 16276 this.warn(`switching to level ${levelIndex} after ${data.details}`); 16277 this.hls.nextAutoLevel = levelIndex; 16278 data.errorAction.resolved = true; 16279 this.hls.nextLoadLevel = this.hls.nextAutoLevel; 16280 } 16281 } 16282}; 16283var BasePlaylistController = class { 16284 constructor(hls, logPrefix) { 16285 this.hls = void 0; 16286 this.timer = -1; 16287 this.requestScheduled = -1; 16288 this.canLoad = false; 16289 this.log = void 0; 16290 this.warn = void 0; 16291 this.log = logger.log.bind(logger, `${logPrefix}:`); 16292 this.warn = logger.warn.bind(logger, `${logPrefix}:`); 16293 this.hls = hls; 16294 } 16295 destroy() { 16296 this.clearTimer(); 16297 this.hls = this.log = this.warn = null; 16298 } 16299 clearTimer() { 16300 if (this.timer !== -1) { 16301 self.clearTimeout(this.timer); 16302 this.timer = -1; 16303 } 16304 } 16305 startLoad() { 16306 this.canLoad = true; 16307 this.requestScheduled = -1; 16308 this.loadPlaylist(); 16309 } 16310 stopLoad() { 16311 this.canLoad = false; 16312 this.clearTimer(); 16313 } 16314 switchParams(playlistUri, previous, current) { 16315 const renditionReports = previous == null ? void 0 : previous.renditionReports; 16316 if (renditionReports) { 16317 let foundIndex = -1; 16318 for (let i3 = 0; i3 < renditionReports.length; i3++) { 16319 const attr = renditionReports[i3]; 16320 let uri; 16321 try { 16322 uri = new self.URL(attr.URI, previous.url).href; 16323 } catch (error) { 16324 logger.warn(`Could not construct new URL for Rendition Report: ${error}`); 16325 uri = attr.URI || ""; 16326 } 16327 if (uri === playlistUri) { 16328 foundIndex = i3; 16329 break; 16330 } else if (uri === playlistUri.substring(0, uri.length)) { 16331 foundIndex = i3; 16332 } 16333 } 16334 if (foundIndex !== -1) { 16335 const attr = renditionReports[foundIndex]; 16336 const msn = parseInt(attr["LAST-MSN"]) || (previous == null ? void 0 : previous.lastPartSn); 16337 let part = parseInt(attr["LAST-PART"]) || (previous == null ? void 0 : previous.lastPartIndex); 16338 if (this.hls.config.lowLatencyMode) { 16339 const currentGoal = Math.min(previous.age - previous.partTarget, previous.targetduration); 16340 if (part >= 0 && currentGoal > previous.partTarget) { 16341 part += 1; 16342 } 16343 } 16344 const skip = current && getSkipValue(current); 16345 return new HlsUrlParameters(msn, part >= 0 ? part : void 0, skip); 16346 } 16347 } 16348 } 16349 loadPlaylist(hlsUrlParameters) { 16350 if (this.requestScheduled === -1) { 16351 this.requestScheduled = self.performance.now(); 16352 } 16353 } 16354 shouldLoadPlaylist(playlist) { 16355 return this.canLoad && !!playlist && !!playlist.url && (!playlist.details || playlist.details.live); 16356 } 16357 shouldReloadPlaylist(playlist) { 16358 return this.timer === -1 && this.requestScheduled === -1 && this.shouldLoadPlaylist(playlist); 16359 } 16360 playlistLoaded(index2, data, previousDetails) { 16361 const { 16362 details, 16363 stats 16364 } = data; 16365 const now2 = self.performance.now(); 16366 const elapsed = stats.loading.first ? Math.max(0, now2 - stats.loading.first) : 0; 16367 details.advancedDateTime = Date.now() - elapsed; 16368 if (details.live || previousDetails != null && previousDetails.live) { 16369 details.reloaded(previousDetails); 16370 if (previousDetails) { 16371 this.log(`live playlist ${index2} ${details.advanced ? "REFRESHED " + details.lastPartSn + "-" + details.lastPartIndex : details.updated ? "UPDATED" : "MISSED"}`); 16372 } 16373 if (previousDetails && details.fragments.length > 0) { 16374 mergeDetails(previousDetails, details); 16375 } 16376 if (!this.canLoad || !details.live) { 16377 return; 16378 } 16379 let deliveryDirectives; 16380 let msn = void 0; 16381 let part = void 0; 16382 if (details.canBlockReload && details.endSN && details.advanced) { 16383 const lowLatencyMode = this.hls.config.lowLatencyMode; 16384 const lastPartSn = details.lastPartSn; 16385 const endSn = details.endSN; 16386 const lastPartIndex = details.lastPartIndex; 16387 const hasParts = lastPartIndex !== -1; 16388 const lastPart = lastPartSn === endSn; 16389 const nextSnStartIndex = lowLatencyMode ? 0 : lastPartIndex; 16390 if (hasParts) { 16391 msn = lastPart ? endSn + 1 : lastPartSn; 16392 part = lastPart ? nextSnStartIndex : lastPartIndex + 1; 16393 } else { 16394 msn = endSn + 1; 16395 } 16396 const lastAdvanced = details.age; 16397 const cdnAge = lastAdvanced + details.ageHeader; 16398 let currentGoal = Math.min(cdnAge - details.partTarget, details.targetduration * 1.5); 16399 if (currentGoal > 0) { 16400 if (previousDetails && currentGoal > previousDetails.tuneInGoal) { 16401 this.warn(`CDN Tune-in goal increased from: ${previousDetails.tuneInGoal} to: ${currentGoal} with playlist age: ${details.age}`); 16402 currentGoal = 0; 16403 } else { 16404 const segments = Math.floor(currentGoal / details.targetduration); 16405 msn += segments; 16406 if (part !== void 0) { 16407 const parts = Math.round(currentGoal % details.targetduration / details.partTarget); 16408 part += parts; 16409 } 16410 this.log(`CDN Tune-in age: ${details.ageHeader}s last advanced ${lastAdvanced.toFixed(2)}s goal: ${currentGoal} skip sn ${segments} to part ${part}`); 16411 } 16412 details.tuneInGoal = currentGoal; 16413 } 16414 deliveryDirectives = this.getDeliveryDirectives(details, data.deliveryDirectives, msn, part); 16415 if (lowLatencyMode || !lastPart) { 16416 this.loadPlaylist(deliveryDirectives); 16417 return; 16418 } 16419 } else if (details.canBlockReload || details.canSkipUntil) { 16420 deliveryDirectives = this.getDeliveryDirectives(details, data.deliveryDirectives, msn, part); 16421 } 16422 const bufferInfo = this.hls.mainForwardBufferInfo; 16423 const position2 = bufferInfo ? bufferInfo.end - bufferInfo.len : 0; 16424 const distanceToLiveEdgeMs = (details.edge - position2) * 1e3; 16425 const reloadInterval = computeReloadInterval(details, distanceToLiveEdgeMs); 16426 if (details.updated && now2 > this.requestScheduled + reloadInterval) { 16427 this.requestScheduled = stats.loading.start; 16428 } 16429 if (msn !== void 0 && details.canBlockReload) { 16430 this.requestScheduled = stats.loading.first + reloadInterval - (details.partTarget * 1e3 || 1e3); 16431 } else if (this.requestScheduled === -1 || this.requestScheduled + reloadInterval < now2) { 16432 this.requestScheduled = now2; 16433 } else if (this.requestScheduled - now2 <= 0) { 16434 this.requestScheduled += reloadInterval; 16435 } 16436 let estimatedTimeUntilUpdate = this.requestScheduled - now2; 16437 estimatedTimeUntilUpdate = Math.max(0, estimatedTimeUntilUpdate); 16438 this.log(`reload live playlist ${index2} in ${Math.round(estimatedTimeUntilUpdate)} ms`); 16439 this.timer = self.setTimeout(() => this.loadPlaylist(deliveryDirectives), estimatedTimeUntilUpdate); 16440 } else { 16441 this.clearTimer(); 16442 } 16443 } 16444 getDeliveryDirectives(details, previousDeliveryDirectives, msn, part) { 16445 let skip = getSkipValue(details); 16446 if (previousDeliveryDirectives != null && previousDeliveryDirectives.skip && details.deltaUpdateFailed) { 16447 msn = previousDeliveryDirectives.msn; 16448 part = previousDeliveryDirectives.part; 16449 skip = HlsSkip.No; 16450 } 16451 return new HlsUrlParameters(msn, part, skip); 16452 } 16453 checkRetry(errorEvent) { 16454 const errorDetails = errorEvent.details; 16455 const isTimeout = isTimeoutError(errorEvent); 16456 const errorAction = errorEvent.errorAction; 16457 const { 16458 action, 16459 retryCount = 0, 16460 retryConfig 16461 } = errorAction || {}; 16462 const retry = !!errorAction && !!retryConfig && (action === NetworkErrorAction.RetryRequest || !errorAction.resolved && action === NetworkErrorAction.SendAlternateToPenaltyBox); 16463 if (retry) { 16464 var _errorEvent$context; 16465 this.requestScheduled = -1; 16466 if (retryCount >= retryConfig.maxNumRetry) { 16467 return false; 16468 } 16469 if (isTimeout && (_errorEvent$context = errorEvent.context) != null && _errorEvent$context.deliveryDirectives) { 16470 this.warn(`Retrying playlist loading ${retryCount + 1}/${retryConfig.maxNumRetry} after "${errorDetails}" without delivery-directives`); 16471 this.loadPlaylist(); 16472 } else { 16473 const delay2 = getRetryDelay(retryConfig, retryCount); 16474 this.timer = self.setTimeout(() => this.loadPlaylist(), delay2); 16475 this.warn(`Retrying playlist loading ${retryCount + 1}/${retryConfig.maxNumRetry} after "${errorDetails}" in ${delay2}ms`); 16476 } 16477 errorEvent.levelRetry = true; 16478 errorAction.resolved = true; 16479 } 16480 return retry; 16481 } 16482}; 16483var EWMA = class { 16484 // About half of the estimated value will be from the last |halfLife| samples by weight. 16485 constructor(halfLife, estimate = 0, weight = 0) { 16486 this.halfLife = void 0; 16487 this.alpha_ = void 0; 16488 this.estimate_ = void 0; 16489 this.totalWeight_ = void 0; 16490 this.halfLife = halfLife; 16491 this.alpha_ = halfLife ? Math.exp(Math.log(0.5) / halfLife) : 0; 16492 this.estimate_ = estimate; 16493 this.totalWeight_ = weight; 16494 } 16495 sample(weight, value) { 16496 const adjAlpha = Math.pow(this.alpha_, weight); 16497 this.estimate_ = value * (1 - adjAlpha) + adjAlpha * this.estimate_; 16498 this.totalWeight_ += weight; 16499 } 16500 getTotalWeight() { 16501 return this.totalWeight_; 16502 } 16503 getEstimate() { 16504 if (this.alpha_) { 16505 const zeroFactor = 1 - Math.pow(this.alpha_, this.totalWeight_); 16506 if (zeroFactor) { 16507 return this.estimate_ / zeroFactor; 16508 } 16509 } 16510 return this.estimate_; 16511 } 16512}; 16513var EwmaBandWidthEstimator = class { 16514 constructor(slow, fast, defaultEstimate, defaultTTFB = 100) { 16515 this.defaultEstimate_ = void 0; 16516 this.minWeight_ = void 0; 16517 this.minDelayMs_ = void 0; 16518 this.slow_ = void 0; 16519 this.fast_ = void 0; 16520 this.defaultTTFB_ = void 0; 16521 this.ttfb_ = void 0; 16522 this.defaultEstimate_ = defaultEstimate; 16523 this.minWeight_ = 1e-3; 16524 this.minDelayMs_ = 50; 16525 this.slow_ = new EWMA(slow); 16526 this.fast_ = new EWMA(fast); 16527 this.defaultTTFB_ = defaultTTFB; 16528 this.ttfb_ = new EWMA(slow); 16529 } 16530 update(slow, fast) { 16531 const { 16532 slow_, 16533 fast_, 16534 ttfb_ 16535 } = this; 16536 if (slow_.halfLife !== slow) { 16537 this.slow_ = new EWMA(slow, slow_.getEstimate(), slow_.getTotalWeight()); 16538 } 16539 if (fast_.halfLife !== fast) { 16540 this.fast_ = new EWMA(fast, fast_.getEstimate(), fast_.getTotalWeight()); 16541 } 16542 if (ttfb_.halfLife !== slow) { 16543 this.ttfb_ = new EWMA(slow, ttfb_.getEstimate(), ttfb_.getTotalWeight()); 16544 } 16545 } 16546 sample(durationMs, numBytes) { 16547 durationMs = Math.max(durationMs, this.minDelayMs_); 16548 const numBits = 8 * numBytes; 16549 const durationS = durationMs / 1e3; 16550 const bandwidthInBps = numBits / durationS; 16551 this.fast_.sample(durationS, bandwidthInBps); 16552 this.slow_.sample(durationS, bandwidthInBps); 16553 } 16554 sampleTTFB(ttfb) { 16555 const seconds = ttfb / 1e3; 16556 const weight = Math.sqrt(2) * Math.exp(-Math.pow(seconds, 2) / 2); 16557 this.ttfb_.sample(weight, Math.max(ttfb, 5)); 16558 } 16559 canEstimate() { 16560 return this.fast_.getTotalWeight() >= this.minWeight_; 16561 } 16562 getEstimate() { 16563 if (this.canEstimate()) { 16564 return Math.min(this.fast_.getEstimate(), this.slow_.getEstimate()); 16565 } else { 16566 return this.defaultEstimate_; 16567 } 16568 } 16569 getEstimateTTFB() { 16570 if (this.ttfb_.getTotalWeight() >= this.minWeight_) { 16571 return this.ttfb_.getEstimate(); 16572 } else { 16573 return this.defaultTTFB_; 16574 } 16575 } 16576 destroy() { 16577 } 16578}; 16579var SUPPORTED_INFO_DEFAULT = { 16580 supported: true, 16581 configurations: [], 16582 decodingInfoResults: [{ 16583 supported: true, 16584 powerEfficient: true, 16585 smooth: true 16586 }] 16587}; 16588var SUPPORTED_INFO_CACHE = {}; 16589function requiresMediaCapabilitiesDecodingInfo(level, audioTracksByGroup, currentVideoRange, currentFrameRate, currentBw, audioPreference) { 16590 const audioGroups = level.audioCodec ? level.audioGroups : null; 16591 const audioCodecPreference = audioPreference == null ? void 0 : audioPreference.audioCodec; 16592 const channelsPreference = audioPreference == null ? void 0 : audioPreference.channels; 16593 const maxChannels = channelsPreference ? parseInt(channelsPreference) : audioCodecPreference ? Infinity : 2; 16594 let audioChannels = null; 16595 if (audioGroups != null && audioGroups.length) { 16596 try { 16597 if (audioGroups.length === 1 && audioGroups[0]) { 16598 audioChannels = audioTracksByGroup.groups[audioGroups[0]].channels; 16599 } else { 16600 audioChannels = audioGroups.reduce((acc, groupId) => { 16601 if (groupId) { 16602 const audioTrackGroup = audioTracksByGroup.groups[groupId]; 16603 if (!audioTrackGroup) { 16604 throw new Error(`Audio track group ${groupId} not found`); 16605 } 16606 Object.keys(audioTrackGroup.channels).forEach((key) => { 16607 acc[key] = (acc[key] || 0) + audioTrackGroup.channels[key]; 16608 }); 16609 } 16610 return acc; 16611 }, { 16612 2: 0 16613 }); 16614 } 16615 } catch (error) { 16616 return true; 16617 } 16618 } 16619 return level.videoCodec !== void 0 && (level.width > 1920 && level.height > 1088 || level.height > 1920 && level.width > 1088 || level.frameRate > Math.max(currentFrameRate, 30) || level.videoRange !== "SDR" && level.videoRange !== currentVideoRange || level.bitrate > Math.max(currentBw, 8e6)) || !!audioChannels && isFiniteNumber(maxChannels) && Object.keys(audioChannels).some((channels) => parseInt(channels) > maxChannels); 16620} 16621function getMediaDecodingInfoPromise(level, audioTracksByGroup, mediaCapabilities) { 16622 const videoCodecs = level.videoCodec; 16623 const audioCodecs = level.audioCodec; 16624 if (!videoCodecs || !audioCodecs || !mediaCapabilities) { 16625 return Promise.resolve(SUPPORTED_INFO_DEFAULT); 16626 } 16627 const baseVideoConfiguration = { 16628 width: level.width, 16629 height: level.height, 16630 bitrate: Math.ceil(Math.max(level.bitrate * 0.9, level.averageBitrate)), 16631 // Assume a framerate of 30fps since MediaCapabilities will not accept Level default of 0. 16632 framerate: level.frameRate || 30 16633 }; 16634 const videoRange = level.videoRange; 16635 if (videoRange !== "SDR") { 16636 baseVideoConfiguration.transferFunction = videoRange.toLowerCase(); 16637 } 16638 const configurations = videoCodecs.split(",").map((videoCodec) => ({ 16639 type: "media-source", 16640 video: _objectSpread23(_objectSpread23({}, baseVideoConfiguration), {}, { 16641 contentType: mimeTypeForCodec(videoCodec, "video") 16642 }) 16643 })); 16644 if (audioCodecs && level.audioGroups) { 16645 level.audioGroups.forEach((audioGroupId) => { 16646 var _audioTracksByGroup$g; 16647 if (!audioGroupId) { 16648 return; 16649 } 16650 (_audioTracksByGroup$g = audioTracksByGroup.groups[audioGroupId]) == null ? void 0 : _audioTracksByGroup$g.tracks.forEach((audioTrack) => { 16651 if (audioTrack.groupId === audioGroupId) { 16652 const channels = audioTrack.channels || ""; 16653 const channelsNumber = parseFloat(channels); 16654 if (isFiniteNumber(channelsNumber) && channelsNumber > 2) { 16655 configurations.push.apply(configurations, audioCodecs.split(",").map((audioCodec) => ({ 16656 type: "media-source", 16657 audio: { 16658 contentType: mimeTypeForCodec(audioCodec, "audio"), 16659 channels: "" + channelsNumber 16660 // spatialRendering: 16661 // audioCodec === 'ec-3' && channels.indexOf('JOC'), 16662 } 16663 }))); 16664 } 16665 } 16666 }); 16667 }); 16668 } 16669 return Promise.all(configurations.map((configuration) => { 16670 const decodingInfoKey = getMediaDecodingInfoKey(configuration); 16671 return SUPPORTED_INFO_CACHE[decodingInfoKey] || (SUPPORTED_INFO_CACHE[decodingInfoKey] = mediaCapabilities.decodingInfo(configuration)); 16672 })).then((decodingInfoResults) => ({ 16673 supported: !decodingInfoResults.some((info) => !info.supported), 16674 configurations, 16675 decodingInfoResults 16676 })).catch((error) => ({ 16677 supported: false, 16678 configurations, 16679 decodingInfoResults: [], 16680 error 16681 })); 16682} 16683function getMediaDecodingInfoKey(config) { 16684 const { 16685 audio, 16686 video 16687 } = config; 16688 const mediaConfig = video || audio; 16689 if (mediaConfig) { 16690 const codec = mediaConfig.contentType.split('"')[1]; 16691 if (video) { 16692 return `r${video.height}x${video.width}f${Math.ceil(video.framerate)}${video.transferFunction || "sd"}_${codec}_${Math.ceil(video.bitrate / 1e5)}`; 16693 } 16694 if (audio) { 16695 return `c${audio.channels}${audio.spatialRendering ? "s" : "n"}_${codec}`; 16696 } 16697 } 16698 return ""; 16699} 16700function isHdrSupported() { 16701 if (typeof matchMedia === "function") { 16702 const mediaQueryList = matchMedia("(dynamic-range: high)"); 16703 const badQuery = matchMedia("bad query"); 16704 if (mediaQueryList.media !== badQuery.media) { 16705 return mediaQueryList.matches === true; 16706 } 16707 } 16708 return false; 16709} 16710function getVideoSelectionOptions(currentVideoRange, videoPreference) { 16711 let preferHDR = false; 16712 let allowedVideoRanges = []; 16713 if (currentVideoRange) { 16714 preferHDR = currentVideoRange !== "SDR"; 16715 allowedVideoRanges = [currentVideoRange]; 16716 } 16717 if (videoPreference) { 16718 allowedVideoRanges = videoPreference.allowedVideoRanges || VideoRangeValues.slice(0); 16719 preferHDR = videoPreference.preferHDR !== void 0 ? videoPreference.preferHDR : isHdrSupported(); 16720 if (preferHDR) { 16721 allowedVideoRanges = allowedVideoRanges.filter((range) => range !== "SDR"); 16722 } else { 16723 allowedVideoRanges = ["SDR"]; 16724 } 16725 } 16726 return { 16727 preferHDR, 16728 allowedVideoRanges 16729 }; 16730} 16731function getStartCodecTier(codecTiers, currentVideoRange, currentBw, audioPreference, videoPreference) { 16732 const codecSets = Object.keys(codecTiers); 16733 const channelsPreference = audioPreference == null ? void 0 : audioPreference.channels; 16734 const audioCodecPreference = audioPreference == null ? void 0 : audioPreference.audioCodec; 16735 const preferStereo = channelsPreference && parseInt(channelsPreference) === 2; 16736 let hasStereo = true; 16737 let hasCurrentVideoRange = false; 16738 let minHeight = Infinity; 16739 let minFramerate = Infinity; 16740 let minBitrate = Infinity; 16741 let selectedScore = 0; 16742 let videoRanges = []; 16743 const { 16744 preferHDR, 16745 allowedVideoRanges 16746 } = getVideoSelectionOptions(currentVideoRange, videoPreference); 16747 for (let i3 = codecSets.length; i3--; ) { 16748 const tier = codecTiers[codecSets[i3]]; 16749 hasStereo = tier.channels[2] > 0; 16750 minHeight = Math.min(minHeight, tier.minHeight); 16751 minFramerate = Math.min(minFramerate, tier.minFramerate); 16752 minBitrate = Math.min(minBitrate, tier.minBitrate); 16753 const matchingVideoRanges = allowedVideoRanges.filter((range) => tier.videoRanges[range] > 0); 16754 if (matchingVideoRanges.length > 0) { 16755 hasCurrentVideoRange = true; 16756 videoRanges = matchingVideoRanges; 16757 } 16758 } 16759 minHeight = isFiniteNumber(minHeight) ? minHeight : 0; 16760 minFramerate = isFiniteNumber(minFramerate) ? minFramerate : 0; 16761 const maxHeight = Math.max(1080, minHeight); 16762 const maxFramerate = Math.max(30, minFramerate); 16763 minBitrate = isFiniteNumber(minBitrate) ? minBitrate : currentBw; 16764 currentBw = Math.max(minBitrate, currentBw); 16765 if (!hasCurrentVideoRange) { 16766 currentVideoRange = void 0; 16767 videoRanges = []; 16768 } 16769 const codecSet = codecSets.reduce((selected, candidate) => { 16770 const candidateTier = codecTiers[candidate]; 16771 if (candidate === selected) { 16772 return selected; 16773 } 16774 if (candidateTier.minBitrate > currentBw) { 16775 logStartCodecCandidateIgnored(candidate, `min bitrate of ${candidateTier.minBitrate} > current estimate of ${currentBw}`); 16776 return selected; 16777 } 16778 if (!candidateTier.hasDefaultAudio) { 16779 logStartCodecCandidateIgnored(candidate, `no renditions with default or auto-select sound found`); 16780 return selected; 16781 } 16782 if (audioCodecPreference && candidate.indexOf(audioCodecPreference.substring(0, 4)) % 5 !== 0) { 16783 logStartCodecCandidateIgnored(candidate, `audio codec preference "${audioCodecPreference}" not found`); 16784 return selected; 16785 } 16786 if (channelsPreference && !preferStereo) { 16787 if (!candidateTier.channels[channelsPreference]) { 16788 logStartCodecCandidateIgnored(candidate, `no renditions with ${channelsPreference} channel sound found (channels options: ${Object.keys(candidateTier.channels)})`); 16789 return selected; 16790 } 16791 } else if ((!audioCodecPreference || preferStereo) && hasStereo && candidateTier.channels["2"] === 0) { 16792 logStartCodecCandidateIgnored(candidate, `no renditions with stereo sound found`); 16793 return selected; 16794 } 16795 if (candidateTier.minHeight > maxHeight) { 16796 logStartCodecCandidateIgnored(candidate, `min resolution of ${candidateTier.minHeight} > maximum of ${maxHeight}`); 16797 return selected; 16798 } 16799 if (candidateTier.minFramerate > maxFramerate) { 16800 logStartCodecCandidateIgnored(candidate, `min framerate of ${candidateTier.minFramerate} > maximum of ${maxFramerate}`); 16801 return selected; 16802 } 16803 if (!videoRanges.some((range) => candidateTier.videoRanges[range] > 0)) { 16804 logStartCodecCandidateIgnored(candidate, `no variants with VIDEO-RANGE of ${JSON.stringify(videoRanges)} found`); 16805 return selected; 16806 } 16807 if (candidateTier.maxScore < selectedScore) { 16808 logStartCodecCandidateIgnored(candidate, `max score of ${candidateTier.maxScore} < selected max of ${selectedScore}`); 16809 return selected; 16810 } 16811 if (selected && (codecsSetSelectionPreferenceValue(candidate) >= codecsSetSelectionPreferenceValue(selected) || candidateTier.fragmentError > codecTiers[selected].fragmentError)) { 16812 return selected; 16813 } 16814 selectedScore = candidateTier.maxScore; 16815 return candidate; 16816 }, void 0); 16817 return { 16818 codecSet, 16819 videoRanges, 16820 preferHDR, 16821 minFramerate, 16822 minBitrate 16823 }; 16824} 16825function logStartCodecCandidateIgnored(codeSet, reason) { 16826 logger.log(`[abr] start candidates with "${codeSet}" ignored because ${reason}`); 16827} 16828function getAudioTracksByGroup(allAudioTracks) { 16829 return allAudioTracks.reduce((audioTracksByGroup, track) => { 16830 let trackGroup = audioTracksByGroup.groups[track.groupId]; 16831 if (!trackGroup) { 16832 trackGroup = audioTracksByGroup.groups[track.groupId] = { 16833 tracks: [], 16834 channels: { 16835 2: 0 16836 }, 16837 hasDefault: false, 16838 hasAutoSelect: false 16839 }; 16840 } 16841 trackGroup.tracks.push(track); 16842 const channelsKey = track.channels || "2"; 16843 trackGroup.channels[channelsKey] = (trackGroup.channels[channelsKey] || 0) + 1; 16844 trackGroup.hasDefault = trackGroup.hasDefault || track.default; 16845 trackGroup.hasAutoSelect = trackGroup.hasAutoSelect || track.autoselect; 16846 if (trackGroup.hasDefault) { 16847 audioTracksByGroup.hasDefaultAudio = true; 16848 } 16849 if (trackGroup.hasAutoSelect) { 16850 audioTracksByGroup.hasAutoSelectAudio = true; 16851 } 16852 return audioTracksByGroup; 16853 }, { 16854 hasDefaultAudio: false, 16855 hasAutoSelectAudio: false, 16856 groups: {} 16857 }); 16858} 16859function getCodecTiers(levels, audioTracksByGroup, minAutoLevel, maxAutoLevel) { 16860 return levels.slice(minAutoLevel, maxAutoLevel + 1).reduce((tiers, level) => { 16861 if (!level.codecSet) { 16862 return tiers; 16863 } 16864 const audioGroups = level.audioGroups; 16865 let tier = tiers[level.codecSet]; 16866 if (!tier) { 16867 tiers[level.codecSet] = tier = { 16868 minBitrate: Infinity, 16869 minHeight: Infinity, 16870 minFramerate: Infinity, 16871 maxScore: 0, 16872 videoRanges: { 16873 SDR: 0 16874 }, 16875 channels: { 16876 "2": 0 16877 }, 16878 hasDefaultAudio: !audioGroups, 16879 fragmentError: 0 16880 }; 16881 } 16882 tier.minBitrate = Math.min(tier.minBitrate, level.bitrate); 16883 const lesserWidthOrHeight = Math.min(level.height, level.width); 16884 tier.minHeight = Math.min(tier.minHeight, lesserWidthOrHeight); 16885 tier.minFramerate = Math.min(tier.minFramerate, level.frameRate); 16886 tier.maxScore = Math.max(tier.maxScore, level.score); 16887 tier.fragmentError += level.fragmentError; 16888 tier.videoRanges[level.videoRange] = (tier.videoRanges[level.videoRange] || 0) + 1; 16889 if (audioGroups) { 16890 audioGroups.forEach((audioGroupId) => { 16891 if (!audioGroupId) { 16892 return; 16893 } 16894 const audioGroup = audioTracksByGroup.groups[audioGroupId]; 16895 if (!audioGroup) { 16896 return; 16897 } 16898 tier.hasDefaultAudio = tier.hasDefaultAudio || audioTracksByGroup.hasDefaultAudio ? audioGroup.hasDefault : audioGroup.hasAutoSelect || !audioTracksByGroup.hasDefaultAudio && !audioTracksByGroup.hasAutoSelectAudio; 16899 Object.keys(audioGroup.channels).forEach((channels) => { 16900 tier.channels[channels] = (tier.channels[channels] || 0) + audioGroup.channels[channels]; 16901 }); 16902 }); 16903 } 16904 return tiers; 16905 }, {}); 16906} 16907function findMatchingOption(option, tracks, matchPredicate) { 16908 if ("attrs" in option) { 16909 const index2 = tracks.indexOf(option); 16910 if (index2 !== -1) { 16911 return index2; 16912 } 16913 } 16914 for (let i3 = 0; i3 < tracks.length; i3++) { 16915 const track = tracks[i3]; 16916 if (matchesOption(option, track, matchPredicate)) { 16917 return i3; 16918 } 16919 } 16920 return -1; 16921} 16922function matchesOption(option, track, matchPredicate) { 16923 const { 16924 groupId, 16925 name, 16926 lang, 16927 assocLang, 16928 default: isDefault 16929 } = option; 16930 const forced = option.forced; 16931 return (groupId === void 0 || track.groupId === groupId) && (name === void 0 || track.name === name) && (lang === void 0 || track.lang === lang) && (lang === void 0 || track.assocLang === assocLang) && (isDefault === void 0 || track.default === isDefault) && (forced === void 0 || track.forced === forced) && (!("characteristics" in option) || characteristicsMatch(option.characteristics || "", track.characteristics)) && (matchPredicate === void 0 || matchPredicate(option, track)); 16932} 16933function characteristicsMatch(characteristicsA, characteristicsB = "") { 16934 const arrA = characteristicsA.split(","); 16935 const arrB = characteristicsB.split(","); 16936 return arrA.length === arrB.length && !arrA.some((el) => arrB.indexOf(el) === -1); 16937} 16938function audioMatchPredicate(option, track) { 16939 const { 16940 audioCodec, 16941 channels 16942 } = option; 16943 return (audioCodec === void 0 || (track.audioCodec || "").substring(0, 4) === audioCodec.substring(0, 4)) && (channels === void 0 || channels === (track.channels || "2")); 16944} 16945function findClosestLevelWithAudioGroup(option, levels, allAudioTracks, searchIndex, matchPredicate) { 16946 const currentLevel = levels[searchIndex]; 16947 const variants = levels.reduce((variantMap, level, index2) => { 16948 const uri = level.uri; 16949 const renditions2 = variantMap[uri] || (variantMap[uri] = []); 16950 renditions2.push(index2); 16951 return variantMap; 16952 }, {}); 16953 const renditions = variants[currentLevel.uri]; 16954 if (renditions.length > 1) { 16955 searchIndex = Math.max.apply(Math, renditions); 16956 } 16957 const currentVideoRange = currentLevel.videoRange; 16958 const currentFrameRate = currentLevel.frameRate; 16959 const currentVideoCodec = currentLevel.codecSet.substring(0, 4); 16960 const matchingVideo = searchDownAndUpList(levels, searchIndex, (level) => { 16961 if (level.videoRange !== currentVideoRange || level.frameRate !== currentFrameRate || level.codecSet.substring(0, 4) !== currentVideoCodec) { 16962 return false; 16963 } 16964 const audioGroups = level.audioGroups; 16965 const tracks = allAudioTracks.filter((track) => !audioGroups || audioGroups.indexOf(track.groupId) !== -1); 16966 return findMatchingOption(option, tracks, matchPredicate) > -1; 16967 }); 16968 if (matchingVideo > -1) { 16969 return matchingVideo; 16970 } 16971 return searchDownAndUpList(levels, searchIndex, (level) => { 16972 const audioGroups = level.audioGroups; 16973 const tracks = allAudioTracks.filter((track) => !audioGroups || audioGroups.indexOf(track.groupId) !== -1); 16974 return findMatchingOption(option, tracks, matchPredicate) > -1; 16975 }); 16976} 16977function searchDownAndUpList(arr, searchIndex, predicate) { 16978 for (let i3 = searchIndex; i3 > -1; i3--) { 16979 if (predicate(arr[i3])) { 16980 return i3; 16981 } 16982 } 16983 for (let i3 = searchIndex + 1; i3 < arr.length; i3++) { 16984 if (predicate(arr[i3])) { 16985 return i3; 16986 } 16987 } 16988 return -1; 16989} 16990var AbrController = class { 16991 constructor(_hls) { 16992 this.hls = void 0; 16993 this.lastLevelLoadSec = 0; 16994 this.lastLoadedFragLevel = -1; 16995 this.firstSelection = -1; 16996 this._nextAutoLevel = -1; 16997 this.nextAutoLevelKey = ""; 16998 this.audioTracksByGroup = null; 16999 this.codecTiers = null; 17000 this.timer = -1; 17001 this.fragCurrent = null; 17002 this.partCurrent = null; 17003 this.bitrateTestDelay = 0; 17004 this.bwEstimator = void 0; 17005 this._abandonRulesCheck = () => { 17006 const { 17007 fragCurrent: frag, 17008 partCurrent: part, 17009 hls 17010 } = this; 17011 const { 17012 autoLevelEnabled, 17013 media 17014 } = hls; 17015 if (!frag || !media) { 17016 return; 17017 } 17018 const now2 = performance.now(); 17019 const stats = part ? part.stats : frag.stats; 17020 const duration = part ? part.duration : frag.duration; 17021 const timeLoading = now2 - stats.loading.start; 17022 const minAutoLevel = hls.minAutoLevel; 17023 if (stats.aborted || stats.loaded && stats.loaded === stats.total || frag.level <= minAutoLevel) { 17024 this.clearTimer(); 17025 this._nextAutoLevel = -1; 17026 return; 17027 } 17028 if (!autoLevelEnabled || media.paused || !media.playbackRate || !media.readyState) { 17029 return; 17030 } 17031 const bufferInfo = hls.mainForwardBufferInfo; 17032 if (bufferInfo === null) { 17033 return; 17034 } 17035 const ttfbEstimate = this.bwEstimator.getEstimateTTFB(); 17036 const playbackRate = Math.abs(media.playbackRate); 17037 if (timeLoading <= Math.max(ttfbEstimate, 1e3 * (duration / (playbackRate * 2)))) { 17038 return; 17039 } 17040 const bufferStarvationDelay = bufferInfo.len / playbackRate; 17041 const ttfb = stats.loading.first ? stats.loading.first - stats.loading.start : -1; 17042 const loadedFirstByte = stats.loaded && ttfb > -1; 17043 const bwEstimate = this.getBwEstimate(); 17044 const levels = hls.levels; 17045 const level = levels[frag.level]; 17046 const expectedLen = stats.total || Math.max(stats.loaded, Math.round(duration * level.averageBitrate / 8)); 17047 let timeStreaming = loadedFirstByte ? timeLoading - ttfb : timeLoading; 17048 if (timeStreaming < 1 && loadedFirstByte) { 17049 timeStreaming = Math.min(timeLoading, stats.loaded * 8 / bwEstimate); 17050 } 17051 const loadRate = loadedFirstByte ? stats.loaded * 1e3 / timeStreaming : 0; 17052 const fragLoadedDelay = loadRate ? (expectedLen - stats.loaded) / loadRate : expectedLen * 8 / bwEstimate + ttfbEstimate / 1e3; 17053 if (fragLoadedDelay <= bufferStarvationDelay) { 17054 return; 17055 } 17056 const bwe = loadRate ? loadRate * 8 : bwEstimate; 17057 let fragLevelNextLoadedDelay = Number.POSITIVE_INFINITY; 17058 let nextLoadLevel; 17059 for (nextLoadLevel = frag.level - 1; nextLoadLevel > minAutoLevel; nextLoadLevel--) { 17060 const levelNextBitrate = levels[nextLoadLevel].maxBitrate; 17061 fragLevelNextLoadedDelay = this.getTimeToLoadFrag(ttfbEstimate / 1e3, bwe, duration * levelNextBitrate, !levels[nextLoadLevel].details); 17062 if (fragLevelNextLoadedDelay < bufferStarvationDelay) { 17063 break; 17064 } 17065 } 17066 if (fragLevelNextLoadedDelay >= fragLoadedDelay) { 17067 return; 17068 } 17069 if (fragLevelNextLoadedDelay > duration * 10) { 17070 return; 17071 } 17072 hls.nextLoadLevel = hls.nextAutoLevel = nextLoadLevel; 17073 if (loadedFirstByte) { 17074 this.bwEstimator.sample(timeLoading - Math.min(ttfbEstimate, ttfb), stats.loaded); 17075 } else { 17076 this.bwEstimator.sampleTTFB(timeLoading); 17077 } 17078 const nextLoadLevelBitrate = levels[nextLoadLevel].maxBitrate; 17079 if (this.getBwEstimate() * this.hls.config.abrBandWidthUpFactor > nextLoadLevelBitrate) { 17080 this.resetEstimator(nextLoadLevelBitrate); 17081 } 17082 this.clearTimer(); 17083 logger.warn(`[abr] Fragment ${frag.sn}${part ? " part " + part.index : ""} of level ${frag.level} is loading too slowly; 17084 Time to underbuffer: ${bufferStarvationDelay.toFixed(3)} s 17085 Estimated load time for current fragment: ${fragLoadedDelay.toFixed(3)} s 17086 Estimated load time for down switch fragment: ${fragLevelNextLoadedDelay.toFixed(3)} s 17087 TTFB estimate: ${ttfb | 0} ms 17088 Current BW estimate: ${isFiniteNumber(bwEstimate) ? bwEstimate | 0 : "Unknown"} bps 17089 New BW estimate: ${this.getBwEstimate() | 0} bps 17090 Switching to level ${nextLoadLevel} @ ${nextLoadLevelBitrate | 0} bps`); 17091 hls.trigger(Events.FRAG_LOAD_EMERGENCY_ABORTED, { 17092 frag, 17093 part, 17094 stats 17095 }); 17096 }; 17097 this.hls = _hls; 17098 this.bwEstimator = this.initEstimator(); 17099 this.registerListeners(); 17100 } 17101 resetEstimator(abrEwmaDefaultEstimate) { 17102 if (abrEwmaDefaultEstimate) { 17103 logger.log(`setting initial bwe to ${abrEwmaDefaultEstimate}`); 17104 this.hls.config.abrEwmaDefaultEstimate = abrEwmaDefaultEstimate; 17105 } 17106 this.firstSelection = -1; 17107 this.bwEstimator = this.initEstimator(); 17108 } 17109 initEstimator() { 17110 const config = this.hls.config; 17111 return new EwmaBandWidthEstimator(config.abrEwmaSlowVoD, config.abrEwmaFastVoD, config.abrEwmaDefaultEstimate); 17112 } 17113 registerListeners() { 17114 const { 17115 hls 17116 } = this; 17117 hls.on(Events.MANIFEST_LOADING, this.onManifestLoading, this); 17118 hls.on(Events.FRAG_LOADING, this.onFragLoading, this); 17119 hls.on(Events.FRAG_LOADED, this.onFragLoaded, this); 17120 hls.on(Events.FRAG_BUFFERED, this.onFragBuffered, this); 17121 hls.on(Events.LEVEL_SWITCHING, this.onLevelSwitching, this); 17122 hls.on(Events.LEVEL_LOADED, this.onLevelLoaded, this); 17123 hls.on(Events.LEVELS_UPDATED, this.onLevelsUpdated, this); 17124 hls.on(Events.MAX_AUTO_LEVEL_UPDATED, this.onMaxAutoLevelUpdated, this); 17125 hls.on(Events.ERROR, this.onError, this); 17126 } 17127 unregisterListeners() { 17128 const { 17129 hls 17130 } = this; 17131 if (!hls) { 17132 return; 17133 } 17134 hls.off(Events.MANIFEST_LOADING, this.onManifestLoading, this); 17135 hls.off(Events.FRAG_LOADING, this.onFragLoading, this); 17136 hls.off(Events.FRAG_LOADED, this.onFragLoaded, this); 17137 hls.off(Events.FRAG_BUFFERED, this.onFragBuffered, this); 17138 hls.off(Events.LEVEL_SWITCHING, this.onLevelSwitching, this); 17139 hls.off(Events.LEVEL_LOADED, this.onLevelLoaded, this); 17140 hls.off(Events.LEVELS_UPDATED, this.onLevelsUpdated, this); 17141 hls.off(Events.MAX_AUTO_LEVEL_UPDATED, this.onMaxAutoLevelUpdated, this); 17142 hls.off(Events.ERROR, this.onError, this); 17143 } 17144 destroy() { 17145 this.unregisterListeners(); 17146 this.clearTimer(); 17147 this.hls = this._abandonRulesCheck = null; 17148 this.fragCurrent = this.partCurrent = null; 17149 } 17150 onManifestLoading(event, data) { 17151 this.lastLoadedFragLevel = -1; 17152 this.firstSelection = -1; 17153 this.lastLevelLoadSec = 0; 17154 this.fragCurrent = this.partCurrent = null; 17155 this.onLevelsUpdated(); 17156 this.clearTimer(); 17157 } 17158 onLevelsUpdated() { 17159 if (this.lastLoadedFragLevel > -1 && this.fragCurrent) { 17160 this.lastLoadedFragLevel = this.fragCurrent.level; 17161 } 17162 this._nextAutoLevel = -1; 17163 this.onMaxAutoLevelUpdated(); 17164 this.codecTiers = null; 17165 this.audioTracksByGroup = null; 17166 } 17167 onMaxAutoLevelUpdated() { 17168 this.firstSelection = -1; 17169 this.nextAutoLevelKey = ""; 17170 } 17171 onFragLoading(event, data) { 17172 const frag = data.frag; 17173 if (this.ignoreFragment(frag)) { 17174 return; 17175 } 17176 if (!frag.bitrateTest) { 17177 var _data$part; 17178 this.fragCurrent = frag; 17179 this.partCurrent = (_data$part = data.part) != null ? _data$part : null; 17180 } 17181 this.clearTimer(); 17182 this.timer = self.setInterval(this._abandonRulesCheck, 100); 17183 } 17184 onLevelSwitching(event, data) { 17185 this.clearTimer(); 17186 } 17187 onError(event, data) { 17188 if (data.fatal) { 17189 return; 17190 } 17191 switch (data.details) { 17192 case ErrorDetails.BUFFER_ADD_CODEC_ERROR: 17193 case ErrorDetails.BUFFER_APPEND_ERROR: 17194 this.lastLoadedFragLevel = -1; 17195 this.firstSelection = -1; 17196 break; 17197 case ErrorDetails.FRAG_LOAD_TIMEOUT: { 17198 const frag = data.frag; 17199 const { 17200 fragCurrent, 17201 partCurrent: part 17202 } = this; 17203 if (frag && fragCurrent && frag.sn === fragCurrent.sn && frag.level === fragCurrent.level) { 17204 const now2 = performance.now(); 17205 const stats = part ? part.stats : frag.stats; 17206 const timeLoading = now2 - stats.loading.start; 17207 const ttfb = stats.loading.first ? stats.loading.first - stats.loading.start : -1; 17208 const loadedFirstByte = stats.loaded && ttfb > -1; 17209 if (loadedFirstByte) { 17210 const ttfbEstimate = this.bwEstimator.getEstimateTTFB(); 17211 this.bwEstimator.sample(timeLoading - Math.min(ttfbEstimate, ttfb), stats.loaded); 17212 } else { 17213 this.bwEstimator.sampleTTFB(timeLoading); 17214 } 17215 } 17216 break; 17217 } 17218 } 17219 } 17220 getTimeToLoadFrag(timeToFirstByteSec, bandwidth, fragSizeBits, isSwitch) { 17221 const fragLoadSec = timeToFirstByteSec + fragSizeBits / bandwidth; 17222 const playlistLoadSec = isSwitch ? this.lastLevelLoadSec : 0; 17223 return fragLoadSec + playlistLoadSec; 17224 } 17225 onLevelLoaded(event, data) { 17226 const config = this.hls.config; 17227 const { 17228 loading 17229 } = data.stats; 17230 const timeLoadingMs = loading.end - loading.start; 17231 if (isFiniteNumber(timeLoadingMs)) { 17232 this.lastLevelLoadSec = timeLoadingMs / 1e3; 17233 } 17234 if (data.details.live) { 17235 this.bwEstimator.update(config.abrEwmaSlowLive, config.abrEwmaFastLive); 17236 } else { 17237 this.bwEstimator.update(config.abrEwmaSlowVoD, config.abrEwmaFastVoD); 17238 } 17239 } 17240 onFragLoaded(event, { 17241 frag, 17242 part 17243 }) { 17244 const stats = part ? part.stats : frag.stats; 17245 if (frag.type === PlaylistLevelType.MAIN) { 17246 this.bwEstimator.sampleTTFB(stats.loading.first - stats.loading.start); 17247 } 17248 if (this.ignoreFragment(frag)) { 17249 return; 17250 } 17251 this.clearTimer(); 17252 if (frag.level === this._nextAutoLevel) { 17253 this._nextAutoLevel = -1; 17254 } 17255 this.firstSelection = -1; 17256 if (this.hls.config.abrMaxWithRealBitrate) { 17257 const duration = part ? part.duration : frag.duration; 17258 const level = this.hls.levels[frag.level]; 17259 const loadedBytes = (level.loaded ? level.loaded.bytes : 0) + stats.loaded; 17260 const loadedDuration = (level.loaded ? level.loaded.duration : 0) + duration; 17261 level.loaded = { 17262 bytes: loadedBytes, 17263 duration: loadedDuration 17264 }; 17265 level.realBitrate = Math.round(8 * loadedBytes / loadedDuration); 17266 } 17267 if (frag.bitrateTest) { 17268 const fragBufferedData = { 17269 stats, 17270 frag, 17271 part, 17272 id: frag.type 17273 }; 17274 this.onFragBuffered(Events.FRAG_BUFFERED, fragBufferedData); 17275 frag.bitrateTest = false; 17276 } else { 17277 this.lastLoadedFragLevel = frag.level; 17278 } 17279 } 17280 onFragBuffered(event, data) { 17281 const { 17282 frag, 17283 part 17284 } = data; 17285 const stats = part != null && part.stats.loaded ? part.stats : frag.stats; 17286 if (stats.aborted) { 17287 return; 17288 } 17289 if (this.ignoreFragment(frag)) { 17290 return; 17291 } 17292 const processingMs = stats.parsing.end - stats.loading.start - Math.min(stats.loading.first - stats.loading.start, this.bwEstimator.getEstimateTTFB()); 17293 this.bwEstimator.sample(processingMs, stats.loaded); 17294 stats.bwEstimate = this.getBwEstimate(); 17295 if (frag.bitrateTest) { 17296 this.bitrateTestDelay = processingMs / 1e3; 17297 } else { 17298 this.bitrateTestDelay = 0; 17299 } 17300 } 17301 ignoreFragment(frag) { 17302 return frag.type !== PlaylistLevelType.MAIN || frag.sn === "initSegment"; 17303 } 17304 clearTimer() { 17305 if (this.timer > -1) { 17306 self.clearInterval(this.timer); 17307 this.timer = -1; 17308 } 17309 } 17310 get firstAutoLevel() { 17311 const { 17312 maxAutoLevel, 17313 minAutoLevel 17314 } = this.hls; 17315 const bwEstimate = this.getBwEstimate(); 17316 const maxStartDelay = this.hls.config.maxStarvationDelay; 17317 const abrAutoLevel = this.findBestLevel(bwEstimate, minAutoLevel, maxAutoLevel, 0, maxStartDelay, 1, 1); 17318 if (abrAutoLevel > -1) { 17319 return abrAutoLevel; 17320 } 17321 const firstLevel = this.hls.firstLevel; 17322 const clamped = Math.min(Math.max(firstLevel, minAutoLevel), maxAutoLevel); 17323 logger.warn(`[abr] Could not find best starting auto level. Defaulting to first in playlist ${firstLevel} clamped to ${clamped}`); 17324 return clamped; 17325 } 17326 get forcedAutoLevel() { 17327 if (this.nextAutoLevelKey) { 17328 return -1; 17329 } 17330 return this._nextAutoLevel; 17331 } 17332 // return next auto level 17333 get nextAutoLevel() { 17334 const forcedAutoLevel = this.forcedAutoLevel; 17335 const bwEstimator = this.bwEstimator; 17336 const useEstimate = bwEstimator.canEstimate(); 17337 const loadedFirstFrag = this.lastLoadedFragLevel > -1; 17338 if (forcedAutoLevel !== -1 && (!useEstimate || !loadedFirstFrag || this.nextAutoLevelKey === this.getAutoLevelKey())) { 17339 return forcedAutoLevel; 17340 } 17341 const nextABRAutoLevel = useEstimate && loadedFirstFrag ? this.getNextABRAutoLevel() : this.firstAutoLevel; 17342 if (forcedAutoLevel !== -1) { 17343 const levels = this.hls.levels; 17344 if (levels.length > Math.max(forcedAutoLevel, nextABRAutoLevel) && levels[forcedAutoLevel].loadError <= levels[nextABRAutoLevel].loadError) { 17345 return forcedAutoLevel; 17346 } 17347 } 17348 this._nextAutoLevel = nextABRAutoLevel; 17349 this.nextAutoLevelKey = this.getAutoLevelKey(); 17350 return nextABRAutoLevel; 17351 } 17352 getAutoLevelKey() { 17353 return `${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`; 17354 } 17355 getNextABRAutoLevel() { 17356 const { 17357 fragCurrent, 17358 partCurrent, 17359 hls 17360 } = this; 17361 const { 17362 maxAutoLevel, 17363 config, 17364 minAutoLevel 17365 } = hls; 17366 const currentFragDuration = partCurrent ? partCurrent.duration : fragCurrent ? fragCurrent.duration : 0; 17367 const avgbw = this.getBwEstimate(); 17368 const bufferStarvationDelay = this.getStarvationDelay(); 17369 let bwFactor = config.abrBandWidthFactor; 17370 let bwUpFactor = config.abrBandWidthUpFactor; 17371 if (bufferStarvationDelay) { 17372 const _bestLevel = this.findBestLevel(avgbw, minAutoLevel, maxAutoLevel, bufferStarvationDelay, 0, bwFactor, bwUpFactor); 17373 if (_bestLevel >= 0) { 17374 return _bestLevel; 17375 } 17376 } 17377 let maxStarvationDelay = currentFragDuration ? Math.min(currentFragDuration, config.maxStarvationDelay) : config.maxStarvationDelay; 17378 if (!bufferStarvationDelay) { 17379 const bitrateTestDelay = this.bitrateTestDelay; 17380 if (bitrateTestDelay) { 17381 const maxLoadingDelay = currentFragDuration ? Math.min(currentFragDuration, config.maxLoadingDelay) : config.maxLoadingDelay; 17382 maxStarvationDelay = maxLoadingDelay - bitrateTestDelay; 17383 logger.info(`[abr] bitrate test took ${Math.round(1e3 * bitrateTestDelay)}ms, set first fragment max fetchDuration to ${Math.round(1e3 * maxStarvationDelay)} ms`); 17384 bwFactor = bwUpFactor = 1; 17385 } 17386 } 17387 const bestLevel = this.findBestLevel(avgbw, minAutoLevel, maxAutoLevel, bufferStarvationDelay, maxStarvationDelay, bwFactor, bwUpFactor); 17388 logger.info(`[abr] ${bufferStarvationDelay ? "rebuffering expected" : "buffer is empty"}, optimal quality level ${bestLevel}`); 17389 if (bestLevel > -1) { 17390 return bestLevel; 17391 } 17392 const minLevel = hls.levels[minAutoLevel]; 17393 const autoLevel = hls.levels[hls.loadLevel]; 17394 if ((minLevel == null ? void 0 : minLevel.bitrate) < (autoLevel == null ? void 0 : autoLevel.bitrate)) { 17395 return minAutoLevel; 17396 } 17397 return hls.loadLevel; 17398 } 17399 getStarvationDelay() { 17400 const hls = this.hls; 17401 const media = hls.media; 17402 if (!media) { 17403 return Infinity; 17404 } 17405 const playbackRate = media && media.playbackRate !== 0 ? Math.abs(media.playbackRate) : 1; 17406 const bufferInfo = hls.mainForwardBufferInfo; 17407 return (bufferInfo ? bufferInfo.len : 0) / playbackRate; 17408 } 17409 getBwEstimate() { 17410 return this.bwEstimator.canEstimate() ? this.bwEstimator.getEstimate() : this.hls.config.abrEwmaDefaultEstimate; 17411 } 17412 findBestLevel(currentBw, minAutoLevel, maxAutoLevel, bufferStarvationDelay, maxStarvationDelay, bwFactor, bwUpFactor) { 17413 var _level$details; 17414 const maxFetchDuration = bufferStarvationDelay + maxStarvationDelay; 17415 const lastLoadedFragLevel = this.lastLoadedFragLevel; 17416 const selectionBaseLevel = lastLoadedFragLevel === -1 ? this.hls.firstLevel : lastLoadedFragLevel; 17417 const { 17418 fragCurrent, 17419 partCurrent 17420 } = this; 17421 const { 17422 levels, 17423 allAudioTracks, 17424 loadLevel, 17425 config 17426 } = this.hls; 17427 if (levels.length === 1) { 17428 return 0; 17429 } 17430 const level = levels[selectionBaseLevel]; 17431 const live = !!(level != null && (_level$details = level.details) != null && _level$details.live); 17432 const firstSelection = loadLevel === -1 || lastLoadedFragLevel === -1; 17433 let currentCodecSet; 17434 let currentVideoRange = "SDR"; 17435 let currentFrameRate = (level == null ? void 0 : level.frameRate) || 0; 17436 const { 17437 audioPreference, 17438 videoPreference 17439 } = config; 17440 const audioTracksByGroup = this.audioTracksByGroup || (this.audioTracksByGroup = getAudioTracksByGroup(allAudioTracks)); 17441 if (firstSelection) { 17442 if (this.firstSelection !== -1) { 17443 return this.firstSelection; 17444 } 17445 const codecTiers = this.codecTiers || (this.codecTiers = getCodecTiers(levels, audioTracksByGroup, minAutoLevel, maxAutoLevel)); 17446 const startTier = getStartCodecTier(codecTiers, currentVideoRange, currentBw, audioPreference, videoPreference); 17447 const { 17448 codecSet, 17449 videoRanges, 17450 minFramerate, 17451 minBitrate, 17452 preferHDR 17453 } = startTier; 17454 currentCodecSet = codecSet; 17455 currentVideoRange = preferHDR ? videoRanges[videoRanges.length - 1] : videoRanges[0]; 17456 currentFrameRate = minFramerate; 17457 currentBw = Math.max(currentBw, minBitrate); 17458 logger.log(`[abr] picked start tier ${JSON.stringify(startTier)}`); 17459 } else { 17460 currentCodecSet = level == null ? void 0 : level.codecSet; 17461 currentVideoRange = level == null ? void 0 : level.videoRange; 17462 } 17463 const currentFragDuration = partCurrent ? partCurrent.duration : fragCurrent ? fragCurrent.duration : 0; 17464 const ttfbEstimateSec = this.bwEstimator.getEstimateTTFB() / 1e3; 17465 const levelsSkipped = []; 17466 for (let i3 = maxAutoLevel; i3 >= minAutoLevel; i3--) { 17467 var _levelInfo$supportedR; 17468 const levelInfo = levels[i3]; 17469 const upSwitch = i3 > selectionBaseLevel; 17470 if (!levelInfo) { 17471 continue; 17472 } 17473 if (config.useMediaCapabilities && !levelInfo.supportedResult && !levelInfo.supportedPromise) { 17474 const mediaCapabilities = navigator.mediaCapabilities; 17475 if (typeof (mediaCapabilities == null ? void 0 : mediaCapabilities.decodingInfo) === "function" && requiresMediaCapabilitiesDecodingInfo(levelInfo, audioTracksByGroup, currentVideoRange, currentFrameRate, currentBw, audioPreference)) { 17476 levelInfo.supportedPromise = getMediaDecodingInfoPromise(levelInfo, audioTracksByGroup, mediaCapabilities); 17477 levelInfo.supportedPromise.then((decodingInfo) => { 17478 if (!this.hls) { 17479 return; 17480 } 17481 levelInfo.supportedResult = decodingInfo; 17482 const levels2 = this.hls.levels; 17483 const index2 = levels2.indexOf(levelInfo); 17484 if (decodingInfo.error) { 17485 logger.warn(`[abr] MediaCapabilities decodingInfo error: "${decodingInfo.error}" for level ${index2} ${JSON.stringify(decodingInfo)}`); 17486 } else if (!decodingInfo.supported) { 17487 logger.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${index2} ${JSON.stringify(decodingInfo)}`); 17488 if (index2 > -1 && levels2.length > 1) { 17489 logger.log(`[abr] Removing unsupported level ${index2}`); 17490 this.hls.removeLevel(index2); 17491 } 17492 } 17493 }); 17494 } else { 17495 levelInfo.supportedResult = SUPPORTED_INFO_DEFAULT; 17496 } 17497 } 17498 if (currentCodecSet && levelInfo.codecSet !== currentCodecSet || currentVideoRange && levelInfo.videoRange !== currentVideoRange || upSwitch && currentFrameRate > levelInfo.frameRate || !upSwitch && currentFrameRate > 0 && currentFrameRate < levelInfo.frameRate || levelInfo.supportedResult && !((_levelInfo$supportedR = levelInfo.supportedResult.decodingInfoResults) != null && _levelInfo$supportedR[0].smooth)) { 17499 levelsSkipped.push(i3); 17500 continue; 17501 } 17502 const levelDetails = levelInfo.details; 17503 const avgDuration = (partCurrent ? levelDetails == null ? void 0 : levelDetails.partTarget : levelDetails == null ? void 0 : levelDetails.averagetargetduration) || currentFragDuration; 17504 let adjustedbw; 17505 if (!upSwitch) { 17506 adjustedbw = bwFactor * currentBw; 17507 } else { 17508 adjustedbw = bwUpFactor * currentBw; 17509 } 17510 const bitrate = currentFragDuration && bufferStarvationDelay >= currentFragDuration * 2 && maxStarvationDelay === 0 ? levels[i3].averageBitrate : levels[i3].maxBitrate; 17511 const fetchDuration = this.getTimeToLoadFrag(ttfbEstimateSec, adjustedbw, bitrate * avgDuration, levelDetails === void 0); 17512 const canSwitchWithinTolerance = ( 17513 // if adjusted bw is greater than level bitrate AND 17514 adjustedbw >= bitrate && // no level change, or new level has no error history 17515 (i3 === lastLoadedFragLevel || levelInfo.loadError === 0 && levelInfo.fragmentError === 0) && // fragment fetchDuration unknown OR live stream OR fragment fetchDuration less than max allowed fetch duration, then this level matches 17516 // we don't account for max Fetch Duration for live streams, this is to avoid switching down when near the edge of live sliding window ... 17517 // special case to support startLevel = -1 (bitrateTest) on live streams : in that case we should not exit loop so that findBestLevel will return -1 17518 (fetchDuration <= ttfbEstimateSec || !isFiniteNumber(fetchDuration) || live && !this.bitrateTestDelay || fetchDuration < maxFetchDuration) 17519 ); 17520 if (canSwitchWithinTolerance) { 17521 const forcedAutoLevel = this.forcedAutoLevel; 17522 if (i3 !== loadLevel && (forcedAutoLevel === -1 || forcedAutoLevel !== loadLevel)) { 17523 if (levelsSkipped.length) { 17524 logger.trace(`[abr] Skipped level(s) ${levelsSkipped.join(",")} of ${maxAutoLevel} max with CODECS and VIDEO-RANGE:"${levels[levelsSkipped[0]].codecs}" ${levels[levelsSkipped[0]].videoRange}; not compatible with "${level.codecs}" ${currentVideoRange}`); 17525 } 17526 logger.info(`[abr] switch candidate:${selectionBaseLevel}->${i3} adjustedbw(${Math.round(adjustedbw)})-bitrate=${Math.round(adjustedbw - bitrate)} ttfb:${ttfbEstimateSec.toFixed(1)} avgDuration:${avgDuration.toFixed(1)} maxFetchDuration:${maxFetchDuration.toFixed(1)} fetchDuration:${fetchDuration.toFixed(1)} firstSelection:${firstSelection} codecSet:${currentCodecSet} videoRange:${currentVideoRange} hls.loadLevel:${loadLevel}`); 17527 } 17528 if (firstSelection) { 17529 this.firstSelection = i3; 17530 } 17531 return i3; 17532 } 17533 } 17534 return -1; 17535 } 17536 set nextAutoLevel(nextLevel) { 17537 const { 17538 maxAutoLevel, 17539 minAutoLevel 17540 } = this.hls; 17541 const value = Math.min(Math.max(nextLevel, minAutoLevel), maxAutoLevel); 17542 if (this._nextAutoLevel !== value) { 17543 this.nextAutoLevelKey = ""; 17544 this._nextAutoLevel = value; 17545 } 17546 } 17547}; 17548var TaskLoop = class { 17549 constructor() { 17550 this._boundTick = void 0; 17551 this._tickTimer = null; 17552 this._tickInterval = null; 17553 this._tickCallCount = 0; 17554 this._boundTick = this.tick.bind(this); 17555 } 17556 destroy() { 17557 this.onHandlerDestroying(); 17558 this.onHandlerDestroyed(); 17559 } 17560 onHandlerDestroying() { 17561 this.clearNextTick(); 17562 this.clearInterval(); 17563 } 17564 onHandlerDestroyed() { 17565 } 17566 hasInterval() { 17567 return !!this._tickInterval; 17568 } 17569 hasNextTick() { 17570 return !!this._tickTimer; 17571 } 17572 /** 17573 * @param millis - Interval time (ms) 17574 * @eturns True when interval has been scheduled, false when already scheduled (no effect) 17575 */ 17576 setInterval(millis) { 17577 if (!this._tickInterval) { 17578 this._tickCallCount = 0; 17579 this._tickInterval = self.setInterval(this._boundTick, millis); 17580 return true; 17581 } 17582 return false; 17583 } 17584 /** 17585 * @returns True when interval was cleared, false when none was set (no effect) 17586 */ 17587 clearInterval() { 17588 if (this._tickInterval) { 17589 self.clearInterval(this._tickInterval); 17590 this._tickInterval = null; 17591 return true; 17592 } 17593 return false; 17594 } 17595 /** 17596 * @returns True when timeout was cleared, false when none was set (no effect) 17597 */ 17598 clearNextTick() { 17599 if (this._tickTimer) { 17600 self.clearTimeout(this._tickTimer); 17601 this._tickTimer = null; 17602 return true; 17603 } 17604 return false; 17605 } 17606 /** 17607 * Will call the subclass doTick implementation in this main loop tick 17608 * or in the next one (via setTimeout(,0)) in case it has already been called 17609 * in this tick (in case this is a re-entrant call). 17610 */ 17611 tick() { 17612 this._tickCallCount++; 17613 if (this._tickCallCount === 1) { 17614 this.doTick(); 17615 if (this._tickCallCount > 1) { 17616 this.tickImmediate(); 17617 } 17618 this._tickCallCount = 0; 17619 } 17620 } 17621 tickImmediate() { 17622 this.clearNextTick(); 17623 this._tickTimer = self.setTimeout(this._boundTick, 0); 17624 } 17625 /** 17626 * For subclass to implement task logic 17627 * @abstract 17628 */ 17629 doTick() { 17630 } 17631}; 17632var FragmentState = { 17633 NOT_LOADED: "NOT_LOADED", 17634 APPENDING: "APPENDING", 17635 PARTIAL: "PARTIAL", 17636 OK: "OK" 17637}; 17638var FragmentTracker = class { 17639 constructor(hls) { 17640 this.activePartLists = /* @__PURE__ */ Object.create(null); 17641 this.endListFragments = /* @__PURE__ */ Object.create(null); 17642 this.fragments = /* @__PURE__ */ Object.create(null); 17643 this.timeRanges = /* @__PURE__ */ Object.create(null); 17644 this.bufferPadding = 0.2; 17645 this.hls = void 0; 17646 this.hasGaps = false; 17647 this.hls = hls; 17648 this._registerListeners(); 17649 } 17650 _registerListeners() { 17651 const { 17652 hls 17653 } = this; 17654 hls.on(Events.BUFFER_APPENDED, this.onBufferAppended, this); 17655 hls.on(Events.FRAG_BUFFERED, this.onFragBuffered, this); 17656 hls.on(Events.FRAG_LOADED, this.onFragLoaded, this); 17657 } 17658 _unregisterListeners() { 17659 const { 17660 hls 17661 } = this; 17662 hls.off(Events.BUFFER_APPENDED, this.onBufferAppended, this); 17663 hls.off(Events.FRAG_BUFFERED, this.onFragBuffered, this); 17664 hls.off(Events.FRAG_LOADED, this.onFragLoaded, this); 17665 } 17666 destroy() { 17667 this._unregisterListeners(); 17668 this.fragments = // @ts-ignore 17669 this.activePartLists = // @ts-ignore 17670 this.endListFragments = this.timeRanges = null; 17671 } 17672 /** 17673 * Return a Fragment or Part with an appended range that matches the position and levelType 17674 * Otherwise, return null 17675 */ 17676 getAppendedFrag(position2, levelType) { 17677 const activeParts = this.activePartLists[levelType]; 17678 if (activeParts) { 17679 for (let i3 = activeParts.length; i3--; ) { 17680 const activePart = activeParts[i3]; 17681 if (!activePart) { 17682 break; 17683 } 17684 const appendedPTS = activePart.end; 17685 if (activePart.start <= position2 && appendedPTS !== null && position2 <= appendedPTS) { 17686 return activePart; 17687 } 17688 } 17689 } 17690 return this.getBufferedFrag(position2, levelType); 17691 } 17692 /** 17693 * Return a buffered Fragment that matches the position and levelType. 17694 * A buffered Fragment is one whose loading, parsing and appending is done (completed or "partial" meaning aborted). 17695 * If not found any Fragment, return null 17696 */ 17697 getBufferedFrag(position2, levelType) { 17698 const { 17699 fragments 17700 } = this; 17701 const keys = Object.keys(fragments); 17702 for (let i3 = keys.length; i3--; ) { 17703 const fragmentEntity = fragments[keys[i3]]; 17704 if ((fragmentEntity == null ? void 0 : fragmentEntity.body.type) === levelType && fragmentEntity.buffered) { 17705 const frag = fragmentEntity.body; 17706 if (frag.start <= position2 && position2 <= frag.end) { 17707 return frag; 17708 } 17709 } 17710 } 17711 return null; 17712 } 17713 /** 17714 * Partial fragments effected by coded frame eviction will be removed 17715 * The browser will unload parts of the buffer to free up memory for new buffer data 17716 * Fragments will need to be reloaded when the buffer is freed up, removing partial fragments will allow them to reload(since there might be parts that are still playable) 17717 */ 17718 detectEvictedFragments(elementaryStream, timeRange, playlistType, appendedPart) { 17719 if (this.timeRanges) { 17720 this.timeRanges[elementaryStream] = timeRange; 17721 } 17722 const appendedPartSn = (appendedPart == null ? void 0 : appendedPart.fragment.sn) || -1; 17723 Object.keys(this.fragments).forEach((key) => { 17724 const fragmentEntity = this.fragments[key]; 17725 if (!fragmentEntity) { 17726 return; 17727 } 17728 if (appendedPartSn >= fragmentEntity.body.sn) { 17729 return; 17730 } 17731 if (!fragmentEntity.buffered && !fragmentEntity.loaded) { 17732 if (fragmentEntity.body.type === playlistType) { 17733 this.removeFragment(fragmentEntity.body); 17734 } 17735 return; 17736 } 17737 const esData = fragmentEntity.range[elementaryStream]; 17738 if (!esData) { 17739 return; 17740 } 17741 esData.time.some((time) => { 17742 const isNotBuffered = !this.isTimeBuffered(time.startPTS, time.endPTS, timeRange); 17743 if (isNotBuffered) { 17744 this.removeFragment(fragmentEntity.body); 17745 } 17746 return isNotBuffered; 17747 }); 17748 }); 17749 } 17750 /** 17751 * Checks if the fragment passed in is loaded in the buffer properly 17752 * Partially loaded fragments will be registered as a partial fragment 17753 */ 17754 detectPartialFragments(data) { 17755 const timeRanges = this.timeRanges; 17756 const { 17757 frag, 17758 part 17759 } = data; 17760 if (!timeRanges || frag.sn === "initSegment") { 17761 return; 17762 } 17763 const fragKey = getFragmentKey(frag); 17764 const fragmentEntity = this.fragments[fragKey]; 17765 if (!fragmentEntity || fragmentEntity.buffered && frag.gap) { 17766 return; 17767 } 17768 const isFragHint = !frag.relurl; 17769 Object.keys(timeRanges).forEach((elementaryStream) => { 17770 const streamInfo = frag.elementaryStreams[elementaryStream]; 17771 if (!streamInfo) { 17772 return; 17773 } 17774 const timeRange = timeRanges[elementaryStream]; 17775 const partial = isFragHint || streamInfo.partial === true; 17776 fragmentEntity.range[elementaryStream] = this.getBufferedTimes(frag, part, partial, timeRange); 17777 }); 17778 fragmentEntity.loaded = null; 17779 if (Object.keys(fragmentEntity.range).length) { 17780 fragmentEntity.buffered = true; 17781 const endList = fragmentEntity.body.endList = frag.endList || fragmentEntity.body.endList; 17782 if (endList) { 17783 this.endListFragments[fragmentEntity.body.type] = fragmentEntity; 17784 } 17785 if (!isPartial(fragmentEntity)) { 17786 this.removeParts(frag.sn - 1, frag.type); 17787 } 17788 } else { 17789 this.removeFragment(fragmentEntity.body); 17790 } 17791 } 17792 removeParts(snToKeep, levelType) { 17793 const activeParts = this.activePartLists[levelType]; 17794 if (!activeParts) { 17795 return; 17796 } 17797 this.activePartLists[levelType] = activeParts.filter((part) => part.fragment.sn >= snToKeep); 17798 } 17799 fragBuffered(frag, force) { 17800 const fragKey = getFragmentKey(frag); 17801 let fragmentEntity = this.fragments[fragKey]; 17802 if (!fragmentEntity && force) { 17803 fragmentEntity = this.fragments[fragKey] = { 17804 body: frag, 17805 appendedPTS: null, 17806 loaded: null, 17807 buffered: false, 17808 range: /* @__PURE__ */ Object.create(null) 17809 }; 17810 if (frag.gap) { 17811 this.hasGaps = true; 17812 } 17813 } 17814 if (fragmentEntity) { 17815 fragmentEntity.loaded = null; 17816 fragmentEntity.buffered = true; 17817 } 17818 } 17819 getBufferedTimes(fragment, part, partial, timeRange) { 17820 const buffered = { 17821 time: [], 17822 partial 17823 }; 17824 const startPTS = fragment.start; 17825 const endPTS = fragment.end; 17826 const minEndPTS = fragment.minEndPTS || endPTS; 17827 const maxStartPTS = fragment.maxStartPTS || startPTS; 17828 for (let i3 = 0; i3 < timeRange.length; i3++) { 17829 const startTime = timeRange.start(i3) - this.bufferPadding; 17830 const endTime = timeRange.end(i3) + this.bufferPadding; 17831 if (maxStartPTS >= startTime && minEndPTS <= endTime) { 17832 buffered.time.push({ 17833 startPTS: Math.max(startPTS, timeRange.start(i3)), 17834 endPTS: Math.min(endPTS, timeRange.end(i3)) 17835 }); 17836 break; 17837 } else if (startPTS < endTime && endPTS > startTime) { 17838 const start = Math.max(startPTS, timeRange.start(i3)); 17839 const end = Math.min(endPTS, timeRange.end(i3)); 17840 if (end > start) { 17841 buffered.partial = true; 17842 buffered.time.push({ 17843 startPTS: start, 17844 endPTS: end 17845 }); 17846 } 17847 } else if (endPTS <= startTime) { 17848 break; 17849 } 17850 } 17851 return buffered; 17852 } 17853 /** 17854 * Gets the partial fragment for a certain time 17855 */ 17856 getPartialFragment(time) { 17857 let bestFragment = null; 17858 let timePadding; 17859 let startTime; 17860 let endTime; 17861 let bestOverlap = 0; 17862 const { 17863 bufferPadding, 17864 fragments 17865 } = this; 17866 Object.keys(fragments).forEach((key) => { 17867 const fragmentEntity = fragments[key]; 17868 if (!fragmentEntity) { 17869 return; 17870 } 17871 if (isPartial(fragmentEntity)) { 17872 startTime = fragmentEntity.body.start - bufferPadding; 17873 endTime = fragmentEntity.body.end + bufferPadding; 17874 if (time >= startTime && time <= endTime) { 17875 timePadding = Math.min(time - startTime, endTime - time); 17876 if (bestOverlap <= timePadding) { 17877 bestFragment = fragmentEntity.body; 17878 bestOverlap = timePadding; 17879 } 17880 } 17881 } 17882 }); 17883 return bestFragment; 17884 } 17885 isEndListAppended(type) { 17886 const lastFragmentEntity = this.endListFragments[type]; 17887 return lastFragmentEntity !== void 0 && (lastFragmentEntity.buffered || isPartial(lastFragmentEntity)); 17888 } 17889 getState(fragment) { 17890 const fragKey = getFragmentKey(fragment); 17891 const fragmentEntity = this.fragments[fragKey]; 17892 if (fragmentEntity) { 17893 if (!fragmentEntity.buffered) { 17894 return FragmentState.APPENDING; 17895 } else if (isPartial(fragmentEntity)) { 17896 return FragmentState.PARTIAL; 17897 } else { 17898 return FragmentState.OK; 17899 } 17900 } 17901 return FragmentState.NOT_LOADED; 17902 } 17903 isTimeBuffered(startPTS, endPTS, timeRange) { 17904 let startTime; 17905 let endTime; 17906 for (let i3 = 0; i3 < timeRange.length; i3++) { 17907 startTime = timeRange.start(i3) - this.bufferPadding; 17908 endTime = timeRange.end(i3) + this.bufferPadding; 17909 if (startPTS >= startTime && endPTS <= endTime) { 17910 return true; 17911 } 17912 if (endPTS <= startTime) { 17913 return false; 17914 } 17915 } 17916 return false; 17917 } 17918 onFragLoaded(event, data) { 17919 const { 17920 frag, 17921 part 17922 } = data; 17923 if (frag.sn === "initSegment" || frag.bitrateTest) { 17924 return; 17925 } 17926 const loaded = part ? null : data; 17927 const fragKey = getFragmentKey(frag); 17928 this.fragments[fragKey] = { 17929 body: frag, 17930 appendedPTS: null, 17931 loaded, 17932 buffered: false, 17933 range: /* @__PURE__ */ Object.create(null) 17934 }; 17935 } 17936 onBufferAppended(event, data) { 17937 const { 17938 frag, 17939 part, 17940 timeRanges 17941 } = data; 17942 if (frag.sn === "initSegment") { 17943 return; 17944 } 17945 const playlistType = frag.type; 17946 if (part) { 17947 let activeParts = this.activePartLists[playlistType]; 17948 if (!activeParts) { 17949 this.activePartLists[playlistType] = activeParts = []; 17950 } 17951 activeParts.push(part); 17952 } 17953 this.timeRanges = timeRanges; 17954 Object.keys(timeRanges).forEach((elementaryStream) => { 17955 const timeRange = timeRanges[elementaryStream]; 17956 this.detectEvictedFragments(elementaryStream, timeRange, playlistType, part); 17957 }); 17958 } 17959 onFragBuffered(event, data) { 17960 this.detectPartialFragments(data); 17961 } 17962 hasFragment(fragment) { 17963 const fragKey = getFragmentKey(fragment); 17964 return !!this.fragments[fragKey]; 17965 } 17966 hasParts(type) { 17967 var _this$activePartLists; 17968 return !!((_this$activePartLists = this.activePartLists[type]) != null && _this$activePartLists.length); 17969 } 17970 removeFragmentsInRange(start, end, playlistType, withGapOnly, unbufferedOnly) { 17971 if (withGapOnly && !this.hasGaps) { 17972 return; 17973 } 17974 Object.keys(this.fragments).forEach((key) => { 17975 const fragmentEntity = this.fragments[key]; 17976 if (!fragmentEntity) { 17977 return; 17978 } 17979 const frag = fragmentEntity.body; 17980 if (frag.type !== playlistType || withGapOnly && !frag.gap) { 17981 return; 17982 } 17983 if (frag.start < end && frag.end > start && (fragmentEntity.buffered || unbufferedOnly)) { 17984 this.removeFragment(frag); 17985 } 17986 }); 17987 } 17988 removeFragment(fragment) { 17989 const fragKey = getFragmentKey(fragment); 17990 fragment.stats.loaded = 0; 17991 fragment.clearElementaryStreamInfo(); 17992 const activeParts = this.activePartLists[fragment.type]; 17993 if (activeParts) { 17994 const snToRemove = fragment.sn; 17995 this.activePartLists[fragment.type] = activeParts.filter((part) => part.fragment.sn !== snToRemove); 17996 } 17997 delete this.fragments[fragKey]; 17998 if (fragment.endList) { 17999 delete this.endListFragments[fragment.type]; 18000 } 18001 } 18002 removeAllFragments() { 18003 this.fragments = /* @__PURE__ */ Object.create(null); 18004 this.endListFragments = /* @__PURE__ */ Object.create(null); 18005 this.activePartLists = /* @__PURE__ */ Object.create(null); 18006 this.hasGaps = false; 18007 } 18008}; 18009function isPartial(fragmentEntity) { 18010 var _fragmentEntity$range, _fragmentEntity$range2, _fragmentEntity$range3; 18011 return fragmentEntity.buffered && (fragmentEntity.body.gap || ((_fragmentEntity$range = fragmentEntity.range.video) == null ? void 0 : _fragmentEntity$range.partial) || ((_fragmentEntity$range2 = fragmentEntity.range.audio) == null ? void 0 : _fragmentEntity$range2.partial) || ((_fragmentEntity$range3 = fragmentEntity.range.audiovideo) == null ? void 0 : _fragmentEntity$range3.partial)); 18012} 18013function getFragmentKey(fragment) { 18014 return `${fragment.type}_${fragment.level}_${fragment.sn}`; 18015} 18016var noopBuffered = { 18017 length: 0, 18018 start: () => 0, 18019 end: () => 0 18020}; 18021var BufferHelper = class _BufferHelper { 18022 /** 18023 * Return true if `media`'s buffered include `position` 18024 */ 18025 static isBuffered(media, position2) { 18026 try { 18027 if (media) { 18028 const buffered = _BufferHelper.getBuffered(media); 18029 for (let i3 = 0; i3 < buffered.length; i3++) { 18030 if (position2 >= buffered.start(i3) && position2 <= buffered.end(i3)) { 18031 return true; 18032 } 18033 } 18034 } 18035 } catch (error) { 18036 } 18037 return false; 18038 } 18039 static bufferInfo(media, pos, maxHoleDuration) { 18040 try { 18041 if (media) { 18042 const vbuffered = _BufferHelper.getBuffered(media); 18043 const buffered = []; 18044 let i3; 18045 for (i3 = 0; i3 < vbuffered.length; i3++) { 18046 buffered.push({ 18047 start: vbuffered.start(i3), 18048 end: vbuffered.end(i3) 18049 }); 18050 } 18051 return this.bufferedInfo(buffered, pos, maxHoleDuration); 18052 } 18053 } catch (error) { 18054 } 18055 return { 18056 len: 0, 18057 start: pos, 18058 end: pos, 18059 nextStart: void 0 18060 }; 18061 } 18062 static bufferedInfo(buffered, pos, maxHoleDuration) { 18063 pos = Math.max(0, pos); 18064 buffered.sort(function(a2, b3) { 18065 const diff = a2.start - b3.start; 18066 if (diff) { 18067 return diff; 18068 } else { 18069 return b3.end - a2.end; 18070 } 18071 }); 18072 let buffered2 = []; 18073 if (maxHoleDuration) { 18074 for (let i3 = 0; i3 < buffered.length; i3++) { 18075 const buf2len = buffered2.length; 18076 if (buf2len) { 18077 const buf2end = buffered2[buf2len - 1].end; 18078 if (buffered[i3].start - buf2end < maxHoleDuration) { 18079 if (buffered[i3].end > buf2end) { 18080 buffered2[buf2len - 1].end = buffered[i3].end; 18081 } 18082 } else { 18083 buffered2.push(buffered[i3]); 18084 } 18085 } else { 18086 buffered2.push(buffered[i3]); 18087 } 18088 } 18089 } else { 18090 buffered2 = buffered; 18091 } 18092 let bufferLen = 0; 18093 let bufferStartNext; 18094 let bufferStart = pos; 18095 let bufferEnd = pos; 18096 for (let i3 = 0; i3 < buffered2.length; i3++) { 18097 const start = buffered2[i3].start; 18098 const end = buffered2[i3].end; 18099 if (pos + maxHoleDuration >= start && pos < end) { 18100 bufferStart = start; 18101 bufferEnd = end; 18102 bufferLen = bufferEnd - pos; 18103 } else if (pos + maxHoleDuration < start) { 18104 bufferStartNext = start; 18105 break; 18106 } 18107 } 18108 return { 18109 len: bufferLen, 18110 start: bufferStart || 0, 18111 end: bufferEnd || 0, 18112 nextStart: bufferStartNext 18113 }; 18114 } 18115 /** 18116 * Safe method to get buffered property. 18117 * SourceBuffer.buffered may throw if SourceBuffer is removed from it's MediaSource 18118 */ 18119 static getBuffered(media) { 18120 try { 18121 return media.buffered; 18122 } catch (e) { 18123 logger.log("failed to get media.buffered", e); 18124 return noopBuffered; 18125 } 18126 } 18127}; 18128var ChunkMetadata = class { 18129 constructor(level, sn, id, size = 0, part = -1, partial = false) { 18130 this.level = void 0; 18131 this.sn = void 0; 18132 this.part = void 0; 18133 this.id = void 0; 18134 this.size = void 0; 18135 this.partial = void 0; 18136 this.transmuxing = getNewPerformanceTiming(); 18137 this.buffering = { 18138 audio: getNewPerformanceTiming(), 18139 video: getNewPerformanceTiming(), 18140 audiovideo: getNewPerformanceTiming() 18141 }; 18142 this.level = level; 18143 this.sn = sn; 18144 this.id = id; 18145 this.size = size; 18146 this.part = part; 18147 this.partial = partial; 18148 } 18149}; 18150function getNewPerformanceTiming() { 18151 return { 18152 start: 0, 18153 executeStart: 0, 18154 executeEnd: 0, 18155 end: 0 18156 }; 18157} 18158function findFirstFragWithCC(fragments, cc) { 18159 for (let i3 = 0, len = fragments.length; i3 < len; i3++) { 18160 var _fragments$i; 18161 if (((_fragments$i = fragments[i3]) == null ? void 0 : _fragments$i.cc) === cc) { 18162 return fragments[i3]; 18163 } 18164 } 18165 return null; 18166} 18167function shouldAlignOnDiscontinuities(lastFrag, switchDetails, details) { 18168 if (switchDetails) { 18169 if (details.endCC > details.startCC || lastFrag && lastFrag.cc < details.startCC) { 18170 return true; 18171 } 18172 } 18173 return false; 18174} 18175function findDiscontinuousReferenceFrag(prevDetails, curDetails) { 18176 const prevFrags = prevDetails.fragments; 18177 const curFrags = curDetails.fragments; 18178 if (!curFrags.length || !prevFrags.length) { 18179 logger.log("No fragments to align"); 18180 return; 18181 } 18182 const prevStartFrag = findFirstFragWithCC(prevFrags, curFrags[0].cc); 18183 if (!prevStartFrag || prevStartFrag && !prevStartFrag.startPTS) { 18184 logger.log("No frag in previous level to align on"); 18185 return; 18186 } 18187 return prevStartFrag; 18188} 18189function adjustFragmentStart(frag, sliding) { 18190 if (frag) { 18191 const start = frag.start + sliding; 18192 frag.start = frag.startPTS = start; 18193 frag.endPTS = start + frag.duration; 18194 } 18195} 18196function adjustSlidingStart(sliding, details) { 18197 const fragments = details.fragments; 18198 for (let i3 = 0, len = fragments.length; i3 < len; i3++) { 18199 adjustFragmentStart(fragments[i3], sliding); 18200 } 18201 if (details.fragmentHint) { 18202 adjustFragmentStart(details.fragmentHint, sliding); 18203 } 18204 details.alignedSliding = true; 18205} 18206function alignStream(lastFrag, switchDetails, details) { 18207 if (!switchDetails) { 18208 return; 18209 } 18210 alignDiscontinuities(lastFrag, details, switchDetails); 18211 if (!details.alignedSliding && switchDetails) { 18212 alignMediaPlaylistByPDT(details, switchDetails); 18213 } 18214 if (!details.alignedSliding && switchDetails && !details.skippedSegments) { 18215 adjustSliding(switchDetails, details); 18216 } 18217} 18218function alignDiscontinuities(lastFrag, details, switchDetails) { 18219 if (shouldAlignOnDiscontinuities(lastFrag, switchDetails, details)) { 18220 const referenceFrag = findDiscontinuousReferenceFrag(switchDetails, details); 18221 if (referenceFrag && isFiniteNumber(referenceFrag.start)) { 18222 logger.log(`Adjusting PTS using last level due to CC increase within current level ${details.url}`); 18223 adjustSlidingStart(referenceFrag.start, details); 18224 } 18225 } 18226} 18227function alignMediaPlaylistByPDT(details, refDetails) { 18228 if (!details.hasProgramDateTime || !refDetails.hasProgramDateTime) { 18229 return; 18230 } 18231 const fragments = details.fragments; 18232 const refFragments = refDetails.fragments; 18233 if (!fragments.length || !refFragments.length) { 18234 return; 18235 } 18236 let refFrag; 18237 let frag; 18238 const targetCC = Math.min(refDetails.endCC, details.endCC); 18239 if (refDetails.startCC < targetCC && details.startCC < targetCC) { 18240 refFrag = findFirstFragWithCC(refFragments, targetCC); 18241 frag = findFirstFragWithCC(fragments, targetCC); 18242 } 18243 if (!refFrag || !frag) { 18244 refFrag = refFragments[Math.floor(refFragments.length / 2)]; 18245 frag = findFirstFragWithCC(fragments, refFrag.cc) || fragments[Math.floor(fragments.length / 2)]; 18246 } 18247 const refPDT = refFrag.programDateTime; 18248 const targetPDT = frag.programDateTime; 18249 if (!refPDT || !targetPDT) { 18250 return; 18251 } 18252 const delta = (targetPDT - refPDT) / 1e3 - (frag.start - refFrag.start); 18253 adjustSlidingStart(delta, details); 18254} 18255var MIN_CHUNK_SIZE = Math.pow(2, 17); 18256var FragmentLoader = class { 18257 constructor(config) { 18258 this.config = void 0; 18259 this.loader = null; 18260 this.partLoadTimeout = -1; 18261 this.config = config; 18262 } 18263 destroy() { 18264 if (this.loader) { 18265 this.loader.destroy(); 18266 this.loader = null; 18267 } 18268 } 18269 abort() { 18270 if (this.loader) { 18271 this.loader.abort(); 18272 } 18273 } 18274 load(frag, onProgress) { 18275 const url = frag.url; 18276 if (!url) { 18277 return Promise.reject(new LoadError({ 18278 type: ErrorTypes.NETWORK_ERROR, 18279 details: ErrorDetails.FRAG_LOAD_ERROR, 18280 fatal: false, 18281 frag, 18282 error: new Error(`Fragment does not have a ${url ? "part list" : "url"}`), 18283 networkDetails: null 18284 })); 18285 } 18286 this.abort(); 18287 const config = this.config; 18288 const FragmentILoader = config.fLoader; 18289 const DefaultILoader = config.loader; 18290 return new Promise((resolve, reject) => { 18291 if (this.loader) { 18292 this.loader.destroy(); 18293 } 18294 if (frag.gap) { 18295 if (frag.tagList.some((tags) => tags[0] === "GAP")) { 18296 reject(createGapLoadError(frag)); 18297 return; 18298 } else { 18299 frag.gap = false; 18300 } 18301 } 18302 const loader = this.loader = frag.loader = FragmentILoader ? new FragmentILoader(config) : new DefaultILoader(config); 18303 const loaderContext = createLoaderContext(frag); 18304 const loadPolicy = getLoaderConfigWithoutReties(config.fragLoadPolicy.default); 18305 const loaderConfig = { 18306 loadPolicy, 18307 timeout: loadPolicy.maxLoadTimeMs, 18308 maxRetry: 0, 18309 retryDelay: 0, 18310 maxRetryDelay: 0, 18311 highWaterMark: frag.sn === "initSegment" ? Infinity : MIN_CHUNK_SIZE 18312 }; 18313 frag.stats = loader.stats; 18314 loader.load(loaderContext, loaderConfig, { 18315 onSuccess: (response, stats, context, networkDetails) => { 18316 this.resetLoader(frag, loader); 18317 let payload = response.data; 18318 if (context.resetIV && frag.decryptdata) { 18319 frag.decryptdata.iv = new Uint8Array(payload.slice(0, 16)); 18320 payload = payload.slice(16); 18321 } 18322 resolve({ 18323 frag, 18324 part: null, 18325 payload, 18326 networkDetails 18327 }); 18328 }, 18329 onError: (response, context, networkDetails, stats) => { 18330 this.resetLoader(frag, loader); 18331 reject(new LoadError({ 18332 type: ErrorTypes.NETWORK_ERROR, 18333 details: ErrorDetails.FRAG_LOAD_ERROR, 18334 fatal: false, 18335 frag, 18336 response: _objectSpread23({ 18337 url, 18338 data: void 0 18339 }, response), 18340 error: new Error(`HTTP Error ${response.code} ${response.text}`), 18341 networkDetails, 18342 stats 18343 })); 18344 }, 18345 onAbort: (stats, context, networkDetails) => { 18346 this.resetLoader(frag, loader); 18347 reject(new LoadError({ 18348 type: ErrorTypes.NETWORK_ERROR, 18349 details: ErrorDetails.INTERNAL_ABORTED, 18350 fatal: false, 18351 frag, 18352 error: new Error("Aborted"), 18353 networkDetails, 18354 stats 18355 })); 18356 }, 18357 onTimeout: (stats, context, networkDetails) => { 18358 this.resetLoader(frag, loader); 18359 reject(new LoadError({ 18360 type: ErrorTypes.NETWORK_ERROR, 18361 details: ErrorDetails.FRAG_LOAD_TIMEOUT, 18362 fatal: false, 18363 frag, 18364 error: new Error(`Timeout after ${loaderConfig.timeout}ms`), 18365 networkDetails, 18366 stats 18367 })); 18368 }, 18369 onProgress: (stats, context, data, networkDetails) => { 18370 if (onProgress) { 18371 onProgress({ 18372 frag, 18373 part: null, 18374 payload: data, 18375 networkDetails 18376 }); 18377 } 18378 } 18379 }); 18380 }); 18381 } 18382 loadPart(frag, part, onProgress) { 18383 this.abort(); 18384 const config = this.config; 18385 const FragmentILoader = config.fLoader; 18386 const DefaultILoader = config.loader; 18387 return new Promise((resolve, reject) => { 18388 if (this.loader) { 18389 this.loader.destroy(); 18390 } 18391 if (frag.gap || part.gap) { 18392 reject(createGapLoadError(frag, part)); 18393 return; 18394 } 18395 const loader = this.loader = frag.loader = FragmentILoader ? new FragmentILoader(config) : new DefaultILoader(config); 18396 const loaderContext = createLoaderContext(frag, part); 18397 const loadPolicy = getLoaderConfigWithoutReties(config.fragLoadPolicy.default); 18398 const loaderConfig = { 18399 loadPolicy, 18400 timeout: loadPolicy.maxLoadTimeMs, 18401 maxRetry: 0, 18402 retryDelay: 0, 18403 maxRetryDelay: 0, 18404 highWaterMark: MIN_CHUNK_SIZE 18405 }; 18406 part.stats = loader.stats; 18407 loader.load(loaderContext, loaderConfig, { 18408 onSuccess: (response, stats, context, networkDetails) => { 18409 this.resetLoader(frag, loader); 18410 this.updateStatsFromPart(frag, part); 18411 const partLoadedData = { 18412 frag, 18413 part, 18414 payload: response.data, 18415 networkDetails 18416 }; 18417 onProgress(partLoadedData); 18418 resolve(partLoadedData); 18419 }, 18420 onError: (response, context, networkDetails, stats) => { 18421 this.resetLoader(frag, loader); 18422 reject(new LoadError({ 18423 type: ErrorTypes.NETWORK_ERROR, 18424 details: ErrorDetails.FRAG_LOAD_ERROR, 18425 fatal: false, 18426 frag, 18427 part, 18428 response: _objectSpread23({ 18429 url: loaderContext.url, 18430 data: void 0 18431 }, response), 18432 error: new Error(`HTTP Error ${response.code} ${response.text}`), 18433 networkDetails, 18434 stats 18435 })); 18436 }, 18437 onAbort: (stats, context, networkDetails) => { 18438 frag.stats.aborted = part.stats.aborted; 18439 this.resetLoader(frag, loader); 18440 reject(new LoadError({ 18441 type: ErrorTypes.NETWORK_ERROR, 18442 details: ErrorDetails.INTERNAL_ABORTED, 18443 fatal: false, 18444 frag, 18445 part, 18446 error: new Error("Aborted"), 18447 networkDetails, 18448 stats 18449 })); 18450 }, 18451 onTimeout: (stats, context, networkDetails) => { 18452 this.resetLoader(frag, loader); 18453 reject(new LoadError({ 18454 type: ErrorTypes.NETWORK_ERROR, 18455 details: ErrorDetails.FRAG_LOAD_TIMEOUT, 18456 fatal: false, 18457 frag, 18458 part, 18459 error: new Error(`Timeout after ${loaderConfig.timeout}ms`), 18460 networkDetails, 18461 stats 18462 })); 18463 } 18464 }); 18465 }); 18466 } 18467 updateStatsFromPart(frag, part) { 18468 const fragStats = frag.stats; 18469 const partStats = part.stats; 18470 const partTotal = partStats.total; 18471 fragStats.loaded += partStats.loaded; 18472 if (partTotal) { 18473 const estTotalParts = Math.round(frag.duration / part.duration); 18474 const estLoadedParts = Math.min(Math.round(fragStats.loaded / partTotal), estTotalParts); 18475 const estRemainingParts = estTotalParts - estLoadedParts; 18476 const estRemainingBytes = estRemainingParts * Math.round(fragStats.loaded / estLoadedParts); 18477 fragStats.total = fragStats.loaded + estRemainingBytes; 18478 } else { 18479 fragStats.total = Math.max(fragStats.loaded, fragStats.total); 18480 } 18481 const fragLoading = fragStats.loading; 18482 const partLoading = partStats.loading; 18483 if (fragLoading.start) { 18484 fragLoading.first += partLoading.first - partLoading.start; 18485 } else { 18486 fragLoading.start = partLoading.start; 18487 fragLoading.first = partLoading.first; 18488 } 18489 fragLoading.end = partLoading.end; 18490 } 18491 resetLoader(frag, loader) { 18492 frag.loader = null; 18493 if (this.loader === loader) { 18494 self.clearTimeout(this.partLoadTimeout); 18495 this.loader = null; 18496 } 18497 loader.destroy(); 18498 } 18499}; 18500function createLoaderContext(frag, part = null) { 18501 const segment = part || frag; 18502 const loaderContext = { 18503 frag, 18504 part, 18505 responseType: "arraybuffer", 18506 url: segment.url, 18507 headers: {}, 18508 rangeStart: 0, 18509 rangeEnd: 0 18510 }; 18511 const start = segment.byteRangeStartOffset; 18512 const end = segment.byteRangeEndOffset; 18513 if (isFiniteNumber(start) && isFiniteNumber(end)) { 18514 var _frag$decryptdata; 18515 let byteRangeStart = start; 18516 let byteRangeEnd = end; 18517 if (frag.sn === "initSegment" && ((_frag$decryptdata = frag.decryptdata) == null ? void 0 : _frag$decryptdata.method) === "AES-128") { 18518 const fragmentLen = end - start; 18519 if (fragmentLen % 16) { 18520 byteRangeEnd = end + (16 - fragmentLen % 16); 18521 } 18522 if (start !== 0) { 18523 loaderContext.resetIV = true; 18524 byteRangeStart = start - 16; 18525 } 18526 } 18527 loaderContext.rangeStart = byteRangeStart; 18528 loaderContext.rangeEnd = byteRangeEnd; 18529 } 18530 return loaderContext; 18531} 18532function createGapLoadError(frag, part) { 18533 const error = new Error(`GAP ${frag.gap ? "tag" : "attribute"} found`); 18534 const errorData = { 18535 type: ErrorTypes.MEDIA_ERROR, 18536 details: ErrorDetails.FRAG_GAP, 18537 fatal: false, 18538 frag, 18539 error, 18540 networkDetails: null 18541 }; 18542 if (part) { 18543 errorData.part = part; 18544 } 18545 (part ? part : frag).stats.aborted = true; 18546 return new LoadError(errorData); 18547} 18548var LoadError = class extends Error { 18549 constructor(data) { 18550 super(data.error.message); 18551 this.data = void 0; 18552 this.data = data; 18553 } 18554}; 18555var AESCrypto = class { 18556 constructor(subtle, iv) { 18557 this.subtle = void 0; 18558 this.aesIV = void 0; 18559 this.subtle = subtle; 18560 this.aesIV = iv; 18561 } 18562 decrypt(data, key) { 18563 return this.subtle.decrypt({ 18564 name: "AES-CBC", 18565 iv: this.aesIV 18566 }, key, data); 18567 } 18568}; 18569var FastAESKey = class { 18570 constructor(subtle, key) { 18571 this.subtle = void 0; 18572 this.key = void 0; 18573 this.subtle = subtle; 18574 this.key = key; 18575 } 18576 expandKey() { 18577 return this.subtle.importKey("raw", this.key, { 18578 name: "AES-CBC" 18579 }, false, ["encrypt", "decrypt"]); 18580 } 18581}; 18582function removePadding(array) { 18583 const outputBytes = array.byteLength; 18584 const paddingBytes = outputBytes && new DataView(array.buffer).getUint8(outputBytes - 1); 18585 if (paddingBytes) { 18586 return sliceUint8(array, 0, outputBytes - paddingBytes); 18587 } 18588 return array; 18589} 18590var AESDecryptor = class { 18591 constructor() { 18592 this.rcon = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54]; 18593 this.subMix = [new Uint32Array(256), new Uint32Array(256), new Uint32Array(256), new Uint32Array(256)]; 18594 this.invSubMix = [new Uint32Array(256), new Uint32Array(256), new Uint32Array(256), new Uint32Array(256)]; 18595 this.sBox = new Uint32Array(256); 18596 this.invSBox = new Uint32Array(256); 18597 this.key = new Uint32Array(0); 18598 this.ksRows = 0; 18599 this.keySize = 0; 18600 this.keySchedule = void 0; 18601 this.invKeySchedule = void 0; 18602 this.initTable(); 18603 } 18604 // Using view.getUint32() also swaps the byte order. 18605 uint8ArrayToUint32Array_(arrayBuffer) { 18606 const view = new DataView(arrayBuffer); 18607 const newArray = new Uint32Array(4); 18608 for (let i3 = 0; i3 < 4; i3++) { 18609 newArray[i3] = view.getUint32(i3 * 4); 18610 } 18611 return newArray; 18612 } 18613 initTable() { 18614 const sBox = this.sBox; 18615 const invSBox = this.invSBox; 18616 const subMix = this.subMix; 18617 const subMix0 = subMix[0]; 18618 const subMix1 = subMix[1]; 18619 const subMix2 = subMix[2]; 18620 const subMix3 = subMix[3]; 18621 const invSubMix = this.invSubMix; 18622 const invSubMix0 = invSubMix[0]; 18623 const invSubMix1 = invSubMix[1]; 18624 const invSubMix2 = invSubMix[2]; 18625 const invSubMix3 = invSubMix[3]; 18626 const d2 = new Uint32Array(256); 18627 let x2 = 0; 18628 let xi2 = 0; 18629 let i3 = 0; 18630 for (i3 = 0; i3 < 256; i3++) { 18631 if (i3 < 128) { 18632 d2[i3] = i3 << 1; 18633 } else { 18634 d2[i3] = i3 << 1 ^ 283; 18635 } 18636 } 18637 for (i3 = 0; i3 < 256; i3++) { 18638 let sx = xi2 ^ xi2 << 1 ^ xi2 << 2 ^ xi2 << 3 ^ xi2 << 4; 18639 sx = sx >>> 8 ^ sx & 255 ^ 99; 18640 sBox[x2] = sx; 18641 invSBox[sx] = x2; 18642 const x22 = d2[x2]; 18643 const x4 = d2[x22]; 18644 const x8 = d2[x4]; 18645 let t2 = d2[sx] * 257 ^ sx * 16843008; 18646 subMix0[x2] = t2 << 24 | t2 >>> 8; 18647 subMix1[x2] = t2 << 16 | t2 >>> 16; 18648 subMix2[x2] = t2 << 8 | t2 >>> 24; 18649 subMix3[x2] = t2; 18650 t2 = x8 * 16843009 ^ x4 * 65537 ^ x22 * 257 ^ x2 * 16843008; 18651 invSubMix0[sx] = t2 << 24 | t2 >>> 8; 18652 invSubMix1[sx] = t2 << 16 | t2 >>> 16; 18653 invSubMix2[sx] = t2 << 8 | t2 >>> 24; 18654 invSubMix3[sx] = t2; 18655 if (!x2) { 18656 x2 = xi2 = 1; 18657 } else { 18658 x2 = x22 ^ d2[d2[d2[x8 ^ x22]]]; 18659 xi2 ^= d2[d2[xi2]]; 18660 } 18661 } 18662 } 18663 expandKey(keyBuffer) { 18664 const key = this.uint8ArrayToUint32Array_(keyBuffer); 18665 let sameKey = true; 18666 let offset = 0; 18667 while (offset < key.length && sameKey) { 18668 sameKey = key[offset] === this.key[offset]; 18669 offset++; 18670 } 18671 if (sameKey) { 18672 return; 18673 } 18674 this.key = key; 18675 const keySize = this.keySize = key.length; 18676 if (keySize !== 4 && keySize !== 6 && keySize !== 8) { 18677 throw new Error("Invalid aes key size=" + keySize); 18678 } 18679 const ksRows = this.ksRows = (keySize + 6 + 1) * 4; 18680 let ksRow; 18681 let invKsRow; 18682 const keySchedule = this.keySchedule = new Uint32Array(ksRows); 18683 const invKeySchedule = this.invKeySchedule = new Uint32Array(ksRows); 18684 const sbox = this.sBox; 18685 const rcon = this.rcon; 18686 const invSubMix = this.invSubMix; 18687 const invSubMix0 = invSubMix[0]; 18688 const invSubMix1 = invSubMix[1]; 18689 const invSubMix2 = invSubMix[2]; 18690 const invSubMix3 = invSubMix[3]; 18691 let prev2; 18692 let t2; 18693 for (ksRow = 0; ksRow < ksRows; ksRow++) { 18694 if (ksRow < keySize) { 18695 prev2 = keySchedule[ksRow] = key[ksRow]; 18696 continue; 18697 } 18698 t2 = prev2; 18699 if (ksRow % keySize === 0) { 18700 t2 = t2 << 8 | t2 >>> 24; 18701 t2 = sbox[t2 >>> 24] << 24 | sbox[t2 >>> 16 & 255] << 16 | sbox[t2 >>> 8 & 255] << 8 | sbox[t2 & 255]; 18702 t2 ^= rcon[ksRow / keySize | 0] << 24; 18703 } else if (keySize > 6 && ksRow % keySize === 4) { 18704 t2 = sbox[t2 >>> 24] << 24 | sbox[t2 >>> 16 & 255] << 16 | sbox[t2 >>> 8 & 255] << 8 | sbox[t2 & 255]; 18705 } 18706 keySchedule[ksRow] = prev2 = (keySchedule[ksRow - keySize] ^ t2) >>> 0; 18707 } 18708 for (invKsRow = 0; invKsRow < ksRows; invKsRow++) { 18709 ksRow = ksRows - invKsRow; 18710 if (invKsRow & 3) { 18711 t2 = keySchedule[ksRow]; 18712 } else { 18713 t2 = keySchedule[ksRow - 4]; 18714 } 18715 if (invKsRow < 4 || ksRow <= 4) { 18716 invKeySchedule[invKsRow] = t2; 18717 } else { 18718 invKeySchedule[invKsRow] = invSubMix0[sbox[t2 >>> 24]] ^ invSubMix1[sbox[t2 >>> 16 & 255]] ^ invSubMix2[sbox[t2 >>> 8 & 255]] ^ invSubMix3[sbox[t2 & 255]]; 18719 } 18720 invKeySchedule[invKsRow] = invKeySchedule[invKsRow] >>> 0; 18721 } 18722 } 18723 // Adding this as a method greatly improves performance. 18724 networkToHostOrderSwap(word) { 18725 return word << 24 | (word & 65280) << 8 | (word & 16711680) >> 8 | word >>> 24; 18726 } 18727 decrypt(inputArrayBuffer, offset, aesIV) { 18728 const nRounds = this.keySize + 6; 18729 const invKeySchedule = this.invKeySchedule; 18730 const invSBOX = this.invSBox; 18731 const invSubMix = this.invSubMix; 18732 const invSubMix0 = invSubMix[0]; 18733 const invSubMix1 = invSubMix[1]; 18734 const invSubMix2 = invSubMix[2]; 18735 const invSubMix3 = invSubMix[3]; 18736 const initVector = this.uint8ArrayToUint32Array_(aesIV); 18737 let initVector0 = initVector[0]; 18738 let initVector1 = initVector[1]; 18739 let initVector2 = initVector[2]; 18740 let initVector3 = initVector[3]; 18741 const inputInt32 = new Int32Array(inputArrayBuffer); 18742 const outputInt32 = new Int32Array(inputInt32.length); 18743 let t0, t1, t2, t3; 18744 let s0, s1, s2, s3; 18745 let inputWords0, inputWords1, inputWords2, inputWords3; 18746 let ksRow, i3; 18747 const swapWord = this.networkToHostOrderSwap; 18748 while (offset < inputInt32.length) { 18749 inputWords0 = swapWord(inputInt32[offset]); 18750 inputWords1 = swapWord(inputInt32[offset + 1]); 18751 inputWords2 = swapWord(inputInt32[offset + 2]); 18752 inputWords3 = swapWord(inputInt32[offset + 3]); 18753 s0 = inputWords0 ^ invKeySchedule[0]; 18754 s1 = inputWords3 ^ invKeySchedule[1]; 18755 s2 = inputWords2 ^ invKeySchedule[2]; 18756 s3 = inputWords1 ^ invKeySchedule[3]; 18757 ksRow = 4; 18758 for (i3 = 1; i3 < nRounds; i3++) { 18759 t0 = invSubMix0[s0 >>> 24] ^ invSubMix1[s1 >> 16 & 255] ^ invSubMix2[s2 >> 8 & 255] ^ invSubMix3[s3 & 255] ^ invKeySchedule[ksRow]; 18760 t1 = invSubMix0[s1 >>> 24] ^ invSubMix1[s2 >> 16 & 255] ^ invSubMix2[s3 >> 8 & 255] ^ invSubMix3[s0 & 255] ^ invKeySchedule[ksRow + 1]; 18761 t2 = invSubMix0[s2 >>> 24] ^ invSubMix1[s3 >> 16 & 255] ^ invSubMix2[s0 >> 8 & 255] ^ invSubMix3[s1 & 255] ^ invKeySchedule[ksRow + 2]; 18762 t3 = invSubMix0[s3 >>> 24] ^ invSubMix1[s0 >> 16 & 255] ^ invSubMix2[s1 >> 8 & 255] ^ invSubMix3[s2 & 255] ^ invKeySchedule[ksRow + 3]; 18763 s0 = t0; 18764 s1 = t1; 18765 s2 = t2; 18766 s3 = t3; 18767 ksRow = ksRow + 4; 18768 } 18769 t0 = invSBOX[s0 >>> 24] << 24 ^ invSBOX[s1 >> 16 & 255] << 16 ^ invSBOX[s2 >> 8 & 255] << 8 ^ invSBOX[s3 & 255] ^ invKeySchedule[ksRow]; 18770 t1 = invSBOX[s1 >>> 24] << 24 ^ invSBOX[s2 >> 16 & 255] << 16 ^ invSBOX[s3 >> 8 & 255] << 8 ^ invSBOX[s0 & 255] ^ invKeySchedule[ksRow + 1]; 18771 t2 = invSBOX[s2 >>> 24] << 24 ^ invSBOX[s3 >> 16 & 255] << 16 ^ invSBOX[s0 >> 8 & 255] << 8 ^ invSBOX[s1 & 255] ^ invKeySchedule[ksRow + 2]; 18772 t3 = invSBOX[s3 >>> 24] << 24 ^ invSBOX[s0 >> 16 & 255] << 16 ^ invSBOX[s1 >> 8 & 255] << 8 ^ invSBOX[s2 & 255] ^ invKeySchedule[ksRow + 3]; 18773 outputInt32[offset] = swapWord(t0 ^ initVector0); 18774 outputInt32[offset + 1] = swapWord(t3 ^ initVector1); 18775 outputInt32[offset + 2] = swapWord(t2 ^ initVector2); 18776 outputInt32[offset + 3] = swapWord(t1 ^ initVector3); 18777 initVector0 = inputWords0; 18778 initVector1 = inputWords1; 18779 initVector2 = inputWords2; 18780 initVector3 = inputWords3; 18781 offset = offset + 4; 18782 } 18783 return outputInt32.buffer; 18784 } 18785}; 18786var CHUNK_SIZE = 16; 18787var Decrypter = class { 18788 constructor(config, { 18789 removePKCS7Padding = true 18790 } = {}) { 18791 this.logEnabled = true; 18792 this.removePKCS7Padding = void 0; 18793 this.subtle = null; 18794 this.softwareDecrypter = null; 18795 this.key = null; 18796 this.fastAesKey = null; 18797 this.remainderData = null; 18798 this.currentIV = null; 18799 this.currentResult = null; 18800 this.useSoftware = void 0; 18801 this.useSoftware = config.enableSoftwareAES; 18802 this.removePKCS7Padding = removePKCS7Padding; 18803 if (removePKCS7Padding) { 18804 try { 18805 const browserCrypto = self.crypto; 18806 if (browserCrypto) { 18807 this.subtle = browserCrypto.subtle || browserCrypto.webkitSubtle; 18808 } 18809 } catch (e) { 18810 } 18811 } 18812 this.useSoftware = !this.subtle; 18813 } 18814 destroy() { 18815 this.subtle = null; 18816 this.softwareDecrypter = null; 18817 this.key = null; 18818 this.fastAesKey = null; 18819 this.remainderData = null; 18820 this.currentIV = null; 18821 this.currentResult = null; 18822 } 18823 isSync() { 18824 return this.useSoftware; 18825 } 18826 flush() { 18827 const { 18828 currentResult, 18829 remainderData 18830 } = this; 18831 if (!currentResult || remainderData) { 18832 this.reset(); 18833 return null; 18834 } 18835 const data = new Uint8Array(currentResult); 18836 this.reset(); 18837 if (this.removePKCS7Padding) { 18838 return removePadding(data); 18839 } 18840 return data; 18841 } 18842 reset() { 18843 this.currentResult = null; 18844 this.currentIV = null; 18845 this.remainderData = null; 18846 if (this.softwareDecrypter) { 18847 this.softwareDecrypter = null; 18848 } 18849 } 18850 decrypt(data, key, iv) { 18851 if (this.useSoftware) { 18852 return new Promise((resolve, reject) => { 18853 this.softwareDecrypt(new Uint8Array(data), key, iv); 18854 const decryptResult = this.flush(); 18855 if (decryptResult) { 18856 resolve(decryptResult.buffer); 18857 } else { 18858 reject(new Error("[softwareDecrypt] Failed to decrypt data")); 18859 } 18860 }); 18861 } 18862 return this.webCryptoDecrypt(new Uint8Array(data), key, iv); 18863 } 18864 // Software decryption is progressive. Progressive decryption may not return a result on each call. Any cached 18865 // data is handled in the flush() call 18866 softwareDecrypt(data, key, iv) { 18867 const { 18868 currentIV, 18869 currentResult, 18870 remainderData 18871 } = this; 18872 this.logOnce("JS AES decrypt"); 18873 if (remainderData) { 18874 data = appendUint8Array(remainderData, data); 18875 this.remainderData = null; 18876 } 18877 const currentChunk = this.getValidChunk(data); 18878 if (!currentChunk.length) { 18879 return null; 18880 } 18881 if (currentIV) { 18882 iv = currentIV; 18883 } 18884 let softwareDecrypter = this.softwareDecrypter; 18885 if (!softwareDecrypter) { 18886 softwareDecrypter = this.softwareDecrypter = new AESDecryptor(); 18887 } 18888 softwareDecrypter.expandKey(key); 18889 const result = currentResult; 18890 this.currentResult = softwareDecrypter.decrypt(currentChunk.buffer, 0, iv); 18891 this.currentIV = sliceUint8(currentChunk, -16).buffer; 18892 if (!result) { 18893 return null; 18894 } 18895 return result; 18896 } 18897 webCryptoDecrypt(data, key, iv) { 18898 if (this.key !== key || !this.fastAesKey) { 18899 if (!this.subtle) { 18900 return Promise.resolve(this.onWebCryptoError(data, key, iv)); 18901 } 18902 this.key = key; 18903 this.fastAesKey = new FastAESKey(this.subtle, key); 18904 } 18905 return this.fastAesKey.expandKey().then((aesKey) => { 18906 if (!this.subtle) { 18907 return Promise.reject(new Error("web crypto not initialized")); 18908 } 18909 this.logOnce("WebCrypto AES decrypt"); 18910 const crypto2 = new AESCrypto(this.subtle, new Uint8Array(iv)); 18911 return crypto2.decrypt(data.buffer, aesKey); 18912 }).catch((err) => { 18913 logger.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${err.name}: ${err.message}`); 18914 return this.onWebCryptoError(data, key, iv); 18915 }); 18916 } 18917 onWebCryptoError(data, key, iv) { 18918 this.useSoftware = true; 18919 this.logEnabled = true; 18920 this.softwareDecrypt(data, key, iv); 18921 const decryptResult = this.flush(); 18922 if (decryptResult) { 18923 return decryptResult.buffer; 18924 } 18925 throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data"); 18926 } 18927 getValidChunk(data) { 18928 let currentChunk = data; 18929 const splitPoint = data.length - data.length % CHUNK_SIZE; 18930 if (splitPoint !== data.length) { 18931 currentChunk = sliceUint8(data, 0, splitPoint); 18932 this.remainderData = sliceUint8(data, splitPoint); 18933 } 18934 return currentChunk; 18935 } 18936 logOnce(msg) { 18937 if (!this.logEnabled) { 18938 return; 18939 } 18940 logger.log(`[decrypter]: ${msg}`); 18941 this.logEnabled = false; 18942 } 18943}; 18944var TimeRanges = { 18945 toString: function(r10) { 18946 let log = ""; 18947 const len = r10.length; 18948 for (let i3 = 0; i3 < len; i3++) { 18949 log += `[${r10.start(i3).toFixed(3)}-${r10.end(i3).toFixed(3)}]`; 18950 } 18951 return log; 18952 } 18953}; 18954var State = { 18955 STOPPED: "STOPPED", 18956 IDLE: "IDLE", 18957 KEY_LOADING: "KEY_LOADING", 18958 FRAG_LOADING: "FRAG_LOADING", 18959 FRAG_LOADING_WAITING_RETRY: "FRAG_LOADING_WAITING_RETRY", 18960 WAITING_TRACK: "WAITING_TRACK", 18961 PARSING: "PARSING", 18962 PARSED: "PARSED", 18963 ENDED: "ENDED", 18964 ERROR: "ERROR", 18965 WAITING_INIT_PTS: "WAITING_INIT_PTS", 18966 WAITING_LEVEL: "WAITING_LEVEL" 18967}; 18968var BaseStreamController = class extends TaskLoop { 18969 constructor(hls, fragmentTracker, keyLoader, logPrefix, playlistType) { 18970 super(); 18971 this.hls = void 0; 18972 this.fragPrevious = null; 18973 this.fragCurrent = null; 18974 this.fragmentTracker = void 0; 18975 this.transmuxer = null; 18976 this._state = State.STOPPED; 18977 this.playlistType = void 0; 18978 this.media = null; 18979 this.mediaBuffer = null; 18980 this.config = void 0; 18981 this.bitrateTest = false; 18982 this.lastCurrentTime = 0; 18983 this.nextLoadPosition = 0; 18984 this.startPosition = 0; 18985 this.startTimeOffset = null; 18986 this.loadedmetadata = false; 18987 this.retryDate = 0; 18988 this.levels = null; 18989 this.fragmentLoader = void 0; 18990 this.keyLoader = void 0; 18991 this.levelLastLoaded = null; 18992 this.startFragRequested = false; 18993 this.decrypter = void 0; 18994 this.initPTS = []; 18995 this.buffering = true; 18996 this.onvseeking = null; 18997 this.onvended = null; 18998 this.logPrefix = ""; 18999 this.log = void 0; 19000 this.warn = void 0; 19001 this.playlistType = playlistType; 19002 this.logPrefix = logPrefix; 19003 this.log = logger.log.bind(logger, `${logPrefix}:`); 19004 this.warn = logger.warn.bind(logger, `${logPrefix}:`); 19005 this.hls = hls; 19006 this.fragmentLoader = new FragmentLoader(hls.config); 19007 this.keyLoader = keyLoader; 19008 this.fragmentTracker = fragmentTracker; 19009 this.config = hls.config; 19010 this.decrypter = new Decrypter(hls.config); 19011 hls.on(Events.MANIFEST_LOADED, this.onManifestLoaded, this); 19012 } 19013 doTick() { 19014 this.onTickEnd(); 19015 } 19016 onTickEnd() { 19017 } 19018 // eslint-disable-next-line @typescript-eslint/no-unused-vars 19019 startLoad(startPosition) { 19020 } 19021 stopLoad() { 19022 this.fragmentLoader.abort(); 19023 this.keyLoader.abort(this.playlistType); 19024 const frag = this.fragCurrent; 19025 if (frag != null && frag.loader) { 19026 frag.abortRequests(); 19027 this.fragmentTracker.removeFragment(frag); 19028 } 19029 this.resetTransmuxer(); 19030 this.fragCurrent = null; 19031 this.fragPrevious = null; 19032 this.clearInterval(); 19033 this.clearNextTick(); 19034 this.state = State.STOPPED; 19035 } 19036 pauseBuffering() { 19037 this.buffering = false; 19038 } 19039 resumeBuffering() { 19040 this.buffering = true; 19041 } 19042 _streamEnded(bufferInfo, levelDetails) { 19043 if (levelDetails.live || bufferInfo.nextStart || !bufferInfo.end || !this.media) { 19044 return false; 19045 } 19046 const partList = levelDetails.partList; 19047 if (partList != null && partList.length) { 19048 const lastPart = partList[partList.length - 1]; 19049 const lastPartBuffered = BufferHelper.isBuffered(this.media, lastPart.start + lastPart.duration / 2); 19050 return lastPartBuffered; 19051 } 19052 const playlistType = levelDetails.fragments[levelDetails.fragments.length - 1].type; 19053 return this.fragmentTracker.isEndListAppended(playlistType); 19054 } 19055 getLevelDetails() { 19056 if (this.levels && this.levelLastLoaded !== null) { 19057 var _this$levelLastLoaded; 19058 return (_this$levelLastLoaded = this.levelLastLoaded) == null ? void 0 : _this$levelLastLoaded.details; 19059 } 19060 } 19061 onMediaAttached(event, data) { 19062 const media = this.media = this.mediaBuffer = data.media; 19063 this.onvseeking = this.onMediaSeeking.bind(this); 19064 this.onvended = this.onMediaEnded.bind(this); 19065 media.addEventListener("seeking", this.onvseeking); 19066 media.addEventListener("ended", this.onvended); 19067 const config = this.config; 19068 if (this.levels && config.autoStartLoad && this.state === State.STOPPED) { 19069 this.startLoad(config.startPosition); 19070 } 19071 } 19072 onMediaDetaching() { 19073 const media = this.media; 19074 if (media != null && media.ended) { 19075 this.log("MSE detaching and video ended, reset startPosition"); 19076 this.startPosition = this.lastCurrentTime = 0; 19077 } 19078 if (media && this.onvseeking && this.onvended) { 19079 media.removeEventListener("seeking", this.onvseeking); 19080 media.removeEventListener("ended", this.onvended); 19081 this.onvseeking = this.onvended = null; 19082 } 19083 if (this.keyLoader) { 19084 this.keyLoader.detach(); 19085 } 19086 this.media = this.mediaBuffer = null; 19087 this.loadedmetadata = false; 19088 this.fragmentTracker.removeAllFragments(); 19089 this.stopLoad(); 19090 } 19091 onMediaSeeking() { 19092 const { 19093 config, 19094 fragCurrent, 19095 media, 19096 mediaBuffer, 19097 state 19098 } = this; 19099 const currentTime = media ? media.currentTime : 0; 19100 const bufferInfo = BufferHelper.bufferInfo(mediaBuffer ? mediaBuffer : media, currentTime, config.maxBufferHole); 19101 this.log(`media seeking to ${isFiniteNumber(currentTime) ? currentTime.toFixed(3) : currentTime}, state: ${state}`); 19102 if (this.state === State.ENDED) { 19103 this.resetLoadingState(); 19104 } else if (fragCurrent) { 19105 const tolerance = config.maxFragLookUpTolerance; 19106 const fragStartOffset = fragCurrent.start - tolerance; 19107 const fragEndOffset = fragCurrent.start + fragCurrent.duration + tolerance; 19108 if (!bufferInfo.len || fragEndOffset < bufferInfo.start || fragStartOffset > bufferInfo.end) { 19109 const pastFragment = currentTime > fragEndOffset; 19110 if (currentTime < fragStartOffset || pastFragment) { 19111 if (pastFragment && fragCurrent.loader) { 19112 this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"); 19113 fragCurrent.abortRequests(); 19114 this.resetLoadingState(); 19115 } 19116 this.fragPrevious = null; 19117 } 19118 } 19119 } 19120 if (media) { 19121 this.fragmentTracker.removeFragmentsInRange(currentTime, Infinity, this.playlistType, true); 19122 this.lastCurrentTime = currentTime; 19123 } 19124 if (!this.loadedmetadata && !bufferInfo.len) { 19125 this.nextLoadPosition = this.startPosition = currentTime; 19126 } 19127 this.tickImmediate(); 19128 } 19129 onMediaEnded() { 19130 this.startPosition = this.lastCurrentTime = 0; 19131 } 19132 onManifestLoaded(event, data) { 19133 this.startTimeOffset = data.startTimeOffset; 19134 this.initPTS = []; 19135 } 19136 onHandlerDestroying() { 19137 this.hls.off(Events.MANIFEST_LOADED, this.onManifestLoaded, this); 19138 this.stopLoad(); 19139 super.onHandlerDestroying(); 19140 this.hls = null; 19141 } 19142 onHandlerDestroyed() { 19143 this.state = State.STOPPED; 19144 if (this.fragmentLoader) { 19145 this.fragmentLoader.destroy(); 19146 } 19147 if (this.keyLoader) { 19148 this.keyLoader.destroy(); 19149 } 19150 if (this.decrypter) { 19151 this.decrypter.destroy(); 19152 } 19153 this.hls = this.log = this.warn = this.decrypter = this.keyLoader = this.fragmentLoader = this.fragmentTracker = null; 19154 super.onHandlerDestroyed(); 19155 } 19156 loadFragment(frag, level, targetBufferTime) { 19157 this._loadFragForPlayback(frag, level, targetBufferTime); 19158 } 19159 _loadFragForPlayback(frag, level, targetBufferTime) { 19160 const progressCallback = (data) => { 19161 if (this.fragContextChanged(frag)) { 19162 this.warn(`Fragment ${frag.sn}${data.part ? " p: " + data.part.index : ""} of level ${frag.level} was dropped during download.`); 19163 this.fragmentTracker.removeFragment(frag); 19164 return; 19165 } 19166 frag.stats.chunkCount++; 19167 this._handleFragmentLoadProgress(data); 19168 }; 19169 this._doFragLoad(frag, level, targetBufferTime, progressCallback).then((data) => { 19170 if (!data) { 19171 return; 19172 } 19173 const state = this.state; 19174 if (this.fragContextChanged(frag)) { 19175 if (state === State.FRAG_LOADING || !this.fragCurrent && state === State.PARSING) { 19176 this.fragmentTracker.removeFragment(frag); 19177 this.state = State.IDLE; 19178 } 19179 return; 19180 } 19181 if ("payload" in data) { 19182 this.log(`Loaded fragment ${frag.sn} of level ${frag.level}`); 19183 this.hls.trigger(Events.FRAG_LOADED, data); 19184 } 19185 this._handleFragmentLoadComplete(data); 19186 }).catch((reason) => { 19187 if (this.state === State.STOPPED || this.state === State.ERROR) { 19188 return; 19189 } 19190 this.warn(`Frag error: ${(reason == null ? void 0 : reason.message) || reason}`); 19191 this.resetFragmentLoading(frag); 19192 }); 19193 } 19194 clearTrackerIfNeeded(frag) { 19195 var _this$mediaBuffer; 19196 const { 19197 fragmentTracker 19198 } = this; 19199 const fragState = fragmentTracker.getState(frag); 19200 if (fragState === FragmentState.APPENDING) { 19201 const playlistType = frag.type; 19202 const bufferedInfo = this.getFwdBufferInfo(this.mediaBuffer, playlistType); 19203 const minForwardBufferLength = Math.max(frag.duration, bufferedInfo ? bufferedInfo.len : this.config.maxBufferLength); 19204 const backtrackFragment = this.backtrackFragment; 19205 const backtracked = backtrackFragment ? frag.sn - backtrackFragment.sn : 0; 19206 if (backtracked === 1 || this.reduceMaxBufferLength(minForwardBufferLength, frag.duration)) { 19207 fragmentTracker.removeFragment(frag); 19208 } 19209 } else if (((_this$mediaBuffer = this.mediaBuffer) == null ? void 0 : _this$mediaBuffer.buffered.length) === 0) { 19210 fragmentTracker.removeAllFragments(); 19211 } else if (fragmentTracker.hasParts(frag.type)) { 19212 fragmentTracker.detectPartialFragments({ 19213 frag, 19214 part: null, 19215 stats: frag.stats, 19216 id: frag.type 19217 }); 19218 if (fragmentTracker.getState(frag) === FragmentState.PARTIAL) { 19219 fragmentTracker.removeFragment(frag); 19220 } 19221 } 19222 } 19223 checkLiveUpdate(details) { 19224 if (details.updated && !details.live) { 19225 const lastFragment = details.fragments[details.fragments.length - 1]; 19226 this.fragmentTracker.detectPartialFragments({ 19227 frag: lastFragment, 19228 part: null, 19229 stats: lastFragment.stats, 19230 id: lastFragment.type 19231 }); 19232 } 19233 if (!details.fragments[0]) { 19234 details.deltaUpdateFailed = true; 19235 } 19236 } 19237 flushMainBuffer(startOffset, endOffset, type = null) { 19238 if (!(startOffset - endOffset)) { 19239 return; 19240 } 19241 const flushScope = { 19242 startOffset, 19243 endOffset, 19244 type 19245 }; 19246 this.hls.trigger(Events.BUFFER_FLUSHING, flushScope); 19247 } 19248 _loadInitSegment(frag, level) { 19249 this._doFragLoad(frag, level).then((data) => { 19250 if (!data || this.fragContextChanged(frag) || !this.levels) { 19251 throw new Error("init load aborted"); 19252 } 19253 return data; 19254 }).then((data) => { 19255 const { 19256 hls 19257 } = this; 19258 const { 19259 payload 19260 } = data; 19261 const decryptData = frag.decryptdata; 19262 if (payload && payload.byteLength > 0 && decryptData != null && decryptData.key && decryptData.iv && decryptData.method === "AES-128") { 19263 const startTime = self.performance.now(); 19264 return this.decrypter.decrypt(new Uint8Array(payload), decryptData.key.buffer, decryptData.iv.buffer).catch((err) => { 19265 hls.trigger(Events.ERROR, { 19266 type: ErrorTypes.MEDIA_ERROR, 19267 details: ErrorDetails.FRAG_DECRYPT_ERROR, 19268 fatal: false, 19269 error: err, 19270 reason: err.message, 19271 frag 19272 }); 19273 throw err; 19274 }).then((decryptedData) => { 19275 const endTime = self.performance.now(); 19276 hls.trigger(Events.FRAG_DECRYPTED, { 19277 frag, 19278 payload: decryptedData, 19279 stats: { 19280 tstart: startTime, 19281 tdecrypt: endTime 19282 } 19283 }); 19284 data.payload = decryptedData; 19285 return this.completeInitSegmentLoad(data); 19286 }); 19287 } 19288 return this.completeInitSegmentLoad(data); 19289 }).catch((reason) => { 19290 if (this.state === State.STOPPED || this.state === State.ERROR) { 19291 return; 19292 } 19293 this.warn(reason); 19294 this.resetFragmentLoading(frag); 19295 }); 19296 } 19297 completeInitSegmentLoad(data) { 19298 const { 19299 levels 19300 } = this; 19301 if (!levels) { 19302 throw new Error("init load aborted, missing levels"); 19303 } 19304 const stats = data.frag.stats; 19305 this.state = State.IDLE; 19306 data.frag.data = new Uint8Array(data.payload); 19307 stats.parsing.start = stats.buffering.start = self.performance.now(); 19308 stats.parsing.end = stats.buffering.end = self.performance.now(); 19309 this.tick(); 19310 } 19311 fragContextChanged(frag) { 19312 const { 19313 fragCurrent 19314 } = this; 19315 return !frag || !fragCurrent || frag.sn !== fragCurrent.sn || frag.level !== fragCurrent.level; 19316 } 19317 fragBufferedComplete(frag, part) { 19318 var _frag$startPTS, _frag$endPTS, _this$fragCurrent, _this$fragPrevious; 19319 const media = this.mediaBuffer ? this.mediaBuffer : this.media; 19320 this.log(`Buffered ${frag.type} sn: ${frag.sn}${part ? " part: " + part.index : ""} of ${this.playlistType === PlaylistLevelType.MAIN ? "level" : "track"} ${frag.level} (frag:[${((_frag$startPTS = frag.startPTS) != null ? _frag$startPTS : NaN).toFixed(3)}-${((_frag$endPTS = frag.endPTS) != null ? _frag$endPTS : NaN).toFixed(3)}] > buffer:${media ? TimeRanges.toString(BufferHelper.getBuffered(media)) : "(detached)"})`); 19321 if (frag.sn !== "initSegment") { 19322 var _this$levels; 19323 if (frag.type !== PlaylistLevelType.SUBTITLE) { 19324 const el = frag.elementaryStreams; 19325 if (!Object.keys(el).some((type) => !!el[type])) { 19326 this.state = State.IDLE; 19327 return; 19328 } 19329 } 19330 const level = (_this$levels = this.levels) == null ? void 0 : _this$levels[frag.level]; 19331 if (level != null && level.fragmentError) { 19332 this.log(`Resetting level fragment error count of ${level.fragmentError} on frag buffered`); 19333 level.fragmentError = 0; 19334 } 19335 } 19336 this.state = State.IDLE; 19337 if (!media) { 19338 return; 19339 } 19340 if (!this.loadedmetadata && frag.type == PlaylistLevelType.MAIN && media.buffered.length && ((_this$fragCurrent = this.fragCurrent) == null ? void 0 : _this$fragCurrent.sn) === ((_this$fragPrevious = this.fragPrevious) == null ? void 0 : _this$fragPrevious.sn)) { 19341 this.loadedmetadata = true; 19342 this.seekToStartPos(); 19343 } 19344 this.tick(); 19345 } 19346 seekToStartPos() { 19347 } 19348 _handleFragmentLoadComplete(fragLoadedEndData) { 19349 const { 19350 transmuxer 19351 } = this; 19352 if (!transmuxer) { 19353 return; 19354 } 19355 const { 19356 frag, 19357 part, 19358 partsLoaded 19359 } = fragLoadedEndData; 19360 const complete = !partsLoaded || partsLoaded.length === 0 || partsLoaded.some((fragLoaded) => !fragLoaded); 19361 const chunkMeta = new ChunkMetadata(frag.level, frag.sn, frag.stats.chunkCount + 1, 0, part ? part.index : -1, !complete); 19362 transmuxer.flush(chunkMeta); 19363 } 19364 // eslint-disable-next-line @typescript-eslint/no-unused-vars 19365 _handleFragmentLoadProgress(frag) { 19366 } 19367 _doFragLoad(frag, level, targetBufferTime = null, progressCallback) { 19368 var _frag$decryptdata; 19369 const details = level == null ? void 0 : level.details; 19370 if (!this.levels || !details) { 19371 throw new Error(`frag load aborted, missing level${details ? "" : " detail"}s`); 19372 } 19373 let keyLoadingPromise = null; 19374 if (frag.encrypted && !((_frag$decryptdata = frag.decryptdata) != null && _frag$decryptdata.key)) { 19375 this.log(`Loading key for ${frag.sn} of [${details.startSN}-${details.endSN}], ${this.logPrefix === "[stream-controller]" ? "level" : "track"} ${frag.level}`); 19376 this.state = State.KEY_LOADING; 19377 this.fragCurrent = frag; 19378 keyLoadingPromise = this.keyLoader.load(frag).then((keyLoadedData) => { 19379 if (!this.fragContextChanged(keyLoadedData.frag)) { 19380 this.hls.trigger(Events.KEY_LOADED, keyLoadedData); 19381 if (this.state === State.KEY_LOADING) { 19382 this.state = State.IDLE; 19383 } 19384 return keyLoadedData; 19385 } 19386 }); 19387 this.hls.trigger(Events.KEY_LOADING, { 19388 frag 19389 }); 19390 if (this.fragCurrent === null) { 19391 keyLoadingPromise = Promise.reject(new Error(`frag load aborted, context changed in KEY_LOADING`)); 19392 } 19393 } else if (!frag.encrypted && details.encryptedFragments.length) { 19394 this.keyLoader.loadClear(frag, details.encryptedFragments); 19395 } 19396 targetBufferTime = Math.max(frag.start, targetBufferTime || 0); 19397 if (this.config.lowLatencyMode && frag.sn !== "initSegment") { 19398 const partList = details.partList; 19399 if (partList && progressCallback) { 19400 if (targetBufferTime > frag.end && details.fragmentHint) { 19401 frag = details.fragmentHint; 19402 } 19403 const partIndex = this.getNextPart(partList, frag, targetBufferTime); 19404 if (partIndex > -1) { 19405 const part = partList[partIndex]; 19406 this.log(`Loading part sn: ${frag.sn} p: ${part.index} cc: ${frag.cc} of playlist [${details.startSN}-${details.endSN}] parts [0-${partIndex}-${partList.length - 1}] ${this.logPrefix === "[stream-controller]" ? "level" : "track"}: ${frag.level}, target: ${parseFloat(targetBufferTime.toFixed(3))}`); 19407 this.nextLoadPosition = part.start + part.duration; 19408 this.state = State.FRAG_LOADING; 19409 let _result; 19410 if (keyLoadingPromise) { 19411 _result = keyLoadingPromise.then((keyLoadedData) => { 19412 if (!keyLoadedData || this.fragContextChanged(keyLoadedData.frag)) { 19413 return null; 19414 } 19415 return this.doFragPartsLoad(frag, part, level, progressCallback); 19416 }).catch((error) => this.handleFragLoadError(error)); 19417 } else { 19418 _result = this.doFragPartsLoad(frag, part, level, progressCallback).catch((error) => this.handleFragLoadError(error)); 19419 } 19420 this.hls.trigger(Events.FRAG_LOADING, { 19421 frag, 19422 part, 19423 targetBufferTime 19424 }); 19425 if (this.fragCurrent === null) { 19426 return Promise.reject(new Error(`frag load aborted, context changed in FRAG_LOADING parts`)); 19427 } 19428 return _result; 19429 } else if (!frag.url || this.loadedEndOfParts(partList, targetBufferTime)) { 19430 return Promise.resolve(null); 19431 } 19432 } 19433 } 19434 this.log(`Loading fragment ${frag.sn} cc: ${frag.cc} ${details ? "of [" + details.startSN + "-" + details.endSN + "] " : ""}${this.logPrefix === "[stream-controller]" ? "level" : "track"}: ${frag.level}, target: ${parseFloat(targetBufferTime.toFixed(3))}`); 19435 if (isFiniteNumber(frag.sn) && !this.bitrateTest) { 19436 this.nextLoadPosition = frag.start + frag.duration; 19437 } 19438 this.state = State.FRAG_LOADING; 19439 const dataOnProgress = this.config.progressive; 19440 let result; 19441 if (dataOnProgress && keyLoadingPromise) { 19442 result = keyLoadingPromise.then((keyLoadedData) => { 19443 if (!keyLoadedData || this.fragContextChanged(keyLoadedData == null ? void 0 : keyLoadedData.frag)) { 19444 return null; 19445 } 19446 return this.fragmentLoader.load(frag, progressCallback); 19447 }).catch((error) => this.handleFragLoadError(error)); 19448 } else { 19449 result = Promise.all([this.fragmentLoader.load(frag, dataOnProgress ? progressCallback : void 0), keyLoadingPromise]).then(([fragLoadedData]) => { 19450 if (!dataOnProgress && fragLoadedData && progressCallback) { 19451 progressCallback(fragLoadedData); 19452 } 19453 return fragLoadedData; 19454 }).catch((error) => this.handleFragLoadError(error)); 19455 } 19456 this.hls.trigger(Events.FRAG_LOADING, { 19457 frag, 19458 targetBufferTime 19459 }); 19460 if (this.fragCurrent === null) { 19461 return Promise.reject(new Error(`frag load aborted, context changed in FRAG_LOADING`)); 19462 } 19463 return result; 19464 } 19465 doFragPartsLoad(frag, fromPart, level, progressCallback) { 19466 return new Promise((resolve, reject) => { 19467 var _level$details; 19468 const partsLoaded = []; 19469 const initialPartList = (_level$details = level.details) == null ? void 0 : _level$details.partList; 19470 const loadPart = (part) => { 19471 this.fragmentLoader.loadPart(frag, part, progressCallback).then((partLoadedData) => { 19472 partsLoaded[part.index] = partLoadedData; 19473 const loadedPart = partLoadedData.part; 19474 this.hls.trigger(Events.FRAG_LOADED, partLoadedData); 19475 const nextPart = getPartWith(level, frag.sn, part.index + 1) || findPart(initialPartList, frag.sn, part.index + 1); 19476 if (nextPart) { 19477 loadPart(nextPart); 19478 } else { 19479 return resolve({ 19480 frag, 19481 part: loadedPart, 19482 partsLoaded 19483 }); 19484 } 19485 }).catch(reject); 19486 }; 19487 loadPart(fromPart); 19488 }); 19489 } 19490 handleFragLoadError(error) { 19491 if ("data" in error) { 19492 const data = error.data; 19493 if (error.data && data.details === ErrorDetails.INTERNAL_ABORTED) { 19494 this.handleFragLoadAborted(data.frag, data.part); 19495 } else { 19496 this.hls.trigger(Events.ERROR, data); 19497 } 19498 } else { 19499 this.hls.trigger(Events.ERROR, { 19500 type: ErrorTypes.OTHER_ERROR, 19501 details: ErrorDetails.INTERNAL_EXCEPTION, 19502 err: error, 19503 error, 19504 fatal: true 19505 }); 19506 } 19507 return null; 19508 } 19509 _handleTransmuxerFlush(chunkMeta) { 19510 const context = this.getCurrentContext(chunkMeta); 19511 if (!context || this.state !== State.PARSING) { 19512 if (!this.fragCurrent && this.state !== State.STOPPED && this.state !== State.ERROR) { 19513 this.state = State.IDLE; 19514 } 19515 return; 19516 } 19517 const { 19518 frag, 19519 part, 19520 level 19521 } = context; 19522 const now2 = self.performance.now(); 19523 frag.stats.parsing.end = now2; 19524 if (part) { 19525 part.stats.parsing.end = now2; 19526 } 19527 this.updateLevelTiming(frag, part, level, chunkMeta.partial); 19528 } 19529 getCurrentContext(chunkMeta) { 19530 const { 19531 levels, 19532 fragCurrent 19533 } = this; 19534 const { 19535 level: levelIndex, 19536 sn, 19537 part: partIndex 19538 } = chunkMeta; 19539 if (!(levels != null && levels[levelIndex])) { 19540 this.warn(`Levels object was unset while buffering fragment ${sn} of level ${levelIndex}. The current chunk will not be buffered.`); 19541 return null; 19542 } 19543 const level = levels[levelIndex]; 19544 const part = partIndex > -1 ? getPartWith(level, sn, partIndex) : null; 19545 const frag = part ? part.fragment : getFragmentWithSN(level, sn, fragCurrent); 19546 if (!frag) { 19547 return null; 19548 } 19549 if (fragCurrent && fragCurrent !== frag) { 19550 frag.stats = fragCurrent.stats; 19551 } 19552 return { 19553 frag, 19554 part, 19555 level 19556 }; 19557 } 19558 bufferFragmentData(data, frag, part, chunkMeta, noBacktracking) { 19559 var _buffer; 19560 if (!data || this.state !== State.PARSING) { 19561 return; 19562 } 19563 const { 19564 data1, 19565 data2 19566 } = data; 19567 let buffer = data1; 19568 if (data1 && data2) { 19569 buffer = appendUint8Array(data1, data2); 19570 } 19571 if (!((_buffer = buffer) != null && _buffer.length)) { 19572 return; 19573 } 19574 const segment = { 19575 type: data.type, 19576 frag, 19577 part, 19578 chunkMeta, 19579 parent: frag.type, 19580 data: buffer 19581 }; 19582 this.hls.trigger(Events.BUFFER_APPENDING, segment); 19583 if (data.dropped && data.independent && !part) { 19584 if (noBacktracking) { 19585 return; 19586 } 19587 this.flushBufferGap(frag); 19588 } 19589 } 19590 flushBufferGap(frag) { 19591 const media = this.media; 19592 if (!media) { 19593 return; 19594 } 19595 if (!BufferHelper.isBuffered(media, media.currentTime)) { 19596 this.flushMainBuffer(0, frag.start); 19597 return; 19598 } 19599 const currentTime = media.currentTime; 19600 const bufferInfo = BufferHelper.bufferInfo(media, currentTime, 0); 19601 const fragDuration = frag.duration; 19602 const segmentFraction = Math.min(this.config.maxFragLookUpTolerance * 2, fragDuration * 0.25); 19603 const start = Math.max(Math.min(frag.start - segmentFraction, bufferInfo.end - segmentFraction), currentTime + segmentFraction); 19604 if (frag.start - start > segmentFraction) { 19605 this.flushMainBuffer(start, frag.start); 19606 } 19607 } 19608 getFwdBufferInfo(bufferable, type) { 19609 const pos = this.getLoadPosition(); 19610 if (!isFiniteNumber(pos)) { 19611 return null; 19612 } 19613 return this.getFwdBufferInfoAtPos(bufferable, pos, type); 19614 } 19615 getFwdBufferInfoAtPos(bufferable, pos, type) { 19616 const { 19617 config: { 19618 maxBufferHole 19619 } 19620 } = this; 19621 const bufferInfo = BufferHelper.bufferInfo(bufferable, pos, maxBufferHole); 19622 if (bufferInfo.len === 0 && bufferInfo.nextStart !== void 0) { 19623 const bufferedFragAtPos = this.fragmentTracker.getBufferedFrag(pos, type); 19624 if (bufferedFragAtPos && bufferInfo.nextStart < bufferedFragAtPos.end) { 19625 return BufferHelper.bufferInfo(bufferable, pos, Math.max(bufferInfo.nextStart, maxBufferHole)); 19626 } 19627 } 19628 return bufferInfo; 19629 } 19630 getMaxBufferLength(levelBitrate) { 19631 const { 19632 config 19633 } = this; 19634 let maxBufLen; 19635 if (levelBitrate) { 19636 maxBufLen = Math.max(8 * config.maxBufferSize / levelBitrate, config.maxBufferLength); 19637 } else { 19638 maxBufLen = config.maxBufferLength; 19639 } 19640 return Math.min(maxBufLen, config.maxMaxBufferLength); 19641 } 19642 reduceMaxBufferLength(threshold, fragDuration) { 19643 const config = this.config; 19644 const minLength = Math.max(Math.min(threshold - fragDuration, config.maxBufferLength), fragDuration); 19645 const reducedLength = Math.max(threshold - fragDuration * 3, config.maxMaxBufferLength / 2, minLength); 19646 if (reducedLength >= minLength) { 19647 config.maxMaxBufferLength = reducedLength; 19648 this.warn(`Reduce max buffer length to ${reducedLength}s`); 19649 return true; 19650 } 19651 return false; 19652 } 19653 getAppendedFrag(position2, playlistType = PlaylistLevelType.MAIN) { 19654 const fragOrPart = this.fragmentTracker.getAppendedFrag(position2, PlaylistLevelType.MAIN); 19655 if (fragOrPart && "fragment" in fragOrPart) { 19656 return fragOrPart.fragment; 19657 } 19658 return fragOrPart; 19659 } 19660 getNextFragment(pos, levelDetails) { 19661 const fragments = levelDetails.fragments; 19662 const fragLen = fragments.length; 19663 if (!fragLen) { 19664 return null; 19665 } 19666 const { 19667 config 19668 } = this; 19669 const start = fragments[0].start; 19670 let frag; 19671 if (levelDetails.live) { 19672 const initialLiveManifestSize = config.initialLiveManifestSize; 19673 if (fragLen < initialLiveManifestSize) { 19674 this.warn(`Not enough fragments to start playback (have: ${fragLen}, need: ${initialLiveManifestSize})`); 19675 return null; 19676 } 19677 if (!levelDetails.PTSKnown && !this.startFragRequested && this.startPosition === -1 || pos < start) { 19678 frag = this.getInitialLiveFragment(levelDetails, fragments); 19679 this.startPosition = this.nextLoadPosition = frag ? this.hls.liveSyncPosition || frag.start : pos; 19680 } 19681 } else if (pos <= start) { 19682 frag = fragments[0]; 19683 } 19684 if (!frag) { 19685 const end = config.lowLatencyMode ? levelDetails.partEnd : levelDetails.fragmentEnd; 19686 frag = this.getFragmentAtPosition(pos, end, levelDetails); 19687 } 19688 return this.mapToInitFragWhenRequired(frag); 19689 } 19690 isLoopLoading(frag, targetBufferTime) { 19691 const trackerState = this.fragmentTracker.getState(frag); 19692 return (trackerState === FragmentState.OK || trackerState === FragmentState.PARTIAL && !!frag.gap) && this.nextLoadPosition > targetBufferTime; 19693 } 19694 getNextFragmentLoopLoading(frag, levelDetails, bufferInfo, playlistType, maxBufLen) { 19695 const gapStart = frag.gap; 19696 const nextFragment = this.getNextFragment(this.nextLoadPosition, levelDetails); 19697 if (nextFragment === null) { 19698 return nextFragment; 19699 } 19700 frag = nextFragment; 19701 if (gapStart && frag && !frag.gap && bufferInfo.nextStart) { 19702 const nextbufferInfo = this.getFwdBufferInfoAtPos(this.mediaBuffer ? this.mediaBuffer : this.media, bufferInfo.nextStart, playlistType); 19703 if (nextbufferInfo !== null && bufferInfo.len + nextbufferInfo.len >= maxBufLen) { 19704 this.log(`buffer full after gaps in "${playlistType}" playlist starting at sn: ${frag.sn}`); 19705 return null; 19706 } 19707 } 19708 return frag; 19709 } 19710 mapToInitFragWhenRequired(frag) { 19711 if (frag != null && frag.initSegment && !(frag != null && frag.initSegment.data) && !this.bitrateTest) { 19712 return frag.initSegment; 19713 } 19714 return frag; 19715 } 19716 getNextPart(partList, frag, targetBufferTime) { 19717 let nextPart = -1; 19718 let contiguous = false; 19719 let independentAttrOmitted = true; 19720 for (let i3 = 0, len = partList.length; i3 < len; i3++) { 19721 const part = partList[i3]; 19722 independentAttrOmitted = independentAttrOmitted && !part.independent; 19723 if (nextPart > -1 && targetBufferTime < part.start) { 19724 break; 19725 } 19726 const loaded = part.loaded; 19727 if (loaded) { 19728 nextPart = -1; 19729 } else if ((contiguous || part.independent || independentAttrOmitted) && part.fragment === frag) { 19730 nextPart = i3; 19731 } 19732 contiguous = loaded; 19733 } 19734 return nextPart; 19735 } 19736 loadedEndOfParts(partList, targetBufferTime) { 19737 const lastPart = partList[partList.length - 1]; 19738 return lastPart && targetBufferTime > lastPart.start && lastPart.loaded; 19739 } 19740 /* 19741 This method is used find the best matching first fragment for a live playlist. This fragment is used to calculate the 19742 "sliding" of the playlist, which is its offset from the start of playback. After sliding we can compute the real 19743 start and end times for each fragment in the playlist (after which this method will not need to be called). 19744 */ 19745 getInitialLiveFragment(levelDetails, fragments) { 19746 const fragPrevious = this.fragPrevious; 19747 let frag = null; 19748 if (fragPrevious) { 19749 if (levelDetails.hasProgramDateTime) { 19750 this.log(`Live playlist, switching playlist, load frag with same PDT: ${fragPrevious.programDateTime}`); 19751 frag = findFragmentByPDT(fragments, fragPrevious.endProgramDateTime, this.config.maxFragLookUpTolerance); 19752 } 19753 if (!frag) { 19754 const targetSN = fragPrevious.sn + 1; 19755 if (targetSN >= levelDetails.startSN && targetSN <= levelDetails.endSN) { 19756 const fragNext = fragments[targetSN - levelDetails.startSN]; 19757 if (fragPrevious.cc === fragNext.cc) { 19758 frag = fragNext; 19759 this.log(`Live playlist, switching playlist, load frag with next SN: ${frag.sn}`); 19760 } 19761 } 19762 if (!frag) { 19763 frag = findFragWithCC(fragments, fragPrevious.cc); 19764 if (frag) { 19765 this.log(`Live playlist, switching playlist, load frag with same CC: ${frag.sn}`); 19766 } 19767 } 19768 } 19769 } else { 19770 const liveStart = this.hls.liveSyncPosition; 19771 if (liveStart !== null) { 19772 frag = this.getFragmentAtPosition(liveStart, this.bitrateTest ? levelDetails.fragmentEnd : levelDetails.edge, levelDetails); 19773 } 19774 } 19775 return frag; 19776 } 19777 /* 19778 This method finds the best matching fragment given the provided position. 19779 */ 19780 getFragmentAtPosition(bufferEnd, end, levelDetails) { 19781 const { 19782 config 19783 } = this; 19784 let { 19785 fragPrevious 19786 } = this; 19787 let { 19788 fragments, 19789 endSN 19790 } = levelDetails; 19791 const { 19792 fragmentHint 19793 } = levelDetails; 19794 const { 19795 maxFragLookUpTolerance 19796 } = config; 19797 const partList = levelDetails.partList; 19798 const loadingParts = !!(config.lowLatencyMode && partList != null && partList.length && fragmentHint); 19799 if (loadingParts && fragmentHint && !this.bitrateTest) { 19800 fragments = fragments.concat(fragmentHint); 19801 endSN = fragmentHint.sn; 19802 } 19803 let frag; 19804 if (bufferEnd < end) { 19805 const lookupTolerance = bufferEnd > end - maxFragLookUpTolerance ? 0 : maxFragLookUpTolerance; 19806 frag = findFragmentByPTS(fragPrevious, fragments, bufferEnd, lookupTolerance); 19807 } else { 19808 frag = fragments[fragments.length - 1]; 19809 } 19810 if (frag) { 19811 const curSNIdx = frag.sn - levelDetails.startSN; 19812 const fragState = this.fragmentTracker.getState(frag); 19813 if (fragState === FragmentState.OK || fragState === FragmentState.PARTIAL && frag.gap) { 19814 fragPrevious = frag; 19815 } 19816 if (fragPrevious && frag.sn === fragPrevious.sn && (!loadingParts || partList[0].fragment.sn > frag.sn)) { 19817 const sameLevel = fragPrevious && frag.level === fragPrevious.level; 19818 if (sameLevel) { 19819 const nextFrag = fragments[curSNIdx + 1]; 19820 if (frag.sn < endSN && this.fragmentTracker.getState(nextFrag) !== FragmentState.OK) { 19821 frag = nextFrag; 19822 } else { 19823 frag = null; 19824 } 19825 } 19826 } 19827 } 19828 return frag; 19829 } 19830 synchronizeToLiveEdge(levelDetails) { 19831 const { 19832 config, 19833 media 19834 } = this; 19835 if (!media) { 19836 return; 19837 } 19838 const liveSyncPosition = this.hls.liveSyncPosition; 19839 const currentTime = media.currentTime; 19840 const start = levelDetails.fragments[0].start; 19841 const end = levelDetails.edge; 19842 const withinSlidingWindow = currentTime >= start - config.maxFragLookUpTolerance && currentTime <= end; 19843 if (liveSyncPosition !== null && media.duration > liveSyncPosition && (currentTime < liveSyncPosition || !withinSlidingWindow)) { 19844 const maxLatency = config.liveMaxLatencyDuration !== void 0 ? config.liveMaxLatencyDuration : config.liveMaxLatencyDurationCount * levelDetails.targetduration; 19845 if (!withinSlidingWindow && media.readyState < 4 || currentTime < end - maxLatency) { 19846 if (!this.loadedmetadata) { 19847 this.nextLoadPosition = liveSyncPosition; 19848 } 19849 if (media.readyState) { 19850 this.warn(`Playback: ${currentTime.toFixed(3)} is located too far from the end of live sliding playlist: ${end}, reset currentTime to : ${liveSyncPosition.toFixed(3)}`); 19851 media.currentTime = liveSyncPosition; 19852 } 19853 } 19854 } 19855 } 19856 alignPlaylists(details, previousDetails, switchDetails) { 19857 const length2 = details.fragments.length; 19858 if (!length2) { 19859 this.warn(`No fragments in live playlist`); 19860 return 0; 19861 } 19862 const slidingStart = details.fragments[0].start; 19863 const firstLevelLoad = !previousDetails; 19864 const aligned = details.alignedSliding && isFiniteNumber(slidingStart); 19865 if (firstLevelLoad || !aligned && !slidingStart) { 19866 const { 19867 fragPrevious 19868 } = this; 19869 alignStream(fragPrevious, switchDetails, details); 19870 const alignedSlidingStart = details.fragments[0].start; 19871 this.log(`Live playlist sliding: ${alignedSlidingStart.toFixed(2)} start-sn: ${previousDetails ? previousDetails.startSN : "na"}->${details.startSN} prev-sn: ${fragPrevious ? fragPrevious.sn : "na"} fragments: ${length2}`); 19872 return alignedSlidingStart; 19873 } 19874 return slidingStart; 19875 } 19876 waitForCdnTuneIn(details) { 19877 const advancePartLimit = 3; 19878 return details.live && details.canBlockReload && details.partTarget && details.tuneInGoal > Math.max(details.partHoldBack, details.partTarget * advancePartLimit); 19879 } 19880 setStartPosition(details, sliding) { 19881 let startPosition = this.startPosition; 19882 if (startPosition < sliding) { 19883 startPosition = -1; 19884 } 19885 if (startPosition === -1 || this.lastCurrentTime === -1) { 19886 const offsetInMultivariantPlaylist = this.startTimeOffset !== null; 19887 const startTimeOffset = offsetInMultivariantPlaylist ? this.startTimeOffset : details.startTimeOffset; 19888 if (startTimeOffset !== null && isFiniteNumber(startTimeOffset)) { 19889 startPosition = sliding + startTimeOffset; 19890 if (startTimeOffset < 0) { 19891 startPosition += details.totalduration; 19892 } 19893 startPosition = Math.min(Math.max(sliding, startPosition), sliding + details.totalduration); 19894 this.log(`Start time offset ${startTimeOffset} found in ${offsetInMultivariantPlaylist ? "multivariant" : "media"} playlist, adjust startPosition to ${startPosition}`); 19895 this.startPosition = startPosition; 19896 } else if (details.live) { 19897 startPosition = this.hls.liveSyncPosition || sliding; 19898 } else { 19899 this.startPosition = startPosition = 0; 19900 } 19901 this.lastCurrentTime = startPosition; 19902 } 19903 this.nextLoadPosition = startPosition; 19904 } 19905 getLoadPosition() { 19906 const { 19907 media 19908 } = this; 19909 let pos = 0; 19910 if (this.loadedmetadata && media) { 19911 pos = media.currentTime; 19912 } else if (this.nextLoadPosition) { 19913 pos = this.nextLoadPosition; 19914 } 19915 return pos; 19916 } 19917 handleFragLoadAborted(frag, part) { 19918 if (this.transmuxer && frag.sn !== "initSegment" && frag.stats.aborted) { 19919 this.warn(`Fragment ${frag.sn}${part ? " part " + part.index : ""} of level ${frag.level} was aborted`); 19920 this.resetFragmentLoading(frag); 19921 } 19922 } 19923 resetFragmentLoading(frag) { 19924 if (!this.fragCurrent || !this.fragContextChanged(frag) && this.state !== State.FRAG_LOADING_WAITING_RETRY) { 19925 this.state = State.IDLE; 19926 } 19927 } 19928 onFragmentOrKeyLoadError(filterType, data) { 19929 if (data.chunkMeta && !data.frag) { 19930 const context = this.getCurrentContext(data.chunkMeta); 19931 if (context) { 19932 data.frag = context.frag; 19933 } 19934 } 19935 const frag = data.frag; 19936 if (!frag || frag.type !== filterType || !this.levels) { 19937 return; 19938 } 19939 if (this.fragContextChanged(frag)) { 19940 var _this$fragCurrent2; 19941 this.warn(`Frag load error must match current frag to retry ${frag.url} > ${(_this$fragCurrent2 = this.fragCurrent) == null ? void 0 : _this$fragCurrent2.url}`); 19942 return; 19943 } 19944 const gapTagEncountered = data.details === ErrorDetails.FRAG_GAP; 19945 if (gapTagEncountered) { 19946 this.fragmentTracker.fragBuffered(frag, true); 19947 } 19948 const errorAction = data.errorAction; 19949 const { 19950 action, 19951 retryCount = 0, 19952 retryConfig 19953 } = errorAction || {}; 19954 if (errorAction && action === NetworkErrorAction.RetryRequest && retryConfig) { 19955 this.resetStartWhenNotLoaded(this.levelLastLoaded); 19956 const delay2 = getRetryDelay(retryConfig, retryCount); 19957 this.warn(`Fragment ${frag.sn} of ${filterType} ${frag.level} errored with ${data.details}, retrying loading ${retryCount + 1}/${retryConfig.maxNumRetry} in ${delay2}ms`); 19958 errorAction.resolved = true; 19959 this.retryDate = self.performance.now() + delay2; 19960 this.state = State.FRAG_LOADING_WAITING_RETRY; 19961 } else if (retryConfig && errorAction) { 19962 this.resetFragmentErrors(filterType); 19963 if (retryCount < retryConfig.maxNumRetry) { 19964 if (!gapTagEncountered && action !== NetworkErrorAction.RemoveAlternatePermanently) { 19965 errorAction.resolved = true; 19966 } 19967 } else { 19968 logger.warn(`${data.details} reached or exceeded max retry (${retryCount})`); 19969 return; 19970 } 19971 } else if ((errorAction == null ? void 0 : errorAction.action) === NetworkErrorAction.SendAlternateToPenaltyBox) { 19972 this.state = State.WAITING_LEVEL; 19973 } else { 19974 this.state = State.ERROR; 19975 } 19976 this.tickImmediate(); 19977 } 19978 reduceLengthAndFlushBuffer(data) { 19979 if (this.state === State.PARSING || this.state === State.PARSED) { 19980 const frag = data.frag; 19981 const playlistType = data.parent; 19982 const bufferedInfo = this.getFwdBufferInfo(this.mediaBuffer, playlistType); 19983 const buffered = bufferedInfo && bufferedInfo.len > 0.5; 19984 if (buffered) { 19985 this.reduceMaxBufferLength(bufferedInfo.len, (frag == null ? void 0 : frag.duration) || 10); 19986 } 19987 const flushBuffer = !buffered; 19988 if (flushBuffer) { 19989 this.warn(`Buffer full error while media.currentTime is not buffered, flush ${playlistType} buffer`); 19990 } 19991 if (frag) { 19992 this.fragmentTracker.removeFragment(frag); 19993 this.nextLoadPosition = frag.start; 19994 } 19995 this.resetLoadingState(); 19996 return flushBuffer; 19997 } 19998 return false; 19999 } 20000 resetFragmentErrors(filterType) { 20001 if (filterType === PlaylistLevelType.AUDIO) { 20002 this.fragCurrent = null; 20003 } 20004 if (!this.loadedmetadata) { 20005 this.startFragRequested = false; 20006 } 20007 if (this.state !== State.STOPPED) { 20008 this.state = State.IDLE; 20009 } 20010 } 20011 afterBufferFlushed(media, bufferType, playlistType) { 20012 if (!media) { 20013 return; 20014 } 20015 const bufferedTimeRanges = BufferHelper.getBuffered(media); 20016 this.fragmentTracker.detectEvictedFragments(bufferType, bufferedTimeRanges, playlistType); 20017 if (this.state === State.ENDED) { 20018 this.resetLoadingState(); 20019 } 20020 } 20021 resetLoadingState() { 20022 this.log("Reset loading state"); 20023 this.fragCurrent = null; 20024 this.fragPrevious = null; 20025 this.state = State.IDLE; 20026 } 20027 resetStartWhenNotLoaded(level) { 20028 if (!this.loadedmetadata) { 20029 this.startFragRequested = false; 20030 const details = level ? level.details : null; 20031 if (details != null && details.live) { 20032 this.startPosition = -1; 20033 this.setStartPosition(details, 0); 20034 this.resetLoadingState(); 20035 } else { 20036 this.nextLoadPosition = this.startPosition; 20037 } 20038 } 20039 } 20040 resetWhenMissingContext(chunkMeta) { 20041 this.warn(`The loading context changed while buffering fragment ${chunkMeta.sn} of level ${chunkMeta.level}. This chunk will not be buffered.`); 20042 this.removeUnbufferedFrags(); 20043 this.resetStartWhenNotLoaded(this.levelLastLoaded); 20044 this.resetLoadingState(); 20045 } 20046 removeUnbufferedFrags(start = 0) { 20047 this.fragmentTracker.removeFragmentsInRange(start, Infinity, this.playlistType, false, true); 20048 } 20049 updateLevelTiming(frag, part, level, partial) { 20050 var _this$transmuxer; 20051 const details = level.details; 20052 if (!details) { 20053 this.warn("level.details undefined"); 20054 return; 20055 } 20056 const parsed = Object.keys(frag.elementaryStreams).reduce((result, type) => { 20057 const info = frag.elementaryStreams[type]; 20058 if (info) { 20059 const parsedDuration = info.endPTS - info.startPTS; 20060 if (parsedDuration <= 0) { 20061 this.warn(`Could not parse fragment ${frag.sn} ${type} duration reliably (${parsedDuration})`); 20062 return result || false; 20063 } 20064 const drift = partial ? 0 : updateFragPTSDTS(details, frag, info.startPTS, info.endPTS, info.startDTS, info.endDTS); 20065 this.hls.trigger(Events.LEVEL_PTS_UPDATED, { 20066 details, 20067 level, 20068 drift, 20069 type, 20070 frag, 20071 start: info.startPTS, 20072 end: info.endPTS 20073 }); 20074 return true; 20075 } 20076 return result; 20077 }, false); 20078 if (!parsed && ((_this$transmuxer = this.transmuxer) == null ? void 0 : _this$transmuxer.error) === null) { 20079 const error = new Error(`Found no media in fragment ${frag.sn} of level ${frag.level} resetting transmuxer to fallback to playlist timing`); 20080 if (level.fragmentError === 0) { 20081 level.fragmentError++; 20082 frag.gap = true; 20083 this.fragmentTracker.removeFragment(frag); 20084 this.fragmentTracker.fragBuffered(frag, true); 20085 } 20086 this.warn(error.message); 20087 this.hls.trigger(Events.ERROR, { 20088 type: ErrorTypes.MEDIA_ERROR, 20089 details: ErrorDetails.FRAG_PARSING_ERROR, 20090 fatal: false, 20091 error, 20092 frag, 20093 reason: `Found no media in msn ${frag.sn} of level "${level.url}"` 20094 }); 20095 if (!this.hls) { 20096 return; 20097 } 20098 this.resetTransmuxer(); 20099 } 20100 this.state = State.PARSED; 20101 this.hls.trigger(Events.FRAG_PARSED, { 20102 frag, 20103 part 20104 }); 20105 } 20106 resetTransmuxer() { 20107 if (this.transmuxer) { 20108 this.transmuxer.destroy(); 20109 this.transmuxer = null; 20110 } 20111 } 20112 recoverWorkerError(data) { 20113 if (data.event === "demuxerWorker") { 20114 this.fragmentTracker.removeAllFragments(); 20115 this.resetTransmuxer(); 20116 this.resetStartWhenNotLoaded(this.levelLastLoaded); 20117 this.resetLoadingState(); 20118 } 20119 } 20120 set state(nextState) { 20121 const previousState = this._state; 20122 if (previousState !== nextState) { 20123 this._state = nextState; 20124 this.log(`${previousState}->${nextState}`); 20125 } 20126 } 20127 get state() { 20128 return this._state; 20129 } 20130}; 20131var ChunkCache = class { 20132 constructor() { 20133 this.chunks = []; 20134 this.dataLength = 0; 20135 } 20136 push(chunk) { 20137 this.chunks.push(chunk); 20138 this.dataLength += chunk.length; 20139 } 20140 flush() { 20141 const { 20142 chunks, 20143 dataLength 20144 } = this; 20145 let result; 20146 if (!chunks.length) { 20147 return new Uint8Array(0); 20148 } else if (chunks.length === 1) { 20149 result = chunks[0]; 20150 } else { 20151 result = concatUint8Arrays(chunks, dataLength); 20152 } 20153 this.reset(); 20154 return result; 20155 } 20156 reset() { 20157 this.chunks.length = 0; 20158 this.dataLength = 0; 20159 } 20160}; 20161function concatUint8Arrays(chunks, dataLength) { 20162 const result = new Uint8Array(dataLength); 20163 let offset = 0; 20164 for (let i3 = 0; i3 < chunks.length; i3++) { 20165 const chunk = chunks[i3]; 20166 result.set(chunk, offset); 20167 offset += chunk.length; 20168 } 20169 return result; 20170} 20171function hasUMDWorker() { 20172 return typeof __HLS_WORKER_BUNDLE__ === "function"; 20173} 20174function injectWorker() { 20175 const blob = new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`], { 20176 type: "text/javascript" 20177 }); 20178 const objectURL = self.URL.createObjectURL(blob); 20179 const worker = new self.Worker(objectURL); 20180 return { 20181 worker, 20182 objectURL 20183 }; 20184} 20185function loadWorker(path) { 20186 const scriptURL = new self.URL(path, self.location.href).href; 20187 const worker = new self.Worker(scriptURL); 20188 return { 20189 worker, 20190 scriptURL 20191 }; 20192} 20193function dummyTrack(type = "", inputTimeScale = 9e4) { 20194 return { 20195 type, 20196 id: -1, 20197 pid: -1, 20198 inputTimeScale, 20199 sequenceNumber: -1, 20200 samples: [], 20201 dropped: 0 20202 }; 20203} 20204var BaseAudioDemuxer = class { 20205 constructor() { 20206 this._audioTrack = void 0; 20207 this._id3Track = void 0; 20208 this.frameIndex = 0; 20209 this.cachedData = null; 20210 this.basePTS = null; 20211 this.initPTS = null; 20212 this.lastPTS = null; 20213 } 20214 resetInitSegment(initSegment, audioCodec, videoCodec, trackDuration) { 20215 this._id3Track = { 20216 type: "id3", 20217 id: 3, 20218 pid: -1, 20219 inputTimeScale: 9e4, 20220 sequenceNumber: 0, 20221 samples: [], 20222 dropped: 0 20223 }; 20224 } 20225 resetTimeStamp(deaultTimestamp) { 20226 this.initPTS = deaultTimestamp; 20227 this.resetContiguity(); 20228 } 20229 resetContiguity() { 20230 this.basePTS = null; 20231 this.lastPTS = null; 20232 this.frameIndex = 0; 20233 } 20234 canParse(data, offset) { 20235 return false; 20236 } 20237 appendFrame(track, data, offset) { 20238 } 20239 // feed incoming data to the front of the parsing pipeline 20240 demux(data, timeOffset) { 20241 if (this.cachedData) { 20242 data = appendUint8Array(this.cachedData, data); 20243 this.cachedData = null; 20244 } 20245 let id3Data = getID3Data(data, 0); 20246 let offset = id3Data ? id3Data.length : 0; 20247 let lastDataIndex; 20248 const track = this._audioTrack; 20249 const id3Track = this._id3Track; 20250 const timestamp = id3Data ? getTimeStamp(id3Data) : void 0; 20251 const length2 = data.length; 20252 if (this.basePTS === null || this.frameIndex === 0 && isFiniteNumber(timestamp)) { 20253 this.basePTS = initPTSFn(timestamp, timeOffset, this.initPTS); 20254 this.lastPTS = this.basePTS; 20255 } 20256 if (this.lastPTS === null) { 20257 this.lastPTS = this.basePTS; 20258 } 20259 if (id3Data && id3Data.length > 0) { 20260 id3Track.samples.push({ 20261 pts: this.lastPTS, 20262 dts: this.lastPTS, 20263 data: id3Data, 20264 type: MetadataSchema.audioId3, 20265 duration: Number.POSITIVE_INFINITY 20266 }); 20267 } 20268 while (offset < length2) { 20269 if (this.canParse(data, offset)) { 20270 const frame = this.appendFrame(track, data, offset); 20271 if (frame) { 20272 this.frameIndex++; 20273 this.lastPTS = frame.sample.pts; 20274 offset += frame.length; 20275 lastDataIndex = offset; 20276 } else { 20277 offset = length2; 20278 } 20279 } else if (canParse$2(data, offset)) { 20280 id3Data = getID3Data(data, offset); 20281 id3Track.samples.push({ 20282 pts: this.lastPTS, 20283 dts: this.lastPTS, 20284 data: id3Data, 20285 type: MetadataSchema.audioId3, 20286 duration: Number.POSITIVE_INFINITY 20287 }); 20288 offset += id3Data.length; 20289 lastDataIndex = offset; 20290 } else { 20291 offset++; 20292 } 20293 if (offset === length2 && lastDataIndex !== length2) { 20294 const partialData = sliceUint8(data, lastDataIndex); 20295 if (this.cachedData) { 20296 this.cachedData = appendUint8Array(this.cachedData, partialData); 20297 } else { 20298 this.cachedData = partialData; 20299 } 20300 } 20301 } 20302 return { 20303 audioTrack: track, 20304 videoTrack: dummyTrack(), 20305 id3Track, 20306 textTrack: dummyTrack() 20307 }; 20308 } 20309 demuxSampleAes(data, keyData, timeOffset) { 20310 return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`)); 20311 } 20312 flush(timeOffset) { 20313 const cachedData = this.cachedData; 20314 if (cachedData) { 20315 this.cachedData = null; 20316 this.demux(cachedData, 0); 20317 } 20318 return { 20319 audioTrack: this._audioTrack, 20320 videoTrack: dummyTrack(), 20321 id3Track: this._id3Track, 20322 textTrack: dummyTrack() 20323 }; 20324 } 20325 destroy() { 20326 } 20327}; 20328var initPTSFn = (timestamp, timeOffset, initPTS) => { 20329 if (isFiniteNumber(timestamp)) { 20330 return timestamp * 90; 20331 } 20332 const init90kHz = initPTS ? initPTS.baseTime * 9e4 / initPTS.timescale : 0; 20333 return timeOffset * 9e4 + init90kHz; 20334}; 20335function getAudioConfig(observer2, data, offset, audioCodec) { 20336 let adtsObjectType; 20337 let adtsExtensionSamplingIndex; 20338 let adtsChannelConfig; 20339 let config; 20340 const userAgent = navigator.userAgent.toLowerCase(); 20341 const manifestCodec = audioCodec; 20342 const adtsSamplingRates = [96e3, 88200, 64e3, 48e3, 44100, 32e3, 24e3, 22050, 16e3, 12e3, 11025, 8e3, 7350]; 20343 adtsObjectType = ((data[offset + 2] & 192) >>> 6) + 1; 20344 const adtsSamplingIndex = (data[offset + 2] & 60) >>> 2; 20345 if (adtsSamplingIndex > adtsSamplingRates.length - 1) { 20346 const error = new Error(`invalid ADTS sampling index:${adtsSamplingIndex}`); 20347 observer2.emit(Events.ERROR, Events.ERROR, { 20348 type: ErrorTypes.MEDIA_ERROR, 20349 details: ErrorDetails.FRAG_PARSING_ERROR, 20350 fatal: true, 20351 error, 20352 reason: error.message 20353 }); 20354 return; 20355 } 20356 adtsChannelConfig = (data[offset + 2] & 1) << 2; 20357 adtsChannelConfig |= (data[offset + 3] & 192) >>> 6; 20358 logger.log(`manifest codec:${audioCodec}, ADTS type:${adtsObjectType}, samplingIndex:${adtsSamplingIndex}`); 20359 if (/firefox/i.test(userAgent)) { 20360 if (adtsSamplingIndex >= 6) { 20361 adtsObjectType = 5; 20362 config = new Array(4); 20363 adtsExtensionSamplingIndex = adtsSamplingIndex - 3; 20364 } else { 20365 adtsObjectType = 2; 20366 config = new Array(2); 20367 adtsExtensionSamplingIndex = adtsSamplingIndex; 20368 } 20369 } else if (userAgent.indexOf("android") !== -1) { 20370 adtsObjectType = 2; 20371 config = new Array(2); 20372 adtsExtensionSamplingIndex = adtsSamplingIndex; 20373 } else { 20374 adtsObjectType = 5; 20375 config = new Array(4); 20376 if (audioCodec && (audioCodec.indexOf("mp4a.40.29") !== -1 || audioCodec.indexOf("mp4a.40.5") !== -1) || !audioCodec && adtsSamplingIndex >= 6) { 20377 adtsExtensionSamplingIndex = adtsSamplingIndex - 3; 20378 } else { 20379 if (audioCodec && audioCodec.indexOf("mp4a.40.2") !== -1 && (adtsSamplingIndex >= 6 && adtsChannelConfig === 1 || /vivaldi/i.test(userAgent)) || !audioCodec && adtsChannelConfig === 1) { 20380 adtsObjectType = 2; 20381 config = new Array(2); 20382 } 20383 adtsExtensionSamplingIndex = adtsSamplingIndex; 20384 } 20385 } 20386 config[0] = adtsObjectType << 3; 20387 config[0] |= (adtsSamplingIndex & 14) >> 1; 20388 config[1] |= (adtsSamplingIndex & 1) << 7; 20389 config[1] |= adtsChannelConfig << 3; 20390 if (adtsObjectType === 5) { 20391 config[1] |= (adtsExtensionSamplingIndex & 14) >> 1; 20392 config[2] = (adtsExtensionSamplingIndex & 1) << 7; 20393 config[2] |= 2 << 2; 20394 config[3] = 0; 20395 } 20396 return { 20397 config, 20398 samplerate: adtsSamplingRates[adtsSamplingIndex], 20399 channelCount: adtsChannelConfig, 20400 codec: "mp4a.40." + adtsObjectType, 20401 manifestCodec 20402 }; 20403} 20404function isHeaderPattern$1(data, offset) { 20405 return data[offset] === 255 && (data[offset + 1] & 246) === 240; 20406} 20407function getHeaderLength(data, offset) { 20408 return data[offset + 1] & 1 ? 7 : 9; 20409} 20410function getFullFrameLength(data, offset) { 20411 return (data[offset + 3] & 3) << 11 | data[offset + 4] << 3 | (data[offset + 5] & 224) >>> 5; 20412} 20413function canGetFrameLength(data, offset) { 20414 return offset + 5 < data.length; 20415} 20416function isHeader$1(data, offset) { 20417 return offset + 1 < data.length && isHeaderPattern$1(data, offset); 20418} 20419function canParse$1(data, offset) { 20420 return canGetFrameLength(data, offset) && isHeaderPattern$1(data, offset) && getFullFrameLength(data, offset) <= data.length - offset; 20421} 20422function probe$1(data, offset) { 20423 if (isHeader$1(data, offset)) { 20424 const headerLength = getHeaderLength(data, offset); 20425 if (offset + headerLength >= data.length) { 20426 return false; 20427 } 20428 const frameLength = getFullFrameLength(data, offset); 20429 if (frameLength <= headerLength) { 20430 return false; 20431 } 20432 const newOffset = offset + frameLength; 20433 return newOffset === data.length || isHeader$1(data, newOffset); 20434 } 20435 return false; 20436} 20437function initTrackConfig(track, observer2, data, offset, audioCodec) { 20438 if (!track.samplerate) { 20439 const config = getAudioConfig(observer2, data, offset, audioCodec); 20440 if (!config) { 20441 return; 20442 } 20443 track.config = config.config; 20444 track.samplerate = config.samplerate; 20445 track.channelCount = config.channelCount; 20446 track.codec = config.codec; 20447 track.manifestCodec = config.manifestCodec; 20448 logger.log(`parsed codec:${track.codec}, rate:${config.samplerate}, channels:${config.channelCount}`); 20449 } 20450} 20451function getFrameDuration(samplerate) { 20452 return 1024 * 9e4 / samplerate; 20453} 20454function parseFrameHeader(data, offset) { 20455 const headerLength = getHeaderLength(data, offset); 20456 if (offset + headerLength <= data.length) { 20457 const frameLength = getFullFrameLength(data, offset) - headerLength; 20458 if (frameLength > 0) { 20459 return { 20460 headerLength, 20461 frameLength 20462 }; 20463 } 20464 } 20465} 20466function appendFrame$2(track, data, offset, pts, frameIndex) { 20467 const frameDuration = getFrameDuration(track.samplerate); 20468 const stamp = pts + frameIndex * frameDuration; 20469 const header = parseFrameHeader(data, offset); 20470 let unit; 20471 if (header) { 20472 const { 20473 frameLength, 20474 headerLength 20475 } = header; 20476 const _length = headerLength + frameLength; 20477 const missing = Math.max(0, offset + _length - data.length); 20478 if (missing) { 20479 unit = new Uint8Array(_length - headerLength); 20480 unit.set(data.subarray(offset + headerLength, data.length), 0); 20481 } else { 20482 unit = data.subarray(offset + headerLength, offset + _length); 20483 } 20484 const _sample = { 20485 unit, 20486 pts: stamp 20487 }; 20488 if (!missing) { 20489 track.samples.push(_sample); 20490 } 20491 return { 20492 sample: _sample, 20493 length: _length, 20494 missing 20495 }; 20496 } 20497 const length2 = data.length - offset; 20498 unit = new Uint8Array(length2); 20499 unit.set(data.subarray(offset, data.length), 0); 20500 const sample = { 20501 unit, 20502 pts: stamp 20503 }; 20504 return { 20505 sample, 20506 length: length2, 20507 missing: -1 20508 }; 20509} 20510var chromeVersion$1 = null; 20511var BitratesMap = [32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160]; 20512var SamplingRateMap = [44100, 48e3, 32e3, 22050, 24e3, 16e3, 11025, 12e3, 8e3]; 20513var SamplesCoefficients = [ 20514 // MPEG 2.5 20515 [ 20516 0, 20517 // Reserved 20518 72, 20519 // Layer3 20520 144, 20521 // Layer2 20522 12 20523 // Layer1 20524 ], 20525 // Reserved 20526 [ 20527 0, 20528 // Reserved 20529 0, 20530 // Layer3 20531 0, 20532 // Layer2 20533 0 20534 // Layer1 20535 ], 20536 // MPEG 2 20537 [ 20538 0, 20539 // Reserved 20540 72, 20541 // Layer3 20542 144, 20543 // Layer2 20544 12 20545 // Layer1 20546 ], 20547 // MPEG 1 20548 [ 20549 0, 20550 // Reserved 20551 144, 20552 // Layer3 20553 144, 20554 // Layer2 20555 12 20556 // Layer1 20557 ] 20558]; 20559var BytesInSlot = [ 20560 0, 20561 // Reserved 20562 1, 20563 // Layer3 20564 1, 20565 // Layer2 20566 4 20567 // Layer1 20568]; 20569function appendFrame$1(track, data, offset, pts, frameIndex) { 20570 if (offset + 24 > data.length) { 20571 return; 20572 } 20573 const header = parseHeader(data, offset); 20574 if (header && offset + header.frameLength <= data.length) { 20575 const frameDuration = header.samplesPerFrame * 9e4 / header.sampleRate; 20576 const stamp = pts + frameIndex * frameDuration; 20577 const sample = { 20578 unit: data.subarray(offset, offset + header.frameLength), 20579 pts: stamp, 20580 dts: stamp 20581 }; 20582 track.config = []; 20583 track.channelCount = header.channelCount; 20584 track.samplerate = header.sampleRate; 20585 track.samples.push(sample); 20586 return { 20587 sample, 20588 length: header.frameLength, 20589 missing: 0 20590 }; 20591 } 20592} 20593function parseHeader(data, offset) { 20594 const mpegVersion = data[offset + 1] >> 3 & 3; 20595 const mpegLayer = data[offset + 1] >> 1 & 3; 20596 const bitRateIndex = data[offset + 2] >> 4 & 15; 20597 const sampleRateIndex = data[offset + 2] >> 2 & 3; 20598 if (mpegVersion !== 1 && bitRateIndex !== 0 && bitRateIndex !== 15 && sampleRateIndex !== 3) { 20599 const paddingBit = data[offset + 2] >> 1 & 1; 20600 const channelMode = data[offset + 3] >> 6; 20601 const columnInBitrates = mpegVersion === 3 ? 3 - mpegLayer : mpegLayer === 3 ? 3 : 4; 20602 const bitRate = BitratesMap[columnInBitrates * 14 + bitRateIndex - 1] * 1e3; 20603 const columnInSampleRates = mpegVersion === 3 ? 0 : mpegVersion === 2 ? 1 : 2; 20604 const sampleRate = SamplingRateMap[columnInSampleRates * 3 + sampleRateIndex]; 20605 const channelCount = channelMode === 3 ? 1 : 2; 20606 const sampleCoefficient = SamplesCoefficients[mpegVersion][mpegLayer]; 20607 const bytesInSlot = BytesInSlot[mpegLayer]; 20608 const samplesPerFrame = sampleCoefficient * 8 * bytesInSlot; 20609 const frameLength = Math.floor(sampleCoefficient * bitRate / sampleRate + paddingBit) * bytesInSlot; 20610 if (chromeVersion$1 === null) { 20611 const userAgent = navigator.userAgent || ""; 20612 const result = userAgent.match(/Chrome\/(\d+)/i); 20613 chromeVersion$1 = result ? parseInt(result[1]) : 0; 20614 } 20615 const needChromeFix = !!chromeVersion$1 && chromeVersion$1 <= 87; 20616 if (needChromeFix && mpegLayer === 2 && bitRate >= 224e3 && channelMode === 0) { 20617 data[offset + 3] = data[offset + 3] | 128; 20618 } 20619 return { 20620 sampleRate, 20621 channelCount, 20622 frameLength, 20623 samplesPerFrame 20624 }; 20625 } 20626} 20627function isHeaderPattern(data, offset) { 20628 return data[offset] === 255 && (data[offset + 1] & 224) === 224 && (data[offset + 1] & 6) !== 0; 20629} 20630function isHeader(data, offset) { 20631 return offset + 1 < data.length && isHeaderPattern(data, offset); 20632} 20633function canParse(data, offset) { 20634 const headerSize = 4; 20635 return isHeaderPattern(data, offset) && headerSize <= data.length - offset; 20636} 20637function probe(data, offset) { 20638 if (offset + 1 < data.length && isHeaderPattern(data, offset)) { 20639 const headerLength = 4; 20640 const header = parseHeader(data, offset); 20641 let frameLength = headerLength; 20642 if (header != null && header.frameLength) { 20643 frameLength = header.frameLength; 20644 } 20645 const newOffset = offset + frameLength; 20646 return newOffset === data.length || isHeader(data, newOffset); 20647 } 20648 return false; 20649} 20650var AACDemuxer = class extends BaseAudioDemuxer { 20651 constructor(observer2, config) { 20652 super(); 20653 this.observer = void 0; 20654 this.config = void 0; 20655 this.observer = observer2; 20656 this.config = config; 20657 } 20658 resetInitSegment(initSegment, audioCodec, videoCodec, trackDuration) { 20659 super.resetInitSegment(initSegment, audioCodec, videoCodec, trackDuration); 20660 this._audioTrack = { 20661 container: "audio/adts", 20662 type: "audio", 20663 id: 2, 20664 pid: -1, 20665 sequenceNumber: 0, 20666 segmentCodec: "aac", 20667 samples: [], 20668 manifestCodec: audioCodec, 20669 duration: trackDuration, 20670 inputTimeScale: 9e4, 20671 dropped: 0 20672 }; 20673 } 20674 // Source for probe info - https://wiki.multimedia.cx/index.php?title=ADTS 20675 static probe(data) { 20676 if (!data) { 20677 return false; 20678 } 20679 const id3Data = getID3Data(data, 0); 20680 let offset = (id3Data == null ? void 0 : id3Data.length) || 0; 20681 if (probe(data, offset)) { 20682 return false; 20683 } 20684 for (let length2 = data.length; offset < length2; offset++) { 20685 if (probe$1(data, offset)) { 20686 logger.log("ADTS sync word found !"); 20687 return true; 20688 } 20689 } 20690 return false; 20691 } 20692 canParse(data, offset) { 20693 return canParse$1(data, offset); 20694 } 20695 appendFrame(track, data, offset) { 20696 initTrackConfig(track, this.observer, data, offset, track.manifestCodec); 20697 const frame = appendFrame$2(track, data, offset, this.basePTS, this.frameIndex); 20698 if (frame && frame.missing === 0) { 20699 return frame; 20700 } 20701 } 20702}; 20703var emsgSchemePattern = /\/emsg[-/]ID3/i; 20704var MP4Demuxer = class { 20705 constructor(observer2, config) { 20706 this.remainderData = null; 20707 this.timeOffset = 0; 20708 this.config = void 0; 20709 this.videoTrack = void 0; 20710 this.audioTrack = void 0; 20711 this.id3Track = void 0; 20712 this.txtTrack = void 0; 20713 this.config = config; 20714 } 20715 resetTimeStamp() { 20716 } 20717 resetInitSegment(initSegment, audioCodec, videoCodec, trackDuration) { 20718 const videoTrack = this.videoTrack = dummyTrack("video", 1); 20719 const audioTrack = this.audioTrack = dummyTrack("audio", 1); 20720 const captionTrack = this.txtTrack = dummyTrack("text", 1); 20721 this.id3Track = dummyTrack("id3", 1); 20722 this.timeOffset = 0; 20723 if (!(initSegment != null && initSegment.byteLength)) { 20724 return; 20725 } 20726 const initData = parseInitSegment(initSegment); 20727 if (initData.video) { 20728 const { 20729 id, 20730 timescale, 20731 codec 20732 } = initData.video; 20733 videoTrack.id = id; 20734 videoTrack.timescale = captionTrack.timescale = timescale; 20735 videoTrack.codec = codec; 20736 } 20737 if (initData.audio) { 20738 const { 20739 id, 20740 timescale, 20741 codec 20742 } = initData.audio; 20743 audioTrack.id = id; 20744 audioTrack.timescale = timescale; 20745 audioTrack.codec = codec; 20746 } 20747 captionTrack.id = RemuxerTrackIdConfig.text; 20748 videoTrack.sampleDuration = 0; 20749 videoTrack.duration = audioTrack.duration = trackDuration; 20750 } 20751 resetContiguity() { 20752 this.remainderData = null; 20753 } 20754 static probe(data) { 20755 return hasMoofData(data); 20756 } 20757 demux(data, timeOffset) { 20758 this.timeOffset = timeOffset; 20759 let videoSamples = data; 20760 const videoTrack = this.videoTrack; 20761 const textTrack = this.txtTrack; 20762 if (this.config.progressive) { 20763 if (this.remainderData) { 20764 videoSamples = appendUint8Array(this.remainderData, data); 20765 } 20766 const segmentedData = segmentValidRange(videoSamples); 20767 this.remainderData = segmentedData.remainder; 20768 videoTrack.samples = segmentedData.valid || new Uint8Array(); 20769 } else { 20770 videoTrack.samples = videoSamples; 20771 } 20772 const id3Track = this.extractID3Track(videoTrack, timeOffset); 20773 textTrack.samples = parseSamples(timeOffset, videoTrack); 20774 return { 20775 videoTrack, 20776 audioTrack: this.audioTrack, 20777 id3Track, 20778 textTrack: this.txtTrack 20779 }; 20780 } 20781 flush() { 20782 const timeOffset = this.timeOffset; 20783 const videoTrack = this.videoTrack; 20784 const textTrack = this.txtTrack; 20785 videoTrack.samples = this.remainderData || new Uint8Array(); 20786 this.remainderData = null; 20787 const id3Track = this.extractID3Track(videoTrack, this.timeOffset); 20788 textTrack.samples = parseSamples(timeOffset, videoTrack); 20789 return { 20790 videoTrack, 20791 audioTrack: dummyTrack(), 20792 id3Track, 20793 textTrack: dummyTrack() 20794 }; 20795 } 20796 extractID3Track(videoTrack, timeOffset) { 20797 const id3Track = this.id3Track; 20798 if (videoTrack.samples.length) { 20799 const emsgs = findBox(videoTrack.samples, ["emsg"]); 20800 if (emsgs) { 20801 emsgs.forEach((data) => { 20802 const emsgInfo = parseEmsg(data); 20803 if (emsgSchemePattern.test(emsgInfo.schemeIdUri)) { 20804 const pts = isFiniteNumber(emsgInfo.presentationTime) ? emsgInfo.presentationTime / emsgInfo.timeScale : timeOffset + emsgInfo.presentationTimeDelta / emsgInfo.timeScale; 20805 let duration = emsgInfo.eventDuration === 4294967295 ? Number.POSITIVE_INFINITY : emsgInfo.eventDuration / emsgInfo.timeScale; 20806 if (duration <= 1e-3) { 20807 duration = Number.POSITIVE_INFINITY; 20808 } 20809 const payload = emsgInfo.payload; 20810 id3Track.samples.push({ 20811 data: payload, 20812 len: payload.byteLength, 20813 dts: pts, 20814 pts, 20815 type: MetadataSchema.emsg, 20816 duration 20817 }); 20818 } 20819 }); 20820 } 20821 } 20822 return id3Track; 20823 } 20824 demuxSampleAes(data, keyData, timeOffset) { 20825 return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption")); 20826 } 20827 destroy() { 20828 } 20829}; 20830var getAudioBSID = (data, offset) => { 20831 let bsid = 0; 20832 let numBits = 5; 20833 offset += numBits; 20834 const temp = new Uint32Array(1); 20835 const mask = new Uint32Array(1); 20836 const byte = new Uint8Array(1); 20837 while (numBits > 0) { 20838 byte[0] = data[offset]; 20839 const bits = Math.min(numBits, 8); 20840 const shift = 8 - bits; 20841 mask[0] = 4278190080 >>> 24 + shift << shift; 20842 temp[0] = (byte[0] & mask[0]) >> shift; 20843 bsid = !bsid ? temp[0] : bsid << bits | temp[0]; 20844 offset += 1; 20845 numBits -= bits; 20846 } 20847 return bsid; 20848}; 20849var AC3Demuxer = class extends BaseAudioDemuxer { 20850 constructor(observer2) { 20851 super(); 20852 this.observer = void 0; 20853 this.observer = observer2; 20854 } 20855 resetInitSegment(initSegment, audioCodec, videoCodec, trackDuration) { 20856 super.resetInitSegment(initSegment, audioCodec, videoCodec, trackDuration); 20857 this._audioTrack = { 20858 container: "audio/ac-3", 20859 type: "audio", 20860 id: 2, 20861 pid: -1, 20862 sequenceNumber: 0, 20863 segmentCodec: "ac3", 20864 samples: [], 20865 manifestCodec: audioCodec, 20866 duration: trackDuration, 20867 inputTimeScale: 9e4, 20868 dropped: 0 20869 }; 20870 } 20871 canParse(data, offset) { 20872 return offset + 64 < data.length; 20873 } 20874 appendFrame(track, data, offset) { 20875 const frameLength = appendFrame(track, data, offset, this.basePTS, this.frameIndex); 20876 if (frameLength !== -1) { 20877 const sample = track.samples[track.samples.length - 1]; 20878 return { 20879 sample, 20880 length: frameLength, 20881 missing: 0 20882 }; 20883 } 20884 } 20885 static probe(data) { 20886 if (!data) { 20887 return false; 20888 } 20889 const id3Data = getID3Data(data, 0); 20890 if (!id3Data) { 20891 return false; 20892 } 20893 const offset = id3Data.length; 20894 if (data[offset] === 11 && data[offset + 1] === 119 && getTimeStamp(id3Data) !== void 0 && // check the bsid to confirm ac-3 20895 getAudioBSID(data, offset) < 16) { 20896 return true; 20897 } 20898 return false; 20899 } 20900}; 20901function appendFrame(track, data, start, pts, frameIndex) { 20902 if (start + 8 > data.length) { 20903 return -1; 20904 } 20905 if (data[start] !== 11 || data[start + 1] !== 119) { 20906 return -1; 20907 } 20908 const samplingRateCode = data[start + 4] >> 6; 20909 if (samplingRateCode >= 3) { 20910 return -1; 20911 } 20912 const samplingRateMap = [48e3, 44100, 32e3]; 20913 const sampleRate = samplingRateMap[samplingRateCode]; 20914 const frameSizeCode = data[start + 4] & 63; 20915 const frameSizeMap = [64, 69, 96, 64, 70, 96, 80, 87, 120, 80, 88, 120, 96, 104, 144, 96, 105, 144, 112, 121, 168, 112, 122, 168, 128, 139, 192, 128, 140, 192, 160, 174, 240, 160, 175, 240, 192, 208, 288, 192, 209, 288, 224, 243, 336, 224, 244, 336, 256, 278, 384, 256, 279, 384, 320, 348, 480, 320, 349, 480, 384, 417, 576, 384, 418, 576, 448, 487, 672, 448, 488, 672, 512, 557, 768, 512, 558, 768, 640, 696, 960, 640, 697, 960, 768, 835, 1152, 768, 836, 1152, 896, 975, 1344, 896, 976, 1344, 1024, 1114, 1536, 1024, 1115, 1536, 1152, 1253, 1728, 1152, 1254, 1728, 1280, 1393, 1920, 1280, 1394, 1920]; 20916 const frameLength = frameSizeMap[frameSizeCode * 3 + samplingRateCode] * 2; 20917 if (start + frameLength > data.length) { 20918 return -1; 20919 } 20920 const channelMode = data[start + 6] >> 5; 20921 let skipCount = 0; 20922 if (channelMode === 2) { 20923 skipCount += 2; 20924 } else { 20925 if (channelMode & 1 && channelMode !== 1) { 20926 skipCount += 2; 20927 } 20928 if (channelMode & 4) { 20929 skipCount += 2; 20930 } 20931 } 20932 const lfeon = (data[start + 6] << 8 | data[start + 7]) >> 12 - skipCount & 1; 20933 const channelsMap = [2, 1, 2, 3, 3, 4, 4, 5]; 20934 const channelCount = channelsMap[channelMode] + lfeon; 20935 const bsid = data[start + 5] >> 3; 20936 const bsmod = data[start + 5] & 7; 20937 const config = new Uint8Array([samplingRateCode << 6 | bsid << 1 | bsmod >> 2, (bsmod & 3) << 6 | channelMode << 3 | lfeon << 2 | frameSizeCode >> 4, frameSizeCode << 4 & 224]); 20938 const frameDuration = 1536 / sampleRate * 9e4; 20939 const stamp = pts + frameIndex * frameDuration; 20940 const unit = data.subarray(start, start + frameLength); 20941 track.config = config; 20942 track.channelCount = channelCount; 20943 track.samplerate = sampleRate; 20944 track.samples.push({ 20945 unit, 20946 pts: stamp 20947 }); 20948 return frameLength; 20949} 20950var BaseVideoParser = class { 20951 constructor() { 20952 this.VideoSample = null; 20953 } 20954 createVideoSample(key, pts, dts, debug) { 20955 return { 20956 key, 20957 frame: false, 20958 pts, 20959 dts, 20960 units: [], 20961 debug, 20962 length: 0 20963 }; 20964 } 20965 getLastNalUnit(samples) { 20966 var _VideoSample; 20967 let VideoSample = this.VideoSample; 20968 let lastUnit; 20969 if (!VideoSample || VideoSample.units.length === 0) { 20970 VideoSample = samples[samples.length - 1]; 20971 } 20972 if ((_VideoSample = VideoSample) != null && _VideoSample.units) { 20973 const units = VideoSample.units; 20974 lastUnit = units[units.length - 1]; 20975 } 20976 return lastUnit; 20977 } 20978 pushAccessUnit(VideoSample, videoTrack) { 20979 if (VideoSample.units.length && VideoSample.frame) { 20980 if (VideoSample.pts === void 0) { 20981 const samples = videoTrack.samples; 20982 const nbSamples = samples.length; 20983 if (nbSamples) { 20984 const lastSample = samples[nbSamples - 1]; 20985 VideoSample.pts = lastSample.pts; 20986 VideoSample.dts = lastSample.dts; 20987 } else { 20988 videoTrack.dropped++; 20989 return; 20990 } 20991 } 20992 videoTrack.samples.push(VideoSample); 20993 } 20994 if (VideoSample.debug.length) { 20995 logger.log(VideoSample.pts + "/" + VideoSample.dts + ":" + VideoSample.debug); 20996 } 20997 } 20998}; 20999var ExpGolomb = class { 21000 constructor(data) { 21001 this.data = void 0; 21002 this.bytesAvailable = void 0; 21003 this.word = void 0; 21004 this.bitsAvailable = void 0; 21005 this.data = data; 21006 this.bytesAvailable = data.byteLength; 21007 this.word = 0; 21008 this.bitsAvailable = 0; 21009 } 21010 // ():void 21011 loadWord() { 21012 const data = this.data; 21013 const bytesAvailable = this.bytesAvailable; 21014 const position2 = data.byteLength - bytesAvailable; 21015 const workingBytes = new Uint8Array(4); 21016 const availableBytes = Math.min(4, bytesAvailable); 21017 if (availableBytes === 0) { 21018 throw new Error("no bytes available"); 21019 } 21020 workingBytes.set(data.subarray(position2, position2 + availableBytes)); 21021 this.word = new DataView(workingBytes.buffer).getUint32(0); 21022 this.bitsAvailable = availableBytes * 8; 21023 this.bytesAvailable -= availableBytes; 21024 } 21025 // (count:int):void 21026 skipBits(count) { 21027 let skipBytes; 21028 count = Math.min(count, this.bytesAvailable * 8 + this.bitsAvailable); 21029 if (this.bitsAvailable > count) { 21030 this.word <<= count; 21031 this.bitsAvailable -= count; 21032 } else { 21033 count -= this.bitsAvailable; 21034 skipBytes = count >> 3; 21035 count -= skipBytes << 3; 21036 this.bytesAvailable -= skipBytes; 21037 this.loadWord(); 21038 this.word <<= count; 21039 this.bitsAvailable -= count; 21040 } 21041 } 21042 // (size:int):uint 21043 readBits(size) { 21044 let bits = Math.min(this.bitsAvailable, size); 21045 const valu = this.word >>> 32 - bits; 21046 if (size > 32) { 21047 logger.error("Cannot read more than 32 bits at a time"); 21048 } 21049 this.bitsAvailable -= bits; 21050 if (this.bitsAvailable > 0) { 21051 this.word <<= bits; 21052 } else if (this.bytesAvailable > 0) { 21053 this.loadWord(); 21054 } else { 21055 throw new Error("no bits available"); 21056 } 21057 bits = size - bits; 21058 if (bits > 0 && this.bitsAvailable) { 21059 return valu << bits | this.readBits(bits); 21060 } else { 21061 return valu; 21062 } 21063 } 21064 // ():uint 21065 skipLZ() { 21066 let leadingZeroCount; 21067 for (leadingZeroCount = 0; leadingZeroCount < this.bitsAvailable; ++leadingZeroCount) { 21068 if ((this.word & 2147483648 >>> leadingZeroCount) !== 0) { 21069 this.word <<= leadingZeroCount; 21070 this.bitsAvailable -= leadingZeroCount; 21071 return leadingZeroCount; 21072 } 21073 } 21074 this.loadWord(); 21075 return leadingZeroCount + this.skipLZ(); 21076 } 21077 // ():void 21078 skipUEG() { 21079 this.skipBits(1 + this.skipLZ()); 21080 } 21081 // ():void 21082 skipEG() { 21083 this.skipBits(1 + this.skipLZ()); 21084 } 21085 // ():uint 21086 readUEG() { 21087 const clz = this.skipLZ(); 21088 return this.readBits(clz + 1) - 1; 21089 } 21090 // ():int 21091 readEG() { 21092 const valu = this.readUEG(); 21093 if (1 & valu) { 21094 return 1 + valu >>> 1; 21095 } else { 21096 return -1 * (valu >>> 1); 21097 } 21098 } 21099 // Some convenience functions 21100 // :Boolean 21101 readBoolean() { 21102 return this.readBits(1) === 1; 21103 } 21104 // ():int 21105 readUByte() { 21106 return this.readBits(8); 21107 } 21108 // ():int 21109 readUShort() { 21110 return this.readBits(16); 21111 } 21112 // ():int 21113 readUInt() { 21114 return this.readBits(32); 21115 } 21116 /** 21117 * Advance the ExpGolomb decoder past a scaling list. The scaling 21118 * list is optionally transmitted as part of a sequence parameter 21119 * set and is not relevant to transmuxing. 21120 * @param count the number of entries in this scaling list 21121 * @see Recommendation ITU-T H.264, Section 7.3.2.1.1.1 21122 */ 21123 skipScalingList(count) { 21124 let lastScale = 8; 21125 let nextScale = 8; 21126 let deltaScale; 21127 for (let j3 = 0; j3 < count; j3++) { 21128 if (nextScale !== 0) { 21129 deltaScale = this.readEG(); 21130 nextScale = (lastScale + deltaScale + 256) % 256; 21131 } 21132 lastScale = nextScale === 0 ? lastScale : nextScale; 21133 } 21134 } 21135 /** 21136 * Read a sequence parameter set and return some interesting video 21137 * properties. A sequence parameter set is the H264 metadata that 21138 * describes the properties of upcoming video frames. 21139 * @returns an object with configuration parsed from the 21140 * sequence parameter set, including the dimensions of the 21141 * associated video frames. 21142 */ 21143 readSPS() { 21144 let frameCropLeftOffset = 0; 21145 let frameCropRightOffset = 0; 21146 let frameCropTopOffset = 0; 21147 let frameCropBottomOffset = 0; 21148 let numRefFramesInPicOrderCntCycle; 21149 let scalingListCount; 21150 let i3; 21151 const readUByte = this.readUByte.bind(this); 21152 const readBits = this.readBits.bind(this); 21153 const readUEG = this.readUEG.bind(this); 21154 const readBoolean = this.readBoolean.bind(this); 21155 const skipBits = this.skipBits.bind(this); 21156 const skipEG = this.skipEG.bind(this); 21157 const skipUEG = this.skipUEG.bind(this); 21158 const skipScalingList = this.skipScalingList.bind(this); 21159 readUByte(); 21160 const profileIdc = readUByte(); 21161 readBits(5); 21162 skipBits(3); 21163 readUByte(); 21164 skipUEG(); 21165 if (profileIdc === 100 || profileIdc === 110 || profileIdc === 122 || profileIdc === 244 || profileIdc === 44 || profileIdc === 83 || profileIdc === 86 || profileIdc === 118 || profileIdc === 128) { 21166 const chromaFormatIdc = readUEG(); 21167 if (chromaFormatIdc === 3) { 21168 skipBits(1); 21169 } 21170 skipUEG(); 21171 skipUEG(); 21172 skipBits(1); 21173 if (readBoolean()) { 21174 scalingListCount = chromaFormatIdc !== 3 ? 8 : 12; 21175 for (i3 = 0; i3 < scalingListCount; i3++) { 21176 if (readBoolean()) { 21177 if (i3 < 6) { 21178 skipScalingList(16); 21179 } else { 21180 skipScalingList(64); 21181 } 21182 } 21183 } 21184 } 21185 } 21186 skipUEG(); 21187 const picOrderCntType = readUEG(); 21188 if (picOrderCntType === 0) { 21189 readUEG(); 21190 } else if (picOrderCntType === 1) { 21191 skipBits(1); 21192 skipEG(); 21193 skipEG(); 21194 numRefFramesInPicOrderCntCycle = readUEG(); 21195 for (i3 = 0; i3 < numRefFramesInPicOrderCntCycle; i3++) { 21196 skipEG(); 21197 } 21198 } 21199 skipUEG(); 21200 skipBits(1); 21201 const picWidthInMbsMinus1 = readUEG(); 21202 const picHeightInMapUnitsMinus1 = readUEG(); 21203 const frameMbsOnlyFlag = readBits(1); 21204 if (frameMbsOnlyFlag === 0) { 21205 skipBits(1); 21206 } 21207 skipBits(1); 21208 if (readBoolean()) { 21209 frameCropLeftOffset = readUEG(); 21210 frameCropRightOffset = readUEG(); 21211 frameCropTopOffset = readUEG(); 21212 frameCropBottomOffset = readUEG(); 21213 } 21214 let pixelRatio = [1, 1]; 21215 if (readBoolean()) { 21216 if (readBoolean()) { 21217 const aspectRatioIdc = readUByte(); 21218 switch (aspectRatioIdc) { 21219 case 1: 21220 pixelRatio = [1, 1]; 21221 break; 21222 case 2: 21223 pixelRatio = [12, 11]; 21224 break; 21225 case 3: 21226 pixelRatio = [10, 11]; 21227 break; 21228 case 4: 21229 pixelRatio = [16, 11]; 21230 break; 21231 case 5: 21232 pixelRatio = [40, 33]; 21233 break; 21234 case 6: 21235 pixelRatio = [24, 11]; 21236 break; 21237 case 7: 21238 pixelRatio = [20, 11]; 21239 break; 21240 case 8: 21241 pixelRatio = [32, 11]; 21242 break; 21243 case 9: 21244 pixelRatio = [80, 33]; 21245 break; 21246 case 10: 21247 pixelRatio = [18, 11]; 21248 break; 21249 case 11: 21250 pixelRatio = [15, 11]; 21251 break; 21252 case 12: 21253 pixelRatio = [64, 33]; 21254 break; 21255 case 13: 21256 pixelRatio = [160, 99]; 21257 break; 21258 case 14: 21259 pixelRatio = [4, 3]; 21260 break; 21261 case 15: 21262 pixelRatio = [3, 2]; 21263 break; 21264 case 16: 21265 pixelRatio = [2, 1]; 21266 break; 21267 case 255: { 21268 pixelRatio = [readUByte() << 8 | readUByte(), readUByte() << 8 | readUByte()]; 21269 break; 21270 } 21271 } 21272 } 21273 } 21274 return { 21275 width: Math.ceil((picWidthInMbsMinus1 + 1) * 16 - frameCropLeftOffset * 2 - frameCropRightOffset * 2), 21276 height: (2 - frameMbsOnlyFlag) * (picHeightInMapUnitsMinus1 + 1) * 16 - (frameMbsOnlyFlag ? 2 : 4) * (frameCropTopOffset + frameCropBottomOffset), 21277 pixelRatio 21278 }; 21279 } 21280 readSliceType() { 21281 this.readUByte(); 21282 this.readUEG(); 21283 return this.readUEG(); 21284 } 21285}; 21286var AvcVideoParser = class extends BaseVideoParser { 21287 parseAVCPES(track, textTrack, pes, last, duration) { 21288 const units = this.parseAVCNALu(track, pes.data); 21289 let VideoSample = this.VideoSample; 21290 let push2; 21291 let spsfound = false; 21292 pes.data = null; 21293 if (VideoSample && units.length && !track.audFound) { 21294 this.pushAccessUnit(VideoSample, track); 21295 VideoSample = this.VideoSample = this.createVideoSample(false, pes.pts, pes.dts, ""); 21296 } 21297 units.forEach((unit) => { 21298 var _VideoSample2; 21299 switch (unit.type) { 21300 case 1: { 21301 let iskey = false; 21302 push2 = true; 21303 const data = unit.data; 21304 if (spsfound && data.length > 4) { 21305 const sliceType = new ExpGolomb(data).readSliceType(); 21306 if (sliceType === 2 || sliceType === 4 || sliceType === 7 || sliceType === 9) { 21307 iskey = true; 21308 } 21309 } 21310 if (iskey) { 21311 var _VideoSample; 21312 if ((_VideoSample = VideoSample) != null && _VideoSample.frame && !VideoSample.key) { 21313 this.pushAccessUnit(VideoSample, track); 21314 VideoSample = this.VideoSample = null; 21315 } 21316 } 21317 if (!VideoSample) { 21318 VideoSample = this.VideoSample = this.createVideoSample(true, pes.pts, pes.dts, ""); 21319 } 21320 VideoSample.frame = true; 21321 VideoSample.key = iskey; 21322 break; 21323 } 21324 case 5: 21325 push2 = true; 21326 if ((_VideoSample2 = VideoSample) != null && _VideoSample2.frame && !VideoSample.key) { 21327 this.pushAccessUnit(VideoSample, track); 21328 VideoSample = this.VideoSample = null; 21329 } 21330 if (!VideoSample) { 21331 VideoSample = this.VideoSample = this.createVideoSample(true, pes.pts, pes.dts, ""); 21332 } 21333 VideoSample.key = true; 21334 VideoSample.frame = true; 21335 break; 21336 case 6: { 21337 push2 = true; 21338 parseSEIMessageFromNALu(unit.data, 1, pes.pts, textTrack.samples); 21339 break; 21340 } 21341 case 7: { 21342 var _track$pixelRatio, _track$pixelRatio2; 21343 push2 = true; 21344 spsfound = true; 21345 const sps = unit.data; 21346 const expGolombDecoder = new ExpGolomb(sps); 21347 const config = expGolombDecoder.readSPS(); 21348 if (!track.sps || track.width !== config.width || track.height !== config.height || ((_track$pixelRatio = track.pixelRatio) == null ? void 0 : _track$pixelRatio[0]) !== config.pixelRatio[0] || ((_track$pixelRatio2 = track.pixelRatio) == null ? void 0 : _track$pixelRatio2[1]) !== config.pixelRatio[1]) { 21349 track.width = config.width; 21350 track.height = config.height; 21351 track.pixelRatio = config.pixelRatio; 21352 track.sps = [sps]; 21353 track.duration = duration; 21354 const codecarray = sps.subarray(1, 4); 21355 let codecstring = "avc1."; 21356 for (let i3 = 0; i3 < 3; i3++) { 21357 let h3 = codecarray[i3].toString(16); 21358 if (h3.length < 2) { 21359 h3 = "0" + h3; 21360 } 21361 codecstring += h3; 21362 } 21363 track.codec = codecstring; 21364 } 21365 break; 21366 } 21367 case 8: 21368 push2 = true; 21369 track.pps = [unit.data]; 21370 break; 21371 case 9: 21372 push2 = true; 21373 track.audFound = true; 21374 if (VideoSample) { 21375 this.pushAccessUnit(VideoSample, track); 21376 } 21377 VideoSample = this.VideoSample = this.createVideoSample(false, pes.pts, pes.dts, ""); 21378 break; 21379 case 12: 21380 push2 = true; 21381 break; 21382 default: 21383 push2 = false; 21384 if (VideoSample) { 21385 VideoSample.debug += "unknown NAL " + unit.type + " "; 21386 } 21387 break; 21388 } 21389 if (VideoSample && push2) { 21390 const units2 = VideoSample.units; 21391 units2.push(unit); 21392 } 21393 }); 21394 if (last && VideoSample) { 21395 this.pushAccessUnit(VideoSample, track); 21396 this.VideoSample = null; 21397 } 21398 } 21399 parseAVCNALu(track, array) { 21400 const len = array.byteLength; 21401 let state = track.naluState || 0; 21402 const lastState = state; 21403 const units = []; 21404 let i3 = 0; 21405 let value; 21406 let overflow; 21407 let unitType; 21408 let lastUnitStart = -1; 21409 let lastUnitType = 0; 21410 if (state === -1) { 21411 lastUnitStart = 0; 21412 lastUnitType = array[0] & 31; 21413 state = 0; 21414 i3 = 1; 21415 } 21416 while (i3 < len) { 21417 value = array[i3++]; 21418 if (!state) { 21419 state = value ? 0 : 1; 21420 continue; 21421 } 21422 if (state === 1) { 21423 state = value ? 0 : 2; 21424 continue; 21425 } 21426 if (!value) { 21427 state = 3; 21428 } else if (value === 1) { 21429 overflow = i3 - state - 1; 21430 if (lastUnitStart >= 0) { 21431 const unit = { 21432 data: array.subarray(lastUnitStart, overflow), 21433 type: lastUnitType 21434 }; 21435 units.push(unit); 21436 } else { 21437 const lastUnit = this.getLastNalUnit(track.samples); 21438 if (lastUnit) { 21439 if (lastState && i3 <= 4 - lastState) { 21440 if (lastUnit.state) { 21441 lastUnit.data = lastUnit.data.subarray(0, lastUnit.data.byteLength - lastState); 21442 } 21443 } 21444 if (overflow > 0) { 21445 lastUnit.data = appendUint8Array(lastUnit.data, array.subarray(0, overflow)); 21446 lastUnit.state = 0; 21447 } 21448 } 21449 } 21450 if (i3 < len) { 21451 unitType = array[i3] & 31; 21452 lastUnitStart = i3; 21453 lastUnitType = unitType; 21454 state = 0; 21455 } else { 21456 state = -1; 21457 } 21458 } else { 21459 state = 0; 21460 } 21461 } 21462 if (lastUnitStart >= 0 && state >= 0) { 21463 const unit = { 21464 data: array.subarray(lastUnitStart, len), 21465 type: lastUnitType, 21466 state 21467 }; 21468 units.push(unit); 21469 } 21470 if (units.length === 0) { 21471 const lastUnit = this.getLastNalUnit(track.samples); 21472 if (lastUnit) { 21473 lastUnit.data = appendUint8Array(lastUnit.data, array); 21474 } 21475 } 21476 track.naluState = state; 21477 return units; 21478 } 21479}; 21480var SampleAesDecrypter = class { 21481 constructor(observer2, config, keyData) { 21482 this.keyData = void 0; 21483 this.decrypter = void 0; 21484 this.keyData = keyData; 21485 this.decrypter = new Decrypter(config, { 21486 removePKCS7Padding: false 21487 }); 21488 } 21489 decryptBuffer(encryptedData) { 21490 return this.decrypter.decrypt(encryptedData, this.keyData.key.buffer, this.keyData.iv.buffer); 21491 } 21492 // AAC - encrypt all full 16 bytes blocks starting from offset 16 21493 decryptAacSample(samples, sampleIndex, callback) { 21494 const curUnit = samples[sampleIndex].unit; 21495 if (curUnit.length <= 16) { 21496 return; 21497 } 21498 const encryptedData = curUnit.subarray(16, curUnit.length - curUnit.length % 16); 21499 const encryptedBuffer = encryptedData.buffer.slice(encryptedData.byteOffset, encryptedData.byteOffset + encryptedData.length); 21500 this.decryptBuffer(encryptedBuffer).then((decryptedBuffer) => { 21501 const decryptedData = new Uint8Array(decryptedBuffer); 21502 curUnit.set(decryptedData, 16); 21503 if (!this.decrypter.isSync()) { 21504 this.decryptAacSamples(samples, sampleIndex + 1, callback); 21505 } 21506 }); 21507 } 21508 decryptAacSamples(samples, sampleIndex, callback) { 21509 for (; ; sampleIndex++) { 21510 if (sampleIndex >= samples.length) { 21511 callback(); 21512 return; 21513 } 21514 if (samples[sampleIndex].unit.length < 32) { 21515 continue; 21516 } 21517 this.decryptAacSample(samples, sampleIndex, callback); 21518 if (!this.decrypter.isSync()) { 21519 return; 21520 } 21521 } 21522 } 21523 // AVC - encrypt one 16 bytes block out of ten, starting from offset 32 21524 getAvcEncryptedData(decodedData) { 21525 const encryptedDataLen = Math.floor((decodedData.length - 48) / 160) * 16 + 16; 21526 const encryptedData = new Int8Array(encryptedDataLen); 21527 let outputPos = 0; 21528 for (let inputPos = 32; inputPos < decodedData.length - 16; inputPos += 160, outputPos += 16) { 21529 encryptedData.set(decodedData.subarray(inputPos, inputPos + 16), outputPos); 21530 } 21531 return encryptedData; 21532 } 21533 getAvcDecryptedUnit(decodedData, decryptedData) { 21534 const uint8DecryptedData = new Uint8Array(decryptedData); 21535 let inputPos = 0; 21536 for (let outputPos = 32; outputPos < decodedData.length - 16; outputPos += 160, inputPos += 16) { 21537 decodedData.set(uint8DecryptedData.subarray(inputPos, inputPos + 16), outputPos); 21538 } 21539 return decodedData; 21540 } 21541 decryptAvcSample(samples, sampleIndex, unitIndex, callback, curUnit) { 21542 const decodedData = discardEPB(curUnit.data); 21543 const encryptedData = this.getAvcEncryptedData(decodedData); 21544 this.decryptBuffer(encryptedData.buffer).then((decryptedBuffer) => { 21545 curUnit.data = this.getAvcDecryptedUnit(decodedData, decryptedBuffer); 21546 if (!this.decrypter.isSync()) { 21547 this.decryptAvcSamples(samples, sampleIndex, unitIndex + 1, callback); 21548 } 21549 }); 21550 } 21551 decryptAvcSamples(samples, sampleIndex, unitIndex, callback) { 21552 if (samples instanceof Uint8Array) { 21553 throw new Error("Cannot decrypt samples of type Uint8Array"); 21554 } 21555 for (; ; sampleIndex++, unitIndex = 0) { 21556 if (sampleIndex >= samples.length) { 21557 callback(); 21558 return; 21559 } 21560 const curUnits = samples[sampleIndex].units; 21561 for (; ; unitIndex++) { 21562 if (unitIndex >= curUnits.length) { 21563 break; 21564 } 21565 const curUnit = curUnits[unitIndex]; 21566 if (curUnit.data.length <= 48 || curUnit.type !== 1 && curUnit.type !== 5) { 21567 continue; 21568 } 21569 this.decryptAvcSample(samples, sampleIndex, unitIndex, callback, curUnit); 21570 if (!this.decrypter.isSync()) { 21571 return; 21572 } 21573 } 21574 } 21575 } 21576}; 21577var PACKET_LENGTH = 188; 21578var TSDemuxer = class _TSDemuxer { 21579 constructor(observer2, config, typeSupported) { 21580 this.observer = void 0; 21581 this.config = void 0; 21582 this.typeSupported = void 0; 21583 this.sampleAes = null; 21584 this.pmtParsed = false; 21585 this.audioCodec = void 0; 21586 this.videoCodec = void 0; 21587 this._duration = 0; 21588 this._pmtId = -1; 21589 this._videoTrack = void 0; 21590 this._audioTrack = void 0; 21591 this._id3Track = void 0; 21592 this._txtTrack = void 0; 21593 this.aacOverFlow = null; 21594 this.remainderData = null; 21595 this.videoParser = void 0; 21596 this.observer = observer2; 21597 this.config = config; 21598 this.typeSupported = typeSupported; 21599 this.videoParser = new AvcVideoParser(); 21600 } 21601 static probe(data) { 21602 const syncOffset = _TSDemuxer.syncOffset(data); 21603 if (syncOffset > 0) { 21604 logger.warn(`MPEG2-TS detected but first sync word found @ offset ${syncOffset}`); 21605 } 21606 return syncOffset !== -1; 21607 } 21608 static syncOffset(data) { 21609 const length2 = data.length; 21610 let scanwindow = Math.min(PACKET_LENGTH * 5, length2 - PACKET_LENGTH) + 1; 21611 let i3 = 0; 21612 while (i3 < scanwindow) { 21613 let foundPat = false; 21614 let packetStart = -1; 21615 let tsPackets = 0; 21616 for (let j3 = i3; j3 < length2; j3 += PACKET_LENGTH) { 21617 if (data[j3] === 71 && (length2 - j3 === PACKET_LENGTH || data[j3 + PACKET_LENGTH] === 71)) { 21618 tsPackets++; 21619 if (packetStart === -1) { 21620 packetStart = j3; 21621 if (packetStart !== 0) { 21622 scanwindow = Math.min(packetStart + PACKET_LENGTH * 99, data.length - PACKET_LENGTH) + 1; 21623 } 21624 } 21625 if (!foundPat) { 21626 foundPat = parsePID(data, j3) === 0; 21627 } 21628 if (foundPat && tsPackets > 1 && (packetStart === 0 && tsPackets > 2 || j3 + PACKET_LENGTH > scanwindow)) { 21629 return packetStart; 21630 } 21631 } else if (tsPackets) { 21632 return -1; 21633 } else { 21634 break; 21635 } 21636 } 21637 i3++; 21638 } 21639 return -1; 21640 } 21641 /** 21642 * Creates a track model internal to demuxer used to drive remuxing input 21643 */ 21644 static createTrack(type, duration) { 21645 return { 21646 container: type === "video" || type === "audio" ? "video/mp2t" : void 0, 21647 type, 21648 id: RemuxerTrackIdConfig[type], 21649 pid: -1, 21650 inputTimeScale: 9e4, 21651 sequenceNumber: 0, 21652 samples: [], 21653 dropped: 0, 21654 duration: type === "audio" ? duration : void 0 21655 }; 21656 } 21657 /** 21658 * Initializes a new init segment on the demuxer/remuxer interface. Needed for discontinuities/track-switches (or at stream start) 21659 * Resets all internal track instances of the demuxer. 21660 */ 21661 resetInitSegment(initSegment, audioCodec, videoCodec, trackDuration) { 21662 this.pmtParsed = false; 21663 this._pmtId = -1; 21664 this._videoTrack = _TSDemuxer.createTrack("video"); 21665 this._audioTrack = _TSDemuxer.createTrack("audio", trackDuration); 21666 this._id3Track = _TSDemuxer.createTrack("id3"); 21667 this._txtTrack = _TSDemuxer.createTrack("text"); 21668 this._audioTrack.segmentCodec = "aac"; 21669 this.aacOverFlow = null; 21670 this.remainderData = null; 21671 this.audioCodec = audioCodec; 21672 this.videoCodec = videoCodec; 21673 this._duration = trackDuration; 21674 } 21675 resetTimeStamp() { 21676 } 21677 resetContiguity() { 21678 const { 21679 _audioTrack, 21680 _videoTrack, 21681 _id3Track 21682 } = this; 21683 if (_audioTrack) { 21684 _audioTrack.pesData = null; 21685 } 21686 if (_videoTrack) { 21687 _videoTrack.pesData = null; 21688 } 21689 if (_id3Track) { 21690 _id3Track.pesData = null; 21691 } 21692 this.aacOverFlow = null; 21693 this.remainderData = null; 21694 } 21695 demux(data, timeOffset, isSampleAes = false, flush = false) { 21696 if (!isSampleAes) { 21697 this.sampleAes = null; 21698 } 21699 let pes; 21700 const videoTrack = this._videoTrack; 21701 const audioTrack = this._audioTrack; 21702 const id3Track = this._id3Track; 21703 const textTrack = this._txtTrack; 21704 let videoPid = videoTrack.pid; 21705 let videoData = videoTrack.pesData; 21706 let audioPid = audioTrack.pid; 21707 let id3Pid = id3Track.pid; 21708 let audioData = audioTrack.pesData; 21709 let id3Data = id3Track.pesData; 21710 let unknownPID = null; 21711 let pmtParsed = this.pmtParsed; 21712 let pmtId = this._pmtId; 21713 let len = data.length; 21714 if (this.remainderData) { 21715 data = appendUint8Array(this.remainderData, data); 21716 len = data.length; 21717 this.remainderData = null; 21718 } 21719 if (len < PACKET_LENGTH && !flush) { 21720 this.remainderData = data; 21721 return { 21722 audioTrack, 21723 videoTrack, 21724 id3Track, 21725 textTrack 21726 }; 21727 } 21728 const syncOffset = Math.max(0, _TSDemuxer.syncOffset(data)); 21729 len -= (len - syncOffset) % PACKET_LENGTH; 21730 if (len < data.byteLength && !flush) { 21731 this.remainderData = new Uint8Array(data.buffer, len, data.buffer.byteLength - len); 21732 } 21733 let tsPacketErrors = 0; 21734 for (let start = syncOffset; start < len; start += PACKET_LENGTH) { 21735 if (data[start] === 71) { 21736 const stt = !!(data[start + 1] & 64); 21737 const pid = parsePID(data, start); 21738 const atf = (data[start + 3] & 48) >> 4; 21739 let offset; 21740 if (atf > 1) { 21741 offset = start + 5 + data[start + 4]; 21742 if (offset === start + PACKET_LENGTH) { 21743 continue; 21744 } 21745 } else { 21746 offset = start + 4; 21747 } 21748 switch (pid) { 21749 case videoPid: 21750 if (stt) { 21751 if (videoData && (pes = parsePES(videoData))) { 21752 this.videoParser.parseAVCPES(videoTrack, textTrack, pes, false, this._duration); 21753 } 21754 videoData = { 21755 data: [], 21756 size: 0 21757 }; 21758 } 21759 if (videoData) { 21760 videoData.data.push(data.subarray(offset, start + PACKET_LENGTH)); 21761 videoData.size += start + PACKET_LENGTH - offset; 21762 } 21763 break; 21764 case audioPid: 21765 if (stt) { 21766 if (audioData && (pes = parsePES(audioData))) { 21767 switch (audioTrack.segmentCodec) { 21768 case "aac": 21769 this.parseAACPES(audioTrack, pes); 21770 break; 21771 case "mp3": 21772 this.parseMPEGPES(audioTrack, pes); 21773 break; 21774 case "ac3": 21775 { 21776 this.parseAC3PES(audioTrack, pes); 21777 } 21778 break; 21779 } 21780 } 21781 audioData = { 21782 data: [], 21783 size: 0 21784 }; 21785 } 21786 if (audioData) { 21787 audioData.data.push(data.subarray(offset, start + PACKET_LENGTH)); 21788 audioData.size += start + PACKET_LENGTH - offset; 21789 } 21790 break; 21791 case id3Pid: 21792 if (stt) { 21793 if (id3Data && (pes = parsePES(id3Data))) { 21794 this.parseID3PES(id3Track, pes); 21795 } 21796 id3Data = { 21797 data: [], 21798 size: 0 21799 }; 21800 } 21801 if (id3Data) { 21802 id3Data.data.push(data.subarray(offset, start + PACKET_LENGTH)); 21803 id3Data.size += start + PACKET_LENGTH - offset; 21804 } 21805 break; 21806 case 0: 21807 if (stt) { 21808 offset += data[offset] + 1; 21809 } 21810 pmtId = this._pmtId = parsePAT(data, offset); 21811 break; 21812 case pmtId: { 21813 if (stt) { 21814 offset += data[offset] + 1; 21815 } 21816 const parsedPIDs = parsePMT(data, offset, this.typeSupported, isSampleAes, this.observer); 21817 videoPid = parsedPIDs.videoPid; 21818 if (videoPid > 0) { 21819 videoTrack.pid = videoPid; 21820 videoTrack.segmentCodec = parsedPIDs.segmentVideoCodec; 21821 } 21822 audioPid = parsedPIDs.audioPid; 21823 if (audioPid > 0) { 21824 audioTrack.pid = audioPid; 21825 audioTrack.segmentCodec = parsedPIDs.segmentAudioCodec; 21826 } 21827 id3Pid = parsedPIDs.id3Pid; 21828 if (id3Pid > 0) { 21829 id3Track.pid = id3Pid; 21830 } 21831 if (unknownPID !== null && !pmtParsed) { 21832 logger.warn(`MPEG-TS PMT found at ${start} after unknown PID '${unknownPID}'. Backtracking to sync byte @${syncOffset} to parse all TS packets.`); 21833 unknownPID = null; 21834 start = syncOffset - 188; 21835 } 21836 pmtParsed = this.pmtParsed = true; 21837 break; 21838 } 21839 case 17: 21840 case 8191: 21841 break; 21842 default: 21843 unknownPID = pid; 21844 break; 21845 } 21846 } else { 21847 tsPacketErrors++; 21848 } 21849 } 21850 if (tsPacketErrors > 0) { 21851 emitParsingError(this.observer, new Error(`Found ${tsPacketErrors} TS packet/s that do not start with 0x47`)); 21852 } 21853 videoTrack.pesData = videoData; 21854 audioTrack.pesData = audioData; 21855 id3Track.pesData = id3Data; 21856 const demuxResult = { 21857 audioTrack, 21858 videoTrack, 21859 id3Track, 21860 textTrack 21861 }; 21862 if (flush) { 21863 this.extractRemainingSamples(demuxResult); 21864 } 21865 return demuxResult; 21866 } 21867 flush() { 21868 const { 21869 remainderData 21870 } = this; 21871 this.remainderData = null; 21872 let result; 21873 if (remainderData) { 21874 result = this.demux(remainderData, -1, false, true); 21875 } else { 21876 result = { 21877 videoTrack: this._videoTrack, 21878 audioTrack: this._audioTrack, 21879 id3Track: this._id3Track, 21880 textTrack: this._txtTrack 21881 }; 21882 } 21883 this.extractRemainingSamples(result); 21884 if (this.sampleAes) { 21885 return this.decrypt(result, this.sampleAes); 21886 } 21887 return result; 21888 } 21889 extractRemainingSamples(demuxResult) { 21890 const { 21891 audioTrack, 21892 videoTrack, 21893 id3Track, 21894 textTrack 21895 } = demuxResult; 21896 const videoData = videoTrack.pesData; 21897 const audioData = audioTrack.pesData; 21898 const id3Data = id3Track.pesData; 21899 let pes; 21900 if (videoData && (pes = parsePES(videoData))) { 21901 this.videoParser.parseAVCPES(videoTrack, textTrack, pes, true, this._duration); 21902 videoTrack.pesData = null; 21903 } else { 21904 videoTrack.pesData = videoData; 21905 } 21906 if (audioData && (pes = parsePES(audioData))) { 21907 switch (audioTrack.segmentCodec) { 21908 case "aac": 21909 this.parseAACPES(audioTrack, pes); 21910 break; 21911 case "mp3": 21912 this.parseMPEGPES(audioTrack, pes); 21913 break; 21914 case "ac3": 21915 { 21916 this.parseAC3PES(audioTrack, pes); 21917 } 21918 break; 21919 } 21920 audioTrack.pesData = null; 21921 } else { 21922 if (audioData != null && audioData.size) { 21923 logger.log("last AAC PES packet truncated,might overlap between fragments"); 21924 } 21925 audioTrack.pesData = audioData; 21926 } 21927 if (id3Data && (pes = parsePES(id3Data))) { 21928 this.parseID3PES(id3Track, pes); 21929 id3Track.pesData = null; 21930 } else { 21931 id3Track.pesData = id3Data; 21932 } 21933 } 21934 demuxSampleAes(data, keyData, timeOffset) { 21935 const demuxResult = this.demux(data, timeOffset, true, !this.config.progressive); 21936 const sampleAes = this.sampleAes = new SampleAesDecrypter(this.observer, this.config, keyData); 21937 return this.decrypt(demuxResult, sampleAes); 21938 } 21939 decrypt(demuxResult, sampleAes) { 21940 return new Promise((resolve) => { 21941 const { 21942 audioTrack, 21943 videoTrack 21944 } = demuxResult; 21945 if (audioTrack.samples && audioTrack.segmentCodec === "aac") { 21946 sampleAes.decryptAacSamples(audioTrack.samples, 0, () => { 21947 if (videoTrack.samples) { 21948 sampleAes.decryptAvcSamples(videoTrack.samples, 0, 0, () => { 21949 resolve(demuxResult); 21950 }); 21951 } else { 21952 resolve(demuxResult); 21953 } 21954 }); 21955 } else if (videoTrack.samples) { 21956 sampleAes.decryptAvcSamples(videoTrack.samples, 0, 0, () => { 21957 resolve(demuxResult); 21958 }); 21959 } 21960 }); 21961 } 21962 destroy() { 21963 this._duration = 0; 21964 } 21965 parseAACPES(track, pes) { 21966 let startOffset = 0; 21967 const aacOverFlow = this.aacOverFlow; 21968 let data = pes.data; 21969 if (aacOverFlow) { 21970 this.aacOverFlow = null; 21971 const frameMissingBytes = aacOverFlow.missing; 21972 const sampleLength = aacOverFlow.sample.unit.byteLength; 21973 if (frameMissingBytes === -1) { 21974 data = appendUint8Array(aacOverFlow.sample.unit, data); 21975 } else { 21976 const frameOverflowBytes = sampleLength - frameMissingBytes; 21977 aacOverFlow.sample.unit.set(data.subarray(0, frameMissingBytes), frameOverflowBytes); 21978 track.samples.push(aacOverFlow.sample); 21979 startOffset = aacOverFlow.missing; 21980 } 21981 } 21982 let offset; 21983 let len; 21984 for (offset = startOffset, len = data.length; offset < len - 1; offset++) { 21985 if (isHeader$1(data, offset)) { 21986 break; 21987 } 21988 } 21989 if (offset !== startOffset) { 21990 let reason; 21991 const recoverable = offset < len - 1; 21992 if (recoverable) { 21993 reason = `AAC PES did not start with ADTS header,offset:${offset}`; 21994 } else { 21995 reason = "No ADTS header found in AAC PES"; 21996 } 21997 emitParsingError(this.observer, new Error(reason), recoverable); 21998 if (!recoverable) { 21999 return; 22000 } 22001 } 22002 initTrackConfig(track, this.observer, data, offset, this.audioCodec); 22003 let pts; 22004 if (pes.pts !== void 0) { 22005 pts = pes.pts; 22006 } else if (aacOverFlow) { 22007 const frameDuration = getFrameDuration(track.samplerate); 22008 pts = aacOverFlow.sample.pts + frameDuration; 22009 } else { 22010 logger.warn("[tsdemuxer]: AAC PES unknown PTS"); 22011 return; 22012 } 22013 let frameIndex = 0; 22014 let frame; 22015 while (offset < len) { 22016 frame = appendFrame$2(track, data, offset, pts, frameIndex); 22017 offset += frame.length; 22018 if (!frame.missing) { 22019 frameIndex++; 22020 for (; offset < len - 1; offset++) { 22021 if (isHeader$1(data, offset)) { 22022 break; 22023 } 22024 } 22025 } else { 22026 this.aacOverFlow = frame; 22027 break; 22028 } 22029 } 22030 } 22031 parseMPEGPES(track, pes) { 22032 const data = pes.data; 22033 const length2 = data.length; 22034 let frameIndex = 0; 22035 let offset = 0; 22036 const pts = pes.pts; 22037 if (pts === void 0) { 22038 logger.warn("[tsdemuxer]: MPEG PES unknown PTS"); 22039 return; 22040 } 22041 while (offset < length2) { 22042 if (isHeader(data, offset)) { 22043 const frame = appendFrame$1(track, data, offset, pts, frameIndex); 22044 if (frame) { 22045 offset += frame.length; 22046 frameIndex++; 22047 } else { 22048 break; 22049 } 22050 } else { 22051 offset++; 22052 } 22053 } 22054 } 22055 parseAC3PES(track, pes) { 22056 { 22057 const data = pes.data; 22058 const pts = pes.pts; 22059 if (pts === void 0) { 22060 logger.warn("[tsdemuxer]: AC3 PES unknown PTS"); 22061 return; 22062 } 22063 const length2 = data.length; 22064 let frameIndex = 0; 22065 let offset = 0; 22066 let parsed; 22067 while (offset < length2 && (parsed = appendFrame(track, data, offset, pts, frameIndex++)) > 0) { 22068 offset += parsed; 22069 } 22070 } 22071 } 22072 parseID3PES(id3Track, pes) { 22073 if (pes.pts === void 0) { 22074 logger.warn("[tsdemuxer]: ID3 PES unknown PTS"); 22075 return; 22076 } 22077 const id3Sample = _extends2({}, pes, { 22078 type: this._videoTrack ? MetadataSchema.emsg : MetadataSchema.audioId3, 22079 duration: Number.POSITIVE_INFINITY 22080 }); 22081 id3Track.samples.push(id3Sample); 22082 } 22083}; 22084function parsePID(data, offset) { 22085 return ((data[offset + 1] & 31) << 8) + data[offset + 2]; 22086} 22087function parsePAT(data, offset) { 22088 return (data[offset + 10] & 31) << 8 | data[offset + 11]; 22089} 22090function parsePMT(data, offset, typeSupported, isSampleAes, observer2) { 22091 const result = { 22092 audioPid: -1, 22093 videoPid: -1, 22094 id3Pid: -1, 22095 segmentVideoCodec: "avc", 22096 segmentAudioCodec: "aac" 22097 }; 22098 const sectionLength = (data[offset + 1] & 15) << 8 | data[offset + 2]; 22099 const tableEnd = offset + 3 + sectionLength - 4; 22100 const programInfoLength = (data[offset + 10] & 15) << 8 | data[offset + 11]; 22101 offset += 12 + programInfoLength; 22102 while (offset < tableEnd) { 22103 const pid = parsePID(data, offset); 22104 const esInfoLength = (data[offset + 3] & 15) << 8 | data[offset + 4]; 22105 switch (data[offset]) { 22106 case 207: 22107 if (!isSampleAes) { 22108 logEncryptedSamplesFoundInUnencryptedStream("ADTS AAC"); 22109 break; 22110 } 22111 case 15: 22112 if (result.audioPid === -1) { 22113 result.audioPid = pid; 22114 } 22115 break; 22116 case 21: 22117 if (result.id3Pid === -1) { 22118 result.id3Pid = pid; 22119 } 22120 break; 22121 case 219: 22122 if (!isSampleAes) { 22123 logEncryptedSamplesFoundInUnencryptedStream("H.264"); 22124 break; 22125 } 22126 case 27: 22127 if (result.videoPid === -1) { 22128 result.videoPid = pid; 22129 result.segmentVideoCodec = "avc"; 22130 } 22131 break; 22132 case 3: 22133 case 4: 22134 if (!typeSupported.mpeg && !typeSupported.mp3) { 22135 logger.log("MPEG audio found, not supported in this browser"); 22136 } else if (result.audioPid === -1) { 22137 result.audioPid = pid; 22138 result.segmentAudioCodec = "mp3"; 22139 } 22140 break; 22141 case 193: 22142 if (!isSampleAes) { 22143 logEncryptedSamplesFoundInUnencryptedStream("AC-3"); 22144 break; 22145 } 22146 case 129: 22147 { 22148 if (!typeSupported.ac3) { 22149 logger.log("AC-3 audio found, not supported in this browser"); 22150 } else if (result.audioPid === -1) { 22151 result.audioPid = pid; 22152 result.segmentAudioCodec = "ac3"; 22153 } 22154 } 22155 break; 22156 case 6: 22157 if (result.audioPid === -1 && esInfoLength > 0) { 22158 let parsePos = offset + 5; 22159 let remaining = esInfoLength; 22160 while (remaining > 2) { 22161 const descriptorId = data[parsePos]; 22162 switch (descriptorId) { 22163 case 106: 22164 { 22165 if (typeSupported.ac3 !== true) { 22166 logger.log("AC-3 audio found, not supported in this browser for now"); 22167 } else { 22168 result.audioPid = pid; 22169 result.segmentAudioCodec = "ac3"; 22170 } 22171 } 22172 break; 22173 } 22174 const descriptorLen = data[parsePos + 1] + 2; 22175 parsePos += descriptorLen; 22176 remaining -= descriptorLen; 22177 } 22178 } 22179 break; 22180 case 194: 22181 case 135: 22182 emitParsingError(observer2, new Error("Unsupported EC-3 in M2TS found")); 22183 return result; 22184 case 36: 22185 emitParsingError(observer2, new Error("Unsupported HEVC in M2TS found")); 22186 return result; 22187 } 22188 offset += esInfoLength + 5; 22189 } 22190 return result; 22191} 22192function emitParsingError(observer2, error, levelRetry) { 22193 logger.warn(`parsing error: ${error.message}`); 22194 observer2.emit(Events.ERROR, Events.ERROR, { 22195 type: ErrorTypes.MEDIA_ERROR, 22196 details: ErrorDetails.FRAG_PARSING_ERROR, 22197 fatal: false, 22198 levelRetry, 22199 error, 22200 reason: error.message 22201 }); 22202} 22203function logEncryptedSamplesFoundInUnencryptedStream(type) { 22204 logger.log(`${type} with AES-128-CBC encryption found in unencrypted stream`); 22205} 22206function parsePES(stream) { 22207 let i3 = 0; 22208 let frag; 22209 let pesLen; 22210 let pesHdrLen; 22211 let pesPts; 22212 let pesDts; 22213 const data = stream.data; 22214 if (!stream || stream.size === 0) { 22215 return null; 22216 } 22217 while (data[0].length < 19 && data.length > 1) { 22218 data[0] = appendUint8Array(data[0], data[1]); 22219 data.splice(1, 1); 22220 } 22221 frag = data[0]; 22222 const pesPrefix = (frag[0] << 16) + (frag[1] << 8) + frag[2]; 22223 if (pesPrefix === 1) { 22224 pesLen = (frag[4] << 8) + frag[5]; 22225 if (pesLen && pesLen > stream.size - 6) { 22226 return null; 22227 } 22228 const pesFlags = frag[7]; 22229 if (pesFlags & 192) { 22230 pesPts = (frag[9] & 14) * 536870912 + // 1 << 29 22231 (frag[10] & 255) * 4194304 + // 1 << 22 22232 (frag[11] & 254) * 16384 + // 1 << 14 22233 (frag[12] & 255) * 128 + // 1 << 7 22234 (frag[13] & 254) / 2; 22235 if (pesFlags & 64) { 22236 pesDts = (frag[14] & 14) * 536870912 + // 1 << 29 22237 (frag[15] & 255) * 4194304 + // 1 << 22 22238 (frag[16] & 254) * 16384 + // 1 << 14 22239 (frag[17] & 255) * 128 + // 1 << 7 22240 (frag[18] & 254) / 2; 22241 if (pesPts - pesDts > 60 * 9e4) { 22242 logger.warn(`${Math.round((pesPts - pesDts) / 9e4)}s delta between PTS and DTS, align them`); 22243 pesPts = pesDts; 22244 } 22245 } else { 22246 pesDts = pesPts; 22247 } 22248 } 22249 pesHdrLen = frag[8]; 22250 let payloadStartOffset = pesHdrLen + 9; 22251 if (stream.size <= payloadStartOffset) { 22252 return null; 22253 } 22254 stream.size -= payloadStartOffset; 22255 const pesData = new Uint8Array(stream.size); 22256 for (let j3 = 0, dataLen = data.length; j3 < dataLen; j3++) { 22257 frag = data[j3]; 22258 let len = frag.byteLength; 22259 if (payloadStartOffset) { 22260 if (payloadStartOffset > len) { 22261 payloadStartOffset -= len; 22262 continue; 22263 } else { 22264 frag = frag.subarray(payloadStartOffset); 22265 len -= payloadStartOffset; 22266 payloadStartOffset = 0; 22267 } 22268 } 22269 pesData.set(frag, i3); 22270 i3 += len; 22271 } 22272 if (pesLen) { 22273 pesLen -= pesHdrLen + 3; 22274 } 22275 return { 22276 data: pesData, 22277 pts: pesPts, 22278 dts: pesDts, 22279 len: pesLen 22280 }; 22281 } 22282 return null; 22283} 22284var MP3Demuxer = class extends BaseAudioDemuxer { 22285 resetInitSegment(initSegment, audioCodec, videoCodec, trackDuration) { 22286 super.resetInitSegment(initSegment, audioCodec, videoCodec, trackDuration); 22287 this._audioTrack = { 22288 container: "audio/mpeg", 22289 type: "audio", 22290 id: 2, 22291 pid: -1, 22292 sequenceNumber: 0, 22293 segmentCodec: "mp3", 22294 samples: [], 22295 manifestCodec: audioCodec, 22296 duration: trackDuration, 22297 inputTimeScale: 9e4, 22298 dropped: 0 22299 }; 22300 } 22301 static probe(data) { 22302 if (!data) { 22303 return false; 22304 } 22305 const id3Data = getID3Data(data, 0); 22306 let offset = (id3Data == null ? void 0 : id3Data.length) || 0; 22307 if (id3Data && data[offset] === 11 && data[offset + 1] === 119 && getTimeStamp(id3Data) !== void 0 && // check the bsid to confirm ac-3 or ec-3 (not mp3) 22308 getAudioBSID(data, offset) <= 16) { 22309 return false; 22310 } 22311 for (let length2 = data.length; offset < length2; offset++) { 22312 if (probe(data, offset)) { 22313 logger.log("MPEG Audio sync word found !"); 22314 return true; 22315 } 22316 } 22317 return false; 22318 } 22319 canParse(data, offset) { 22320 return canParse(data, offset); 22321 } 22322 appendFrame(track, data, offset) { 22323 if (this.basePTS === null) { 22324 return; 22325 } 22326 return appendFrame$1(track, data, offset, this.basePTS, this.frameIndex); 22327 } 22328}; 22329var AAC = class { 22330 static getSilentFrame(codec, channelCount) { 22331 switch (codec) { 22332 case "mp4a.40.2": 22333 if (channelCount === 1) { 22334 return new Uint8Array([0, 200, 0, 128, 35, 128]); 22335 } else if (channelCount === 2) { 22336 return new Uint8Array([33, 0, 73, 144, 2, 25, 0, 35, 128]); 22337 } else if (channelCount === 3) { 22338 return new Uint8Array([0, 200, 0, 128, 32, 132, 1, 38, 64, 8, 100, 0, 142]); 22339 } else if (channelCount === 4) { 22340 return new Uint8Array([0, 200, 0, 128, 32, 132, 1, 38, 64, 8, 100, 0, 128, 44, 128, 8, 2, 56]); 22341 } else if (channelCount === 5) { 22342 return new Uint8Array([0, 200, 0, 128, 32, 132, 1, 38, 64, 8, 100, 0, 130, 48, 4, 153, 0, 33, 144, 2, 56]); 22343 } else if (channelCount === 6) { 22344 return new Uint8Array([0, 200, 0, 128, 32, 132, 1, 38, 64, 8, 100, 0, 130, 48, 4, 153, 0, 33, 144, 2, 0, 178, 0, 32, 8, 224]); 22345 } 22346 break; 22347 default: 22348 if (channelCount === 1) { 22349 return new Uint8Array([1, 64, 34, 128, 163, 78, 230, 128, 186, 8, 0, 0, 0, 28, 6, 241, 193, 10, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 94]); 22350 } else if (channelCount === 2) { 22351 return new Uint8Array([1, 64, 34, 128, 163, 94, 230, 128, 186, 8, 0, 0, 0, 0, 149, 0, 6, 241, 161, 10, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 94]); 22352 } else if (channelCount === 3) { 22353 return new Uint8Array([1, 64, 34, 128, 163, 94, 230, 128, 186, 8, 0, 0, 0, 0, 149, 0, 6, 241, 161, 10, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 94]); 22354 } 22355 break; 22356 } 22357 return void 0; 22358 } 22359}; 22360var UINT32_MAX = Math.pow(2, 32) - 1; 22361var MP4 = class _MP4 { 22362 static init() { 22363 _MP4.types = { 22364 avc1: [], 22365 // codingname 22366 avcC: [], 22367 btrt: [], 22368 dinf: [], 22369 dref: [], 22370 esds: [], 22371 ftyp: [], 22372 hdlr: [], 22373 mdat: [], 22374 mdhd: [], 22375 mdia: [], 22376 mfhd: [], 22377 minf: [], 22378 moof: [], 22379 moov: [], 22380 mp4a: [], 22381 ".mp3": [], 22382 dac3: [], 22383 "ac-3": [], 22384 mvex: [], 22385 mvhd: [], 22386 pasp: [], 22387 sdtp: [], 22388 stbl: [], 22389 stco: [], 22390 stsc: [], 22391 stsd: [], 22392 stsz: [], 22393 stts: [], 22394 tfdt: [], 22395 tfhd: [], 22396 traf: [], 22397 trak: [], 22398 trun: [], 22399 trex: [], 22400 tkhd: [], 22401 vmhd: [], 22402 smhd: [] 22403 }; 22404 let i3; 22405 for (i3 in _MP4.types) { 22406 if (_MP4.types.hasOwnProperty(i3)) { 22407 _MP4.types[i3] = [i3.charCodeAt(0), i3.charCodeAt(1), i3.charCodeAt(2), i3.charCodeAt(3)]; 22408 } 22409 } 22410 const videoHdlr = new Uint8Array([ 22411 0, 22412 // version 0 22413 0, 22414 0, 22415 0, 22416 // flags 22417 0, 22418 0, 22419 0, 22420 0, 22421 // pre_defined 22422 118, 22423 105, 22424 100, 22425 101, 22426 // handler_type: 'vide' 22427 0, 22428 0, 22429 0, 22430 0, 22431 // reserved 22432 0, 22433 0, 22434 0, 22435 0, 22436 // reserved 22437 0, 22438 0, 22439 0, 22440 0, 22441 // reserved 22442 86, 22443 105, 22444 100, 22445 101, 22446 111, 22447 72, 22448 97, 22449 110, 22450 100, 22451 108, 22452 101, 22453 114, 22454 0 22455 // name: 'VideoHandler' 22456 ]); 22457 const audioHdlr = new Uint8Array([ 22458 0, 22459 // version 0 22460 0, 22461 0, 22462 0, 22463 // flags 22464 0, 22465 0, 22466 0, 22467 0, 22468 // pre_defined 22469 115, 22470 111, 22471 117, 22472 110, 22473 // handler_type: 'soun' 22474 0, 22475 0, 22476 0, 22477 0, 22478 // reserved 22479 0, 22480 0, 22481 0, 22482 0, 22483 // reserved 22484 0, 22485 0, 22486 0, 22487 0, 22488 // reserved 22489 83, 22490 111, 22491 117, 22492 110, 22493 100, 22494 72, 22495 97, 22496 110, 22497 100, 22498 108, 22499 101, 22500 114, 22501 0 22502 // name: 'SoundHandler' 22503 ]); 22504 _MP4.HDLR_TYPES = { 22505 video: videoHdlr, 22506 audio: audioHdlr 22507 }; 22508 const dref = new Uint8Array([ 22509 0, 22510 // version 0 22511 0, 22512 0, 22513 0, 22514 // flags 22515 0, 22516 0, 22517 0, 22518 1, 22519 // entry_count 22520 0, 22521 0, 22522 0, 22523 12, 22524 // entry_size 22525 117, 22526 114, 22527 108, 22528 32, 22529 // 'url' type 22530 0, 22531 // version 0 22532 0, 22533 0, 22534 1 22535 // entry_flags 22536 ]); 22537 const stco = new Uint8Array([ 22538 0, 22539 // version 22540 0, 22541 0, 22542 0, 22543 // flags 22544 0, 22545 0, 22546 0, 22547 0 22548 // entry_count 22549 ]); 22550 _MP4.STTS = _MP4.STSC = _MP4.STCO = stco; 22551 _MP4.STSZ = new Uint8Array([ 22552 0, 22553 // version 22554 0, 22555 0, 22556 0, 22557 // flags 22558 0, 22559 0, 22560 0, 22561 0, 22562 // sample_size 22563 0, 22564 0, 22565 0, 22566 0 22567 // sample_count 22568 ]); 22569 _MP4.VMHD = new Uint8Array([ 22570 0, 22571 // version 22572 0, 22573 0, 22574 1, 22575 // flags 22576 0, 22577 0, 22578 // graphicsmode 22579 0, 22580 0, 22581 0, 22582 0, 22583 0, 22584 0 22585 // opcolor 22586 ]); 22587 _MP4.SMHD = new Uint8Array([ 22588 0, 22589 // version 22590 0, 22591 0, 22592 0, 22593 // flags 22594 0, 22595 0, 22596 // balance 22597 0, 22598 0 22599 // reserved 22600 ]); 22601 _MP4.STSD = new Uint8Array([ 22602 0, 22603 // version 0 22604 0, 22605 0, 22606 0, 22607 // flags 22608 0, 22609 0, 22610 0, 22611 1 22612 ]); 22613 const majorBrand = new Uint8Array([105, 115, 111, 109]); 22614 const avc1Brand = new Uint8Array([97, 118, 99, 49]); 22615 const minorVersion = new Uint8Array([0, 0, 0, 1]); 22616 _MP4.FTYP = _MP4.box(_MP4.types.ftyp, majorBrand, minorVersion, majorBrand, avc1Brand); 22617 _MP4.DINF = _MP4.box(_MP4.types.dinf, _MP4.box(_MP4.types.dref, dref)); 22618 } 22619 static box(type, ...payload) { 22620 let size = 8; 22621 let i3 = payload.length; 22622 const len = i3; 22623 while (i3--) { 22624 size += payload[i3].byteLength; 22625 } 22626 const result = new Uint8Array(size); 22627 result[0] = size >> 24 & 255; 22628 result[1] = size >> 16 & 255; 22629 result[2] = size >> 8 & 255; 22630 result[3] = size & 255; 22631 result.set(type, 4); 22632 for (i3 = 0, size = 8; i3 < len; i3++) { 22633 result.set(payload[i3], size); 22634 size += payload[i3].byteLength; 22635 } 22636 return result; 22637 } 22638 static hdlr(type) { 22639 return _MP4.box(_MP4.types.hdlr, _MP4.HDLR_TYPES[type]); 22640 } 22641 static mdat(data) { 22642 return _MP4.box(_MP4.types.mdat, data); 22643 } 22644 static mdhd(timescale, duration) { 22645 duration *= timescale; 22646 const upperWordDuration = Math.floor(duration / (UINT32_MAX + 1)); 22647 const lowerWordDuration = Math.floor(duration % (UINT32_MAX + 1)); 22648 return _MP4.box(_MP4.types.mdhd, new Uint8Array([ 22649 1, 22650 // version 1 22651 0, 22652 0, 22653 0, 22654 // flags 22655 0, 22656 0, 22657 0, 22658 0, 22659 0, 22660 0, 22661 0, 22662 2, 22663 // creation_time 22664 0, 22665 0, 22666 0, 22667 0, 22668 0, 22669 0, 22670 0, 22671 3, 22672 // modification_time 22673 timescale >> 24 & 255, 22674 timescale >> 16 & 255, 22675 timescale >> 8 & 255, 22676 timescale & 255, 22677 // timescale 22678 upperWordDuration >> 24, 22679 upperWordDuration >> 16 & 255, 22680 upperWordDuration >> 8 & 255, 22681 upperWordDuration & 255, 22682 lowerWordDuration >> 24, 22683 lowerWordDuration >> 16 & 255, 22684 lowerWordDuration >> 8 & 255, 22685 lowerWordDuration & 255, 22686 85, 22687 196, 22688 // 'und' language (undetermined) 22689 0, 22690 0 22691 ])); 22692 } 22693 static mdia(track) { 22694 return _MP4.box(_MP4.types.mdia, _MP4.mdhd(track.timescale, track.duration), _MP4.hdlr(track.type), _MP4.minf(track)); 22695 } 22696 static mfhd(sequenceNumber) { 22697 return _MP4.box(_MP4.types.mfhd, new Uint8Array([ 22698 0, 22699 0, 22700 0, 22701 0, 22702 // flags 22703 sequenceNumber >> 24, 22704 sequenceNumber >> 16 & 255, 22705 sequenceNumber >> 8 & 255, 22706 sequenceNumber & 255 22707 // sequence_number 22708 ])); 22709 } 22710 static minf(track) { 22711 if (track.type === "audio") { 22712 return _MP4.box(_MP4.types.minf, _MP4.box(_MP4.types.smhd, _MP4.SMHD), _MP4.DINF, _MP4.stbl(track)); 22713 } else { 22714 return _MP4.box(_MP4.types.minf, _MP4.box(_MP4.types.vmhd, _MP4.VMHD), _MP4.DINF, _MP4.stbl(track)); 22715 } 22716 } 22717 static moof(sn, baseMediaDecodeTime, track) { 22718 return _MP4.box(_MP4.types.moof, _MP4.mfhd(sn), _MP4.traf(track, baseMediaDecodeTime)); 22719 } 22720 static moov(tracks) { 22721 let i3 = tracks.length; 22722 const boxes = []; 22723 while (i3--) { 22724 boxes[i3] = _MP4.trak(tracks[i3]); 22725 } 22726 return _MP4.box.apply(null, [_MP4.types.moov, _MP4.mvhd(tracks[0].timescale, tracks[0].duration)].concat(boxes).concat(_MP4.mvex(tracks))); 22727 } 22728 static mvex(tracks) { 22729 let i3 = tracks.length; 22730 const boxes = []; 22731 while (i3--) { 22732 boxes[i3] = _MP4.trex(tracks[i3]); 22733 } 22734 return _MP4.box.apply(null, [_MP4.types.mvex, ...boxes]); 22735 } 22736 static mvhd(timescale, duration) { 22737 duration *= timescale; 22738 const upperWordDuration = Math.floor(duration / (UINT32_MAX + 1)); 22739 const lowerWordDuration = Math.floor(duration % (UINT32_MAX + 1)); 22740 const bytes = new Uint8Array([ 22741 1, 22742 // version 1 22743 0, 22744 0, 22745 0, 22746 // flags 22747 0, 22748 0, 22749 0, 22750 0, 22751 0, 22752 0, 22753 0, 22754 2, 22755 // creation_time 22756 0, 22757 0, 22758 0, 22759 0, 22760 0, 22761 0, 22762 0, 22763 3, 22764 // modification_time 22765 timescale >> 24 & 255, 22766 timescale >> 16 & 255, 22767 timescale >> 8 & 255, 22768 timescale & 255, 22769 // timescale 22770 upperWordDuration >> 24, 22771 upperWordDuration >> 16 & 255, 22772 upperWordDuration >> 8 & 255, 22773 upperWordDuration & 255, 22774 lowerWordDuration >> 24, 22775 lowerWordDuration >> 16 & 255, 22776 lowerWordDuration >> 8 & 255, 22777 lowerWordDuration & 255, 22778 0, 22779 1, 22780 0, 22781 0, 22782 // 1.0 rate 22783 1, 22784 0, 22785 // 1.0 volume 22786 0, 22787 0, 22788 // reserved 22789 0, 22790 0, 22791 0, 22792 0, 22793 // reserved 22794 0, 22795 0, 22796 0, 22797 0, 22798 // reserved 22799 0, 22800 1, 22801 0, 22802 0, 22803 0, 22804 0, 22805 0, 22806 0, 22807 0, 22808 0, 22809 0, 22810 0, 22811 0, 22812 0, 22813 0, 22814 0, 22815 0, 22816 1, 22817 0, 22818 0, 22819 0, 22820 0, 22821 0, 22822 0, 22823 0, 22824 0, 22825 0, 22826 0, 22827 0, 22828 0, 22829 0, 22830 0, 22831 64, 22832 0, 22833 0, 22834 0, 22835 // transformation: unity matrix 22836 0, 22837 0, 22838 0, 22839 0, 22840 0, 22841 0, 22842 0, 22843 0, 22844 0, 22845 0, 22846 0, 22847 0, 22848 0, 22849 0, 22850 0, 22851 0, 22852 0, 22853 0, 22854 0, 22855 0, 22856 0, 22857 0, 22858 0, 22859 0, 22860 // pre_defined 22861 255, 22862 255, 22863 255, 22864 255 22865 // next_track_ID 22866 ]); 22867 return _MP4.box(_MP4.types.mvhd, bytes); 22868 } 22869 static sdtp(track) { 22870 const samples = track.samples || []; 22871 const bytes = new Uint8Array(4 + samples.length); 22872 let i3; 22873 let flags; 22874 for (i3 = 0; i3 < samples.length; i3++) { 22875 flags = samples[i3].flags; 22876 bytes[i3 + 4] = flags.dependsOn << 4 | flags.isDependedOn << 2 | flags.hasRedundancy; 22877 } 22878 return _MP4.box(_MP4.types.sdtp, bytes); 22879 } 22880 static stbl(track) { 22881 return _MP4.box(_MP4.types.stbl, _MP4.stsd(track), _MP4.box(_MP4.types.stts, _MP4.STTS), _MP4.box(_MP4.types.stsc, _MP4.STSC), _MP4.box(_MP4.types.stsz, _MP4.STSZ), _MP4.box(_MP4.types.stco, _MP4.STCO)); 22882 } 22883 static avc1(track) { 22884 let sps = []; 22885 let pps = []; 22886 let i3; 22887 let data; 22888 let len; 22889 for (i3 = 0; i3 < track.sps.length; i3++) { 22890 data = track.sps[i3]; 22891 len = data.byteLength; 22892 sps.push(len >>> 8 & 255); 22893 sps.push(len & 255); 22894 sps = sps.concat(Array.prototype.slice.call(data)); 22895 } 22896 for (i3 = 0; i3 < track.pps.length; i3++) { 22897 data = track.pps[i3]; 22898 len = data.byteLength; 22899 pps.push(len >>> 8 & 255); 22900 pps.push(len & 255); 22901 pps = pps.concat(Array.prototype.slice.call(data)); 22902 } 22903 const avcc = _MP4.box(_MP4.types.avcC, new Uint8Array([ 22904 1, 22905 // version 22906 sps[3], 22907 // profile 22908 sps[4], 22909 // profile compat 22910 sps[5], 22911 // level 22912 252 | 3, 22913 // lengthSizeMinusOne, hard-coded to 4 bytes 22914 224 | track.sps.length 22915 // 3bit reserved (111) + numOfSequenceParameterSets 22916 ].concat(sps).concat([ 22917 track.pps.length 22918 // numOfPictureParameterSets 22919 ]).concat(pps))); 22920 const width = track.width; 22921 const height = track.height; 22922 const hSpacing = track.pixelRatio[0]; 22923 const vSpacing = track.pixelRatio[1]; 22924 return _MP4.box( 22925 _MP4.types.avc1, 22926 new Uint8Array([ 22927 0, 22928 0, 22929 0, 22930 // reserved 22931 0, 22932 0, 22933 0, 22934 // reserved 22935 0, 22936 1, 22937 // data_reference_index 22938 0, 22939 0, 22940 // pre_defined 22941 0, 22942 0, 22943 // reserved 22944 0, 22945 0, 22946 0, 22947 0, 22948 0, 22949 0, 22950 0, 22951 0, 22952 0, 22953 0, 22954 0, 22955 0, 22956 // pre_defined 22957 width >> 8 & 255, 22958 width & 255, 22959 // width 22960 height >> 8 & 255, 22961 height & 255, 22962 // height 22963 0, 22964 72, 22965 0, 22966 0, 22967 // horizresolution 22968 0, 22969 72, 22970 0, 22971 0, 22972 // vertresolution 22973 0, 22974 0, 22975 0, 22976 0, 22977 // reserved 22978 0, 22979 1, 22980 // frame_count 22981 18, 22982 100, 22983 97, 22984 105, 22985 108, 22986
vendor: 11,385 bytes, lines 22986-23509
22986// dailymotion/hls.js 22987 121, 22988 109, 22989 111, 22990 116, 22991 105, 22992 111, 22993 110, 22994 47, 22995 104, 22996 108, 22997 115, 22998 46, 22999 106, 23000 115, 23001 0, 23002 0, 23003 0, 23004 0, 23005 0, 23006 0, 23007 0, 23008 0, 23009 0, 23010 0, 23011 0, 23012 0, 23013 0, 23014 // compressorname 23015 0, 23016 24, 23017 // depth = 24 23018 17, 23019 17 23020 ]), 23021 // pre_defined = -1 23022 avcc, 23023 _MP4.box(_MP4.types.btrt, new Uint8Array([ 23024 0, 23025 28, 23026 156, 23027 128, 23028 // bufferSizeDB 23029 0, 23030 45, 23031 198, 23032 192, 23033 // maxBitrate 23034 0, 23035 45, 23036 198, 23037 192 23038 ])), 23039 // avgBitrate 23040 _MP4.box(_MP4.types.pasp, new Uint8Array([ 23041 hSpacing >> 24, 23042 // hSpacing 23043 hSpacing >> 16 & 255, 23044 hSpacing >> 8 & 255, 23045 hSpacing & 255, 23046 vSpacing >> 24, 23047 // vSpacing 23048 vSpacing >> 16 & 255, 23049 vSpacing >> 8 & 255, 23050 vSpacing & 255 23051 ])) 23052 ); 23053 } 23054 static esds(track) { 23055 const configlen = track.config.length; 23056 return new Uint8Array([ 23057 0, 23058 // version 0 23059 0, 23060 0, 23061 0, 23062 // flags 23063 3, 23064 // descriptor_type 23065 23 + configlen, 23066 // length 23067 0, 23068 1, 23069 // es_id 23070 0, 23071 // stream_priority 23072 4, 23073 // descriptor_type 23074 15 + configlen, 23075 // length 23076 64, 23077 // codec : mpeg4_audio 23078 21, 23079 // stream_type 23080 0, 23081 0, 23082 0, 23083 // buffer_size 23084 0, 23085 0, 23086 0, 23087 0, 23088 // maxBitrate 23089 0, 23090 0, 23091 0, 23092 0, 23093 // avgBitrate 23094 5 23095 // descriptor_type 23096 ].concat([configlen]).concat(track.config).concat([6, 1, 2])); 23097 } 23098 static audioStsd(track) { 23099 const samplerate = track.samplerate; 23100 return new Uint8Array([ 23101 0, 23102 0, 23103 0, 23104 // reserved 23105 0, 23106 0, 23107 0, 23108 // reserved 23109 0, 23110 1, 23111 // data_reference_index 23112 0, 23113 0, 23114 0, 23115 0, 23116 0, 23117 0, 23118 0, 23119 0, 23120 // reserved 23121 0, 23122 track.channelCount, 23123 // channelcount 23124 0, 23125 16, 23126 // sampleSize:16bits 23127 0, 23128 0, 23129 0, 23130 0, 23131 // reserved2 23132 samplerate >> 8 & 255, 23133 samplerate & 255, 23134 // 23135 0, 23136 0 23137 ]); 23138 } 23139 static mp4a(track) { 23140 return _MP4.box(_MP4.types.mp4a, _MP4.audioStsd(track), _MP4.box(_MP4.types.esds, _MP4.esds(track))); 23141 } 23142 static mp3(track) { 23143 return _MP4.box(_MP4.types[".mp3"], _MP4.audioStsd(track)); 23144 } 23145 static ac3(track) { 23146 return _MP4.box(_MP4.types["ac-3"], _MP4.audioStsd(track), _MP4.box(_MP4.types.dac3, track.config)); 23147 } 23148 static stsd(track) { 23149 if (track.type === "audio") { 23150 if (track.segmentCodec === "mp3" && track.codec === "mp3") { 23151 return _MP4.box(_MP4.types.stsd, _MP4.STSD, _MP4.mp3(track)); 23152 } 23153 if (track.segmentCodec === "ac3") { 23154 return _MP4.box(_MP4.types.stsd, _MP4.STSD, _MP4.ac3(track)); 23155 } 23156 return _MP4.box(_MP4.types.stsd, _MP4.STSD, _MP4.mp4a(track)); 23157 } else { 23158 return _MP4.box(_MP4.types.stsd, _MP4.STSD, _MP4.avc1(track)); 23159 } 23160 } 23161 static tkhd(track) { 23162 const id = track.id; 23163 const duration = track.duration * track.timescale; 23164 const width = track.width; 23165 const height = track.height; 23166 const upperWordDuration = Math.floor(duration / (UINT32_MAX + 1)); 23167 const lowerWordDuration = Math.floor(duration % (UINT32_MAX + 1)); 23168 return _MP4.box(_MP4.types.tkhd, new Uint8Array([ 23169 1, 23170 // version 1 23171 0, 23172 0, 23173 7, 23174 // flags 23175 0, 23176 0, 23177 0, 23178 0, 23179 0, 23180 0, 23181 0, 23182 2, 23183 // creation_time 23184 0, 23185 0, 23186 0, 23187 0, 23188 0, 23189 0, 23190 0, 23191 3, 23192 // modification_time 23193 id >> 24 & 255, 23194 id >> 16 & 255, 23195 id >> 8 & 255, 23196 id & 255, 23197 // track_ID 23198 0, 23199 0, 23200 0, 23201 0, 23202 // reserved 23203 upperWordDuration >> 24, 23204 upperWordDuration >> 16 & 255, 23205 upperWordDuration >> 8 & 255, 23206 upperWordDuration & 255, 23207 lowerWordDuration >> 24, 23208 lowerWordDuration >> 16 & 255, 23209 lowerWordDuration >> 8 & 255, 23210 lowerWordDuration & 255, 23211 0, 23212 0, 23213 0, 23214 0, 23215 0, 23216 0, 23217 0, 23218 0, 23219 // reserved 23220 0, 23221 0, 23222 // layer 23223 0, 23224 0, 23225 // alternate_group 23226 0, 23227 0, 23228 // non-audio track volume 23229 0, 23230 0, 23231 // reserved 23232 0, 23233 1, 23234 0, 23235 0, 23236 0, 23237 0, 23238 0, 23239 0, 23240 0, 23241 0, 23242 0, 23243 0, 23244 0, 23245 0, 23246 0, 23247 0, 23248 0, 23249 1, 23250 0, 23251 0, 23252 0, 23253 0, 23254 0, 23255 0, 23256 0, 23257 0, 23258 0, 23259 0, 23260 0, 23261 0, 23262 0, 23263 0, 23264 64, 23265 0, 23266 0, 23267 0, 23268 // transformation: unity matrix 23269 width >> 8 & 255, 23270 width & 255, 23271 0, 23272 0, 23273 // width 23274 height >> 8 & 255, 23275 height & 255, 23276 0, 23277 0 23278 // height 23279 ])); 23280 } 23281 static traf(track, baseMediaDecodeTime) { 23282 const sampleDependencyTable = _MP4.sdtp(track); 23283 const id = track.id; 23284 const upperWordBaseMediaDecodeTime = Math.floor(baseMediaDecodeTime / (UINT32_MAX + 1)); 23285 const lowerWordBaseMediaDecodeTime = Math.floor(baseMediaDecodeTime % (UINT32_MAX + 1)); 23286 return _MP4.box( 23287 _MP4.types.traf, 23288 _MP4.box(_MP4.types.tfhd, new Uint8Array([ 23289 0, 23290 // version 0 23291 0, 23292 0, 23293 0, 23294 // flags 23295 id >> 24, 23296 id >> 16 & 255, 23297 id >> 8 & 255, 23298 id & 255 23299 // track_ID 23300 ])), 23301 _MP4.box(_MP4.types.tfdt, new Uint8Array([ 23302 1, 23303 // version 1 23304 0, 23305 0, 23306 0, 23307 // flags 23308 upperWordBaseMediaDecodeTime >> 24, 23309 upperWordBaseMediaDecodeTime >> 16 & 255, 23310 upperWordBaseMediaDecodeTime >> 8 & 255, 23311 upperWordBaseMediaDecodeTime & 255, 23312 lowerWordBaseMediaDecodeTime >> 24, 23313 lowerWordBaseMediaDecodeTime >> 16 & 255, 23314 lowerWordBaseMediaDecodeTime >> 8 & 255, 23315 lowerWordBaseMediaDecodeTime & 255 23316 ])), 23317 _MP4.trun(track, sampleDependencyTable.length + 16 + // tfhd 23318 20 + // tfdt 23319 8 + // traf header 23320 16 + // mfhd 23321 8 + // moof header 23322 8), 23323 // mdat header 23324 sampleDependencyTable 23325 ); 23326 } 23327 /** 23328 * Generate a track box. 23329 * @param track a track definition 23330 */ 23331 static trak(track) { 23332 track.duration = track.duration || 4294967295; 23333 return _MP4.box(_MP4.types.trak, _MP4.tkhd(track), _MP4.mdia(track)); 23334 } 23335 static trex(track) { 23336 const id = track.id; 23337 return _MP4.box(_MP4.types.trex, new Uint8Array([ 23338 0, 23339 // version 0 23340 0, 23341 0, 23342 0, 23343 // flags 23344 id >> 24, 23345 id >> 16 & 255, 23346 id >> 8 & 255, 23347 id & 255, 23348 // track_ID 23349 0, 23350 0, 23351 0, 23352 1, 23353 // default_sample_description_index 23354 0, 23355 0, 23356 0, 23357 0, 23358 // default_sample_duration 23359 0, 23360 0, 23361 0, 23362 0, 23363 // default_sample_size 23364 0, 23365 1, 23366 0, 23367 1 23368 // default_sample_flags 23369 ])); 23370 } 23371 static trun(track, offset) { 23372 const samples = track.samples || []; 23373 const len = samples.length; 23374 const arraylen = 12 + 16 * len; 23375 const array = new Uint8Array(arraylen); 23376 let i3; 23377 let sample; 23378 let duration; 23379 let size; 23380 let flags; 23381 let cts; 23382 offset += 8 + arraylen; 23383 array.set([ 23384 track.type === "video" ? 1 : 0, 23385 // version 1 for video with signed-int sample_composition_time_offset 23386 0, 23387 15, 23388 1, 23389 // flags 23390 len >>> 24 & 255, 23391 len >>> 16 & 255, 23392 len >>> 8 & 255, 23393 len & 255, 23394 // sample_count 23395 offset >>> 24 & 255, 23396 offset >>> 16 & 255, 23397 offset >>> 8 & 255, 23398 offset & 255 23399 // data_offset 23400 ], 0); 23401 for (i3 = 0; i3 < len; i3++) { 23402 sample = samples[i3]; 23403 duration = sample.duration; 23404 size = sample.size; 23405 flags = sample.flags; 23406 cts = sample.cts; 23407 array.set([ 23408 duration >>> 24 & 255, 23409 duration >>> 16 & 255, 23410 duration >>> 8 & 255, 23411 duration & 255, 23412 // sample_duration 23413 size >>> 24 & 255, 23414 size >>> 16 & 255, 23415 size >>> 8 & 255, 23416 size & 255, 23417 // sample_size 23418 flags.isLeading << 2 | flags.dependsOn, 23419 flags.isDependedOn << 6 | flags.hasRedundancy << 4 | flags.paddingValue << 1 | flags.isNonSync, 23420 flags.degradPrio & 240 << 8, 23421 flags.degradPrio & 15, 23422 // sample_flags 23423 cts >>> 24 & 255, 23424 cts >>> 16 & 255, 23425 cts >>> 8 & 255, 23426 cts & 255 23427 // sample_composition_time_offset 23428 ], 12 + 16 * i3); 23429 } 23430 return _MP4.box(_MP4.types.trun, array); 23431 } 23432 static initSegment(tracks) { 23433 if (!_MP4.types) { 23434 _MP4.init(); 23435 } 23436 const movie = _MP4.moov(tracks); 23437 const result = appendUint8Array(_MP4.FTYP, movie); 23438 return result; 23439 } 23440}; 23441MP4.types = void 0; 23442MP4.HDLR_TYPES = void 0; 23443MP4.STTS = void 0; 23444MP4.STSC = void 0; 23445MP4.STCO = void 0; 23446MP4.STSZ = void 0; 23447MP4.VMHD = void 0; 23448MP4.SMHD = void 0; 23449MP4.STSD = void 0; 23450MP4.FTYP = void 0; 23451MP4.DINF = void 0; 23452var MPEG_TS_CLOCK_FREQ_HZ = 9e4; 23453function toTimescaleFromBase(baseTime, destScale, srcBase = 1, round = false) { 23454 const result = baseTime * destScale * srcBase; 23455 return round ? Math.round(result) : result; 23456} 23457function toTimescaleFromScale(baseTime, destScale, srcScale = 1, round = false) { 23458 return toTimescaleFromBase(baseTime, destScale, 1 / srcScale, round); 23459} 23460function toMsFromMpegTsClock(baseTime, round = false) { 23461 return toTimescaleFromBase(baseTime, 1e3, 1 / MPEG_TS_CLOCK_FREQ_HZ, round); 23462} 23463function toMpegTsClockFromTimescale(baseTime, srcScale = 1) { 23464 return toTimescaleFromBase(baseTime, MPEG_TS_CLOCK_FREQ_HZ, 1 / srcScale); 23465} 23466var MAX_SILENT_FRAME_DURATION = 10 * 1e3; 23467var AAC_SAMPLES_PER_FRAME = 1024; 23468var MPEG_AUDIO_SAMPLE_PER_FRAME = 1152; 23469var AC3_SAMPLES_PER_FRAME = 1536; 23470var chromeVersion = null; 23471var safariWebkitVersion = null; 23472var MP4Remuxer = class { 23473 constructor(observer2, config, typeSupported, vendor = "") { 23474 this.observer = void 0; 23475 this.config = void 0; 23476 this.typeSupported = void 0; 23477 this.ISGenerated = false; 23478 this._initPTS = null; 23479 this._initDTS = null; 23480 this.nextAvcDts = null; 23481 this.nextAudioPts = null; 23482 this.videoSampleDuration = null; 23483 this.isAudioContiguous = false; 23484 this.isVideoContiguous = false; 23485 this.videoTrackConfig = void 0; 23486 this.observer = observer2; 23487 this.config = config; 23488 this.typeSupported = typeSupported; 23489 this.ISGenerated = false; 23490 if (chromeVersion === null) { 23491 const userAgent = navigator.userAgent || ""; 23492 const result = userAgent.match(/Chrome\/(\d+)/i); 23493 chromeVersion = result ? parseInt(result[1]) : 0; 23494 } 23495 if (safariWebkitVersion === null) { 23496 const result = navigator.userAgent.match(/Safari\/(\d+)/i); 23497 safariWebkitVersion = result ? parseInt(result[1]) : 0; 23498 } 23499 } 23500 destroy() { 23501 this.config = this.videoTrackConfig = this._initPTS = this._initDTS = null; 23502 } 23503 resetTimeStamp(defaultTimeStamp) { 23504 logger.log("[mp4-remuxer]: initPTS & initDTS reset"); 23505 this._initPTS = this._initDTS = defaultTimeStamp; 23506 } 23507 resetNextTimestamp() { 23508 logger.log("[mp4-remuxer]: reset next timestamp"); 23509 this.isVideoContiguous = false;
vendor: 4,168 bytes, lines 23510-23596
23510 this.isAudioContiguous = false; 23511 } 23512 resetInitSegment() { 23513 logger.log("[mp4-remuxer]: ISGenerated flag reset"); 23514 this.ISGenerated = false; 23515 this.videoTrackConfig = void 0; 23516 } 23517 getVideoStartPts(videoSamples) { 23518 let rolloverDetected = false; 23519 const firstPts = videoSamples[0].pts; 23520 const startPTS = videoSamples.reduce((minPTS, sample) => { 23521 let pts = sample.pts; 23522 let delta = pts - minPTS; 23523 if (delta < -4294967296) { 23524 rolloverDetected = true; 23525 pts = normalizePts(pts, firstPts); 23526 delta = pts - minPTS; 23527 } 23528 if (delta > 0) { 23529 return minPTS; 23530 } 23531 return pts; 23532 }, firstPts); 23533 if (rolloverDetected) { 23534 logger.debug("PTS rollover detected"); 23535 } 23536 return startPTS; 23537 } 23538 remux(audioTrack, videoTrack, id3Track, textTrack, timeOffset, accurateTimeOffset, flush, playlistType) { 23539 let video; 23540 let audio; 23541 let initSegment; 23542 let text; 23543 let id3; 23544 let independent; 23545 let audioTimeOffset = timeOffset; 23546 let videoTimeOffset = timeOffset; 23547 const hasAudio = audioTrack.pid > -1; 23548 const hasVideo = videoTrack.pid > -1; 23549 const length2 = videoTrack.samples.length; 23550 const enoughAudioSamples = audioTrack.samples.length > 0; 23551 const enoughVideoSamples = flush && length2 > 0 || length2 > 1; 23552 const canRemuxAvc = (!hasAudio || enoughAudioSamples) && (!hasVideo || enoughVideoSamples) || this.ISGenerated || flush; 23553 if (canRemuxAvc) { 23554 if (this.ISGenerated) { 23555 var _videoTrack$pixelRati, _config$pixelRatio, _videoTrack$pixelRati2, _config$pixelRatio2; 23556 const config = this.videoTrackConfig; 23557 if (config && (videoTrack.width !== config.width || videoTrack.height !== config.height || ((_videoTrack$pixelRati = videoTrack.pixelRatio) == null ? void 0 : _videoTrack$pixelRati[0]) !== ((_config$pixelRatio = config.pixelRatio) == null ? void 0 : _config$pixelRatio[0]) || ((_videoTrack$pixelRati2 = videoTrack.pixelRatio) == null ? void 0 : _videoTrack$pixelRati2[1]) !== ((_config$pixelRatio2 = config.pixelRatio) == null ? void 0 : _config$pixelRatio2[1]))) { 23558 this.resetInitSegment(); 23559 } 23560 } else { 23561 initSegment = this.generateIS(audioTrack, videoTrack, timeOffset, accurateTimeOffset); 23562 } 23563 const isVideoContiguous = this.isVideoContiguous; 23564 let firstKeyFrameIndex = -1; 23565 let firstKeyFramePTS; 23566 if (enoughVideoSamples) { 23567 firstKeyFrameIndex = findKeyframeIndex(videoTrack.samples); 23568 if (!isVideoContiguous && this.config.forceKeyFrameOnDiscontinuity) { 23569 independent = true; 23570 if (firstKeyFrameIndex > 0) { 23571 logger.warn(`[mp4-remuxer]: Dropped ${firstKeyFrameIndex} out of ${length2} video samples due to a missing keyframe`); 23572 const startPTS = this.getVideoStartPts(videoTrack.samples); 23573 videoTrack.samples = videoTrack.samples.slice(firstKeyFrameIndex); 23574 videoTrack.dropped += firstKeyFrameIndex; 23575 videoTimeOffset += (videoTrack.samples[0].pts - startPTS) / videoTrack.inputTimeScale; 23576 firstKeyFramePTS = videoTimeOffset; 23577 } else if (firstKeyFrameIndex === -1) { 23578 logger.warn(`[mp4-remuxer]: No keyframe found out of ${length2} video samples`); 23579 independent = false; 23580 } 23581 } 23582 } 23583 if (this.ISGenerated) { 23584 if (enoughAudioSamples && enoughVideoSamples) { 23585 const startPTS = this.getVideoStartPts(videoTrack.samples); 23586 const tsDelta = normalizePts(audioTrack.samples[0].pts, startPTS) - startPTS; 23587 const audiovideoTimestampDelta = tsDelta / videoTrack.inputTimeScale; 23588 audioTimeOffset += Math.max(0, audiovideoTimestampDelta); 23589 videoTimeOffset += Math.max(0, -audiovideoTimestampDelta); 23590 } 23591 if (enoughAudioSamples) { 23592 if (!audioTrack.samplerate) { 23593 logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"); 23594 initSegment = this.generateIS(audioTrack, videoTrack, timeOffset, accurateTimeOffset); 23595 } 23596 audio = this.remuxAudio(audioTrack, audioTimeOffset, this.isAudioContiguous, accurateTimeOff
23596set, hasVideo || enoughVideoSamples || playlistType === PlaylistLevelType.AUDIO ? videoTimeOffset : void 0); 23597 if (enoughVideoSamples) { 23598 const audioTrackLength = audio ? audio.endPTS - audio.startPTS : 0; 23599 if (!videoTrack.inputTimeScale) { 23600 logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"); 23601 initSegment = this.generateIS(audioTrack, videoTrack, timeOffset, accurateTimeOffset); 23602 } 23603 video = this.remuxVideo(videoTrack, videoTimeOffset, isVideoContiguous, audioTrackLength); 23604 } 23605 } else if (enoughVideoSamples) { 23606 video = this.remuxVideo(videoTrack, videoTimeOffset, isVideoContiguous, 0); 23607 } 23608 if (video) { 23609 video.firstKeyFrame = firstKeyFrameIndex; 23610 video.independent = firstKeyFrameIndex !== -1; 23611 video.firstKeyFramePTS = firstKeyFramePTS; 23612 } 23613 } 23614 } 23615 if (this.ISGenerated && this._initPTS && this._initDTS) { 23616 if (id3Track.samples.length) { 23617 id3 = flushTextTrackMetadataCueSamples(id3Track, timeOffset, this._initPTS, this._initDTS); 23618 } 23619 if (textTrack.samples.length) { 23620 text = flushTextTrackUserdataCueSamples(textTrack, timeOffset, this._initPTS); 23621 } 23622 } 23623 return { 23624 audio, 23625 video, 23626 initSegment, 23627 independent, 23628 text, 23629 id3 23630 }; 23631 } 23632 generateIS(audioTrack, videoTrack, timeOffset, accurateTimeOffset) { 23633 const audioSamples = audioTrack.samples; 23634 const videoSamples = videoTrack.samples; 23635 const typeSupported = this.typeSupported; 23636 const tracks = {}; 23637 const _initPTS = this._initPTS; 23638 let computePTSDTS = !_initPTS || accurateTimeOffset; 23639 let container = "audio/mp4"; 23640 let initPTS; 23641 let initDTS; 23642 let timescale; 23643 if (computePTSDTS) { 23644 initPTS = initDTS = Infinity; 23645 } 23646 if (audioTrack.config && audioSamples.length) { 23647 audioTrack.timescale = audioTrack.samplerate; 23648 switch (audioTrack.segmentCodec) { 23649 case "mp3": 23650 if (typeSupported.mpeg) { 23651 container = "audio/mpeg"; 23652 audioTrack.codec = ""; 23653 } else if (typeSupported.mp3) { 23654 audioTrack.codec = "mp3"; 23655 } 23656 break; 23657 case "ac3": 23658 audioTrack.codec = "ac-3"; 23659 break; 23660 } 23661 tracks.audio = { 23662 id: "audio", 23663 container, 23664 codec: audioTrack.codec, 23665 initSegment: audioTrack.segmentCodec === "mp3" && typeSupported.mpeg ? new Uint8Array(0) : MP4.initSegment([audioTrack]), 23666 metadata: { 23667 channelCount: audioTrack.channelCount 23668 } 23669 }; 23670 if (computePTSDTS) { 23671 timescale = audioTrack.inputTimeScale; 23672 if (!_initPTS || timescale !== _initPTS.timescale) { 23673 initPTS = initDTS = audioSamples[0].pts - Math.round(timescale * timeOffset); 23674 } else { 23675 computePTSDTS = false; 23676 } 23677 } 23678 } 23679 if (videoTrack.sps && videoTrack.pps && videoSamples.length) { 23680 videoTrack.timescale = videoTrack.inputTimeScale; 23681 tracks.video = { 23682 id: "main", 23683 container: "video/mp4", 23684 codec: videoTrack.codec, 23685 initSegment: MP4.initSegment([videoTrack]), 23686 metadata: { 23687 width: videoTrack.width, 23688 height: videoTrack.height 23689 } 23690 }; 23691 if (computePTSDTS) { 23692 timescale = videoTrack.inputTimeScale; 23693 if (!_initPTS || timescale !== _initPTS.timescale) { 23694 const startPTS = this.getVideoStartPts(videoSamples); 23695 const startOffset = Math.round(timescale * timeOffset); 23696 initDTS = Math.min(initDTS, normalizePts(videoSamples[0].dts, startPTS) - startOffset); 23697 initPTS = Math.min(initPTS, startPTS - startOffset); 23698 } else { 23699 computePTSDTS = false; 23700 } 23701 } 23702 this.videoTrackConfig = { 23703 width: videoTrack.width, 23704 height: videoTrack.height, 23705 pixelRatio: videoTrack.pixelRatio 23706 }; 23707 } 23708 if (Object.keys(tracks).length) { 23709 this.ISGenerated = true; 23710 if (computePTSDTS) { 23711 this._initPTS = { 23712 baseTime: initPTS, 23713 timescale 23714 }; 23715 this._initDTS = { 23716 baseTime: initDTS, 23717 timescale 23718 }; 23719 } else { 23720 initPTS = timescale = void 0; 23721 } 23722 return { 23723 tracks, 23724 initPTS, 23725 timescale 23726 }; 23727 } 23728 } 23729 remuxVideo(track, timeOffset, contiguous, audioTrackLength) { 23730 const timeScale = track.inputTimeScale; 23731 const inputSamples = track.samples; 23732 const outputSamples = []; 23733 const nbSamples = inputSamples.length; 23734 const initPTS = this._initPTS; 23735 let nextAvcDts = this.nextAvcDts; 23736 let offset = 8; 23737 let mp4SampleDuration = this.videoSampleDuration; 23738 let firstDTS; 23739 let lastDTS; 23740 let minPTS = Number.POSITIVE_INFINITY; 23741 let maxPTS = Number.NEGATIVE_INFINITY; 23742 let sortSamples = false;
vendor: 6,839 bytes, lines 23743-23904
23743 if (!contiguous || nextAvcDts === null) { 23744 const pts = timeOffset * timeScale; 23745 const cts = inputSamples[0].pts - normalizePts(inputSamples[0].dts, inputSamples[0].pts); 23746 if (chromeVersion && nextAvcDts !== null && Math.abs(pts - cts - nextAvcDts) < 15e3) { 23747 contiguous = true; 23748 } else { 23749 nextAvcDts = pts - cts; 23750 } 23751 } 23752 const initTime = initPTS.baseTime * timeScale / initPTS.timescale; 23753 for (let i3 = 0; i3 < nbSamples; i3++) { 23754 const sample = inputSamples[i3]; 23755 sample.pts = normalizePts(sample.pts - initTime, nextAvcDts); 23756 sample.dts = normalizePts(sample.dts - initTime, nextAvcDts); 23757 if (sample.dts < inputSamples[i3 > 0 ? i3 - 1 : i3].dts) { 23758 sortSamples = true; 23759 } 23760 } 23761 if (sortSamples) { 23762 inputSamples.sort(function(a2, b3) { 23763 const deltadts = a2.dts - b3.dts; 23764 const deltapts = a2.pts - b3.pts; 23765 return deltadts || deltapts; 23766 }); 23767 } 23768 firstDTS = inputSamples[0].dts; 23769 lastDTS = inputSamples[inputSamples.length - 1].dts; 23770 const inputDuration = lastDTS - firstDTS; 23771 const averageSampleDuration = inputDuration ? Math.round(inputDuration / (nbSamples - 1)) : mp4SampleDuration || track.inputTimeScale / 30; 23772 if (contiguous) { 23773 const delta = firstDTS - nextAvcDts; 23774 const foundHole = delta > averageSampleDuration; 23775 const foundOverlap = delta < -1; 23776 if (foundHole || foundOverlap) { 23777 if (foundHole) { 23778 logger.warn(`AVC: ${toMsFromMpegTsClock(delta, true)} ms (${delta}dts) hole between fragments detected at ${timeOffset.toFixed(3)}`); 23779 } else { 23780 logger.warn(`AVC: ${toMsFromMpegTsClock(-delta, true)} ms (${delta}dts) overlapping between fragments detected at ${timeOffset.toFixed(3)}`); 23781 } 23782 if (!foundOverlap || nextAvcDts >= inputSamples[0].pts || chromeVersion) { 23783 firstDTS = nextAvcDts; 23784 const firstPTS = inputSamples[0].pts - delta; 23785 if (foundHole) { 23786 inputSamples[0].dts = firstDTS; 23787 inputSamples[0].pts = firstPTS; 23788 } else { 23789 for (let i3 = 0; i3 < inputSamples.length; i3++) { 23790 if (inputSamples[i3].dts > firstPTS) { 23791 break; 23792 } 23793 inputSamples[i3].dts -= delta; 23794 inputSamples[i3].pts -= delta; 23795 } 23796 } 23797 logger.log(`Video: Initial PTS/DTS adjusted: ${toMsFromMpegTsClock(firstPTS, true)}/${toMsFromMpegTsClock(firstDTS, true)}, delta: ${toMsFromMpegTsClock(delta, true)} ms`); 23798 } 23799 } 23800 } 23801 firstDTS = Math.max(0, firstDTS); 23802 let nbNalu = 0; 23803 let naluLen = 0; 23804 let dtsStep = firstDTS; 23805 for (let i3 = 0; i3 < nbSamples; i3++) { 23806 const sample = inputSamples[i3]; 23807 const units = sample.units; 23808 const nbUnits = units.length; 23809 let sampleLen = 0; 23810 for (let j3 = 0; j3 < nbUnits; j3++) { 23811 sampleLen += units[j3].data.length; 23812 } 23813 naluLen += sampleLen; 23814 nbNalu += nbUnits; 23815 sample.length = sampleLen; 23816 if (sample.dts < dtsStep) { 23817 sample.dts = dtsStep; 23818 dtsStep += averageSampleDuration / 4 | 0 || 1; 23819 } else { 23820 dtsStep = sample.dts; 23821 } 23822 minPTS = Math.min(sample.pts, minPTS); 23823 maxPTS = Math.max(sample.pts, maxPTS); 23824 } 23825 lastDTS = inputSamples[nbSamples - 1].dts; 23826 const mdatSize = naluLen + 4 * nbNalu + 8; 23827 let mdat; 23828 try { 23829 mdat = new Uint8Array(mdatSize); 23830 } catch (err) { 23831 this.observer.emit(Events.ERROR, Events.ERROR, { 23832 type: ErrorTypes.MUX_ERROR, 23833 details: ErrorDetails.REMUX_ALLOC_ERROR, 23834 fatal: false, 23835 error: err, 23836 bytes: mdatSize, 23837 reason: `fail allocating video mdat ${mdatSize}` 23838 }); 23839 return; 23840 } 23841 const view = new DataView(mdat.buffer); 23842 view.setUint32(0, mdatSize); 23843 mdat.set(MP4.types.mdat, 4); 23844 let stretchedLastFrame = false; 23845 let minDtsDelta = Number.POSITIVE_INFINITY; 23846 let minPtsDelta = Number.POSITIVE_INFINITY; 23847 let maxDtsDelta = Number.NEGATIVE_INFINITY; 23848 let maxPtsDelta = Number.NEGATIVE_INFINITY; 23849 for (let i3 = 0; i3 < nbSamples; i3++) { 23850 const VideoSample = inputSamples[i3]; 23851 const VideoSampleUnits = VideoSample.units; 23852 let mp4SampleLength = 0; 23853 for (let j3 = 0, nbUnits = VideoSampleUnits.length; j3 < nbUnits; j3++) { 23854 const unit = VideoSampleUnits[j3]; 23855 const unitData = unit.data; 23856 const unitDataLen = unit.data.byteLength; 23857 view.setUint32(offset, unitDataLen); 23858 offset += 4; 23859 mdat.set(unitData, offset); 23860 offset += unitDataLen; 23861 mp4SampleLength += 4 + unitDataLen; 23862 } 23863 let ptsDelta; 23864 if (i3 < nbSamples - 1) { 23865 mp4SampleDuration = inputSamples[i3 + 1].dts - VideoSample.dts; 23866 ptsDelta = inputSamples[i3 + 1].pts - VideoSample.pts; 23867 } else { 23868 const config = this.config; 23869 const lastFrameDuration = i3 > 0 ? VideoSample.dts - inputSamples[i3 - 1].dts : averageSampleDuration; 23870 ptsDelta = i3 > 0 ? VideoSample.pts - inputSamples[i3 - 1].pts : averageSampleDuration; 23871 if (config.stretchShortVideoTrack && this.nextAudioPts !== null) { 23872 const gapTolerance = Math.floor(config.maxBufferHole * timeScale); 23873 const deltaToFrameEnd = (audioTrackLength ? minPTS + audioTrackLength * timeScale : this.nextAudioPts) - VideoSample.pts; 23874 if (deltaToFrameEnd > gapTolerance) { 23875 mp4SampleDuration = deltaToFrameEnd - lastFrameDuration; 23876 if (mp4SampleDuration < 0) { 23877 mp4SampleDuration = lastFrameDuration; 23878 } else { 23879 stretchedLastFrame = true; 23880 } 23881 logger.log(`[mp4-remuxer]: It is approximately ${deltaToFrameEnd / 90} ms to the next segment; using duration ${mp4SampleDuration / 90} ms for the last video frame.`); 23882 } else { 23883 mp4SampleDuration = lastFrameDuration; 23884 } 23885 } else { 23886 mp4SampleDuration = lastFrameDuration; 23887 } 23888 } 23889 const compositionTimeOffset = Math.round(VideoSample.pts - VideoSample.dts); 23890 minDtsDelta = Math.min(minDtsDelta, mp4SampleDuration); 23891 maxDtsDelta = Math.max(maxDtsDelta, mp4SampleDuration); 23892 minPtsDelta = Math.min(minPtsDelta, ptsDelta); 23893 maxPtsDelta = Math.max(maxPtsDelta, ptsDelta); 23894 outputSamples.push(new Mp4Sample(VideoSample.key, mp4SampleDuration, mp4SampleLength, compositionTimeOffset)); 23895 } 23896 if (outputSamples.length) { 23897 if (chromeVersion) { 23898 if (chromeVersion < 70) { 23899 const flags = outputSamples[0].flags; 23900 flags.dependsOn = 2; 23901 flags.isNonSync = 0; 23902 } 23903 } else if (safariWebkitVersion) { 23904 if (maxPtsDelta - minPtsDelta < maxDtsDelta - minDtsDelta && averageSampleDuration / maxDts
23904Delta < 0.025 && outputSamples[0].cts === 0) { 23905 logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration."); 23906 let dts = firstDTS; 23907 for (let i3 = 0, len = outputSamples.length; i3 < len; i3++) { 23908 const nextDts = dts + outputSamples[i3].duration; 23909 const pts = dts + outputSamples[i3].cts; 23910 if (i3 < len - 1) { 23911 const nextPts = nextDts + outputSamples[i3 + 1].cts; 23912 outputSamples[i3].duration = nextPts - pts; 23913 } else { 23914 outputSamples[i3].duration = i3 ? outputSamples[i3 - 1].duration : averageSampleDuration; 23915 } 23916 outputSamples[i3].cts = 0; 23917 dts = nextDts; 23918 } 23919 } 23920 } 23921 } 23922 mp4SampleDuration = stretchedLastFrame || !mp4SampleDuration ? averageSampleDuration : mp4SampleDuration; 23923 this.nextAvcDts = nextAvcDts = lastDTS + mp4SampleDuration; 23924 this.videoSampleDuration = mp4SampleDuration; 23925 this.isVideoContiguous = true; 23926 const moof = MP4.moof(track.sequenceNumber++, firstDTS, _extends2({}, track, { 23927 samples: outputSamples 23928 })); 23929 const type = "video"; 23930 const data = { 23931 data1: moof, 23932 data2: mdat, 23933 startPTS: minPTS / timeScale, 23934 endPTS: (maxPTS + mp4SampleDuration) / timeScale, 23935 startDTS: firstDTS / timeScale, 23936 endDTS: nextAvcDts / timeScale, 23937 type, 23938 hasAudio: false, 23939 hasVideo: true, 23940 nb: outputSamples.length, 23941 dropped: track.dropped 23942 }; 23943 track.samples = []; 23944 track.dropped = 0; 23945 return data; 23946 } 23947 getSamplesPerFrame(track) { 23948 switch (track.segmentCodec) { 23949 case "mp3": 23950 return MPEG_AUDIO_SAMPLE_PER_FRAME; 23951 case "ac3": 23952 return AC3_SAMPLES_PER_FRAME; 23953 default: 23954 return AAC_SAMPLES_PER_FRAME; 23955 } 23956 } 23957 remuxAudio(track, timeOffset, contiguous, accurateTimeOffset, videoTimeOffset) { 23958 const inputTimeScale = track.inputTimeScale; 23959 const mp4timeScale = track.samplerate ? track.samplerate : inputTimeScale; 23960 const scaleFactor = inputTimeScale / mp4timeScale; 23961 const mp4SampleDuration = this.getSamplesPerFrame(track); 23962 const inputSampleDuration = mp4SampleDuration * scaleFactor; 23963 const initPTS = this._initPTS; 23964 const rawMPEG = track.segmentCodec === "mp3" && this.typeSupported.mpeg; 23965 const outputSamples = []; 23966 const alignedWithVideo = videoTimeOffset !== void 0; 23967 let inputSamples = track.samples; 23968 let offset = rawMPEG ? 0 : 8; 23969 let nextAudioPts = this.nextAudioPts || -1; 23970 const timeOffsetMpegTS = timeOffset * inputTimeScale; 23971 const initTime = initPTS.baseTime * inputTimeScale / initPTS.timescale; 23972 this.isAudioContiguous = contiguous = contiguous || inputSamples.length && nextAudioPts > 0 && (accurateTimeOffset && Math.abs(timeOffsetMpegTS - nextAudioPts) < 9e3 || Math.abs(normalizePts(inputSamples[0].pts - initTime, timeOffsetMpegTS) - nextAudioPts) < 20 * inputSampleDuration); 23973 inputSamples.forEach(function(sample) { 23974 sample.pts = normalizePts(sample.pts - initTime, timeOffsetMpegTS); 23975 }); 23976 if (!contiguous || nextAudioPts < 0) { 23977 inputSamples = inputSamples.filter((sample) => sample.pts >= 0); 23978 if (!inputSamples.length) { 23979 return; 23980 } 23981 if (videoTimeOffset === 0) { 23982 nextAudioPts = 0; 23983 } else if (accurateTimeOffset && !alignedWithVideo) { 23984 nextAudioPts = Math.max(0, timeOffsetMpegTS); 23985 } else { 23986 nextAudioPts = inputSamples[0].pts; 23987 } 23988 } 23989 if (track.segmentCodec === "aac") { 23990 const maxAudioFramesDrift = this.config.maxAudioFramesDrift; 23991 for (let i3 = 0, nextPts = nextAudioPts; i3 < inputSamples.length; i3++) { 23992 const sample = inputSamples[i3]; 23993 const pts = sample.pts; 23994 const delta = pts - nextPts; 23995 const duration = Math.abs(1e3 * delta / inputTimeScale); 23996 if (delta <= -maxAudioFramesDrift * inputSampleDuration && alignedWithVideo) { 23997 if (i3 === 0) { 23998 logger.warn(`Audio frame @ ${(pts / inputTimeScale).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3 * delta / inputTimeScale)}
23998 ms.`); 23999 this.nextAudioPts = nextAudioPts = nextPts = pts; 24000 } 24001 } else if (delta >= maxAudioFramesDrift * inputSampleDuration && duration < MAX_SILENT_FRAME_DURATION && alignedWithVideo) { 24002 let missing = Math.round(delta / inputSampleDuration); 24003 nextPts = pts - missing * inputSampleDuration; 24004 if (nextPts < 0) { 24005 missing--; 24006 nextPts += inputSampleDuration; 24007 } 24008 if (i3 === 0) { 24009 this.nextAudioPts = nextAudioPts = nextPts; 24010 } 24011 logger.warn(`[mp4-remuxer]: Injecting ${missing} audio frame @ ${(nextPts / inputTimeScale).toFixed(3)}s due to ${Math.round(1e3 * delta / inputTimeScale)} ms gap.`); 24012 for (let j3 = 0; j3 < missing; j3++) { 24013 const newStamp = Math.max(nextPts, 0); 24014 let fillFrame = AAC.getSilentFrame(track.manifestCodec || track.codec, track.channelCount); 24015 if (!fillFrame) { 24016 logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."); 24017 fillFrame = sample.unit.subarray(); 24018 } 24019 inputSamples.splice(i3, 0, { 24020 unit: fillFrame, 24021 pts: newStamp 24022 }); 24023 nextPts += inputSampleDuration; 24024 i3++; 24025 } 24026 } 24027 sample.pts = nextPts; 24028 nextPts += inputSampleDuration; 24029 } 24030 } 24031 let firstPTS = null; 24032 let lastPTS = null; 24033 let mdat; 24034 let mdatSize = 0; 24035 let sampleLength = inputSamples.length; 24036 while (sampleLength--) { 24037 mdatSize += inputSamples[sampleLength].unit.byteLength; 24038 } 24039 for (let j3 = 0, _nbSamples = inputSamples.length; j3 < _nbSamples; j3++) { 24040 const audioSample = inputSamples[j3]; 24041 const unit = audioSample.unit; 24042 let pts = audioSample.pts; 24043 if (lastPTS !== null) { 24044 const prevSample = outputSamples[j3 - 1]; 24045 prevSample.duration = Math.round((pts - lastPTS) / scaleFactor); 24046 } else { 24047 if (contiguous && track.segmentCodec === "aac") { 24048 pts = nextAudioPts; 24049 } 24050 firstPTS = pts; 24051 if (mdatSize > 0) { 24052 mdatSize += offset; 24053 try { 24054 mdat = new Uint8Array(mdatSize); 24055 } catch (err) { 24056 this.observer.emit(Events.ERROR, Events.ERROR, { 24057 type: ErrorTypes.MUX_ERROR, 24058 details: ErrorDetails.REMUX_ALLOC_ERROR, 24059 fatal: false, 24060 error: err, 24061 bytes: mdatSize, 24062 reason: `fail allocating audio mdat ${mdatSize}` 24063 }); 24064 return; 24065 } 24066 if (!rawMPEG) { 24067 const view = new DataView(mdat.buffer); 24068 view.setUint32(0, mdatSize); 24069 mdat.set(MP4.types.mdat, 4); 24070 } 24071 } else { 24072 return; 24073 } 24074 } 24075 mdat.set(unit, offset); 24076 const unitLen = unit.byteLength; 24077 offset += unitLen; 24078 outputSamples.push(new Mp4Sample(true, mp4SampleDuration, unitLen, 0)); 24079 lastPTS = pts; 24080 } 24081 const nbSamples = outputSamples.length; 24082 if (!nbSamples) { 24083 return; 24084 } 24085 const lastSample = outputSamples[outputSamples.length - 1]; 24086 this.nextAudioPts = nextAudioPts = lastPTS + scaleFactor * lastSample.duration; 24087 const moof = rawMPEG ? new Uint8Array(0) : MP4.moof(track.sequenceNumber++, firstPTS / scaleFactor, _extends2({}, track, { 24088 samples: outputSamples 24089 })); 24090 track.samples = []; 24091 const start = firstPTS / inputTimeScale; 24092 const end = nextAudioPts / inputTimeScale; 24093 const type = "audio"; 24094 const audioData = { 24095 data1: moof, 24096 data2: mdat, 24097 startPTS: start, 24098 endPTS: end, 24099 startDTS: start, 24100 endDTS: end, 24101 type, 24102 hasAudio: true, 24103 hasVideo: false, 24104 nb: nbSamples 24105 }; 24106 this.isAudioContiguous = true; 24107 return audioData; 24108 } 24109 remuxEmptyAudio(track, timeOffset, contiguous, videoData) { 24110 const inputTimeScale = track.inputTimeScale; 24111 const mp4timeScale = track.samplerate ? track.samplerate : inputTimeScale; 24112 const scaleFactor = inputTimeScale / mp4timeScale; 24113 const nextAudioPts = this.nextAudioPts; 24114 const initDTS = this._initDTS; 24115 const init90kHz = initDTS.baseTime * 9e4 / initDTS.timescale; 24116 const startDTS = (nextAudioPts !== null ? nextAudioPts : videoData.startDTS * inputTimeScale) + init90kHz; 24117 const endDTS = videoData.endDTS * inputTimeScale + init90kHz; 24118 const frameDuration = scaleFactor * AAC_SAMPLES_PER_FRAME;
24119 const nbSamples = Math.ceil((endDTS - startDTS) / frameDuration); 24120 const silentFrame = AAC.getSilentFrame(track.manifestCodec || track.codec, track.channelCount); 24121 logger.warn("[mp4-remuxer]: remux empty Audio"); 24122 if (!silentFrame) { 24123 logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec"); 24124 return; 24125 } 24126 const samples = []; 24127 for (let i3 = 0; i3 < nbSamples; i3++) { 24128 const stamp = startDTS + i3 * frameDuration; 24129 samples.push({ 24130 unit: silentFrame, 24131 pts: stamp, 24132 dts: stamp 24133 }); 24134 } 24135 track.samples = samples; 24136 return this.remuxAudio(track, timeOffset, contiguous, false); 24137 } 24138}; 24139function normalizePts(value, reference) { 24140 let offset; 24141 if (reference === null) { 24142 return value; 24143 } 24144 if (reference < value) { 24145 offset = -8589934592; 24146 } else { 24147 offset = 8589934592; 24148 } 24149 while (Math.abs(value - reference) > 4294967296) { 24150 value += offset; 24151 } 24152 return value; 24153} 24154function findKeyframeIndex(samples) { 24155 for (let i3 = 0; i3 < samples.length; i3++) { 24156 if (samples[i3].key) { 24157 return i3; 24158 } 24159 } 24160 return -1; 24161} 24162function flushTextTrackMetadataCueSamples(track, timeOffset, initPTS, initDTS) { 24163 const length2 = track.samples.length; 24164 if (!length2) { 24165 return; 24166 } 24167 const inputTimeScale = track.inputTimeScale; 24168 for (let index2 = 0; index2 < length2; index2++) { 24169 const sample = track.samples[index2]; 24170 sample.pts = normalizePts(sample.pts - initPTS.baseTime * inputTimeScale / initPTS.timescale, timeOffset * inputTimeScale) / inputTimeScale; 24171 sample.dts = normalizePts(sample.dts - initDTS.baseTime * inputTimeScale / initDTS.timescale, timeOffset * inputTimeScale) / inputTimeScale; 24172 } 24173 const samples = track.samples; 24174 track.samples = []; 24175 return { 24176 samples 24177 }; 24178} 24179function flushTextTrackUserdataCueSamples(track, timeOffset, initPTS) { 24180 const length2 = track.samples.length; 24181 if (!length2) { 24182 return; 24183 } 24184 const inputTimeScale = track.inputTimeScale; 24185 for (let index2 = 0; index2 < length2; index2++) { 24186 const sample = track.samples[index2]; 24187 sample.pts = normalizePts(sample.pts - initPTS.baseTime * inputTimeScale / initPTS.timescale, timeOffset * inputTimeScale) / inputTimeScale; 24188 } 24189 track.samples.sort((a2, b3) => a2.pts - b3.pts); 24190 const samples = track.samples; 24191 track.samples = []; 24192 return { 24193 samples 24194 }; 24195} 24196var Mp4Sample = class { 24197 constructor(isKeyframe, duration, size, cts) { 24198 this.size = void 0; 24199 this.duration = void 0; 24200 this.cts = void 0; 24201 this.flags = void 0; 24202 this.duration = duration; 24203 this.size = size; 24204 this.cts = cts; 24205 this.flags = { 24206 isLeading: 0, 24207 isDependedOn: 0, 24208 hasRedundancy: 0, 24209 degradPrio: 0, 24210 dependsOn: isKeyframe ? 2 : 1, 24211 isNonSync: isKeyframe ? 0 : 1 24212 }; 24213 } 24214}; 24215var PassThroughRemuxer = class { 24216 constructor() { 24217 this.emitInitSegment = false; 24218 this.audioCodec = void 0; 24219 this.videoCodec = void 0; 24220 this.initData = void 0; 24221 this.initPTS = null; 24222 this.initTracks = void 0; 24223 this.lastEndTime = null; 24224 } 24225 destroy() { 24226 } 24227 resetTimeStamp(defaultInitPTS) { 24228 this.initPTS = defaultInitPTS; 24229 this.lastEndTime = null; 24230 } 24231 resetNextTimestamp() { 24232 this.lastEndTime = null; 24233 } 24234 resetInitSegment(initSegment, audioCodec, videoCodec, decryptdata) { 24235 this.audioCodec = audioCodec; 24236 this.videoCodec = videoCodec; 24237 this.generateInitSegment(patchEncyptionData(initSegment, decryptdata)); 24238 this.emitInitSegment = true; 24239 } 24240 generateInitSegment(initSegment) { 24241 let { 24242 audioCodec, 24243 videoCodec 24244 } = this; 24245 if (!(initSegment != null && initSegment.byteLength)) { 24246 this.initTracks = void 0; 24247 this.initData = void 0; 24248 return; 24249 } 24250 const initData = this.initData = parseInitSegment(initSegment); 24251 if (initData.audio) { 24252 audioCodec = getParsedTrackCodec(initData.audio, ElementaryStreamTypes.AUDIO); 24253 } 24254 if (initData.video) { 24255 videoCodec = getParsedTrackCodec(initData.video, ElementaryStreamTypes.VIDEO); 24256 } 24257 const tracks = {}; 24258 if (initData.audio && initData.video) { 24259 tracks.audiovideo = { 24260 container: "video/mp4", 24261 codec: audioCodec + "," + videoCodec, 24262 initSegment, 24263 id: "main" 24264 }; 24265 } else if (initData.audio) { 24266 tracks.audio = { 24267 container: "audio/mp4", 24268 codec: audioCodec, 24269 initSegment, 24270 id: "audio" 24271 }; 24272 } else if (initData.video) { 24273 tracks.video = { 24274 container: "video/mp4", 24275 codec: videoCodec, 24276 initSegment, 24277 id: "main" 24278 }; 24279 } else { 24280 logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."); 24281 } 24282 this.initTracks = tracks; 24283 } 24284 remux(audioTrack, videoTrack, id3Track, textTrack, timeOffset, accurateTimeOff
24284set) { 24285 var _initData, _initData2; 24286 let { 24287 initPTS, 24288 lastEndTime 24289 } = this; 24290 const result = { 24291 audio: void 0, 24292 video: void 0, 24293 text: textTrack, 24294 id3: id3Track, 24295 initSegment: void 0 24296 }; 24297 if (!isFiniteNumber(lastEndTime)) { 24298 lastEndTime = this.lastEndTime = timeOffset || 0; 24299 } 24300 const data = videoTrack.samples; 24301 if (!(data != null && data.length)) { 24302 return result; 24303 } 24304 const initSegment = { 24305 initPTS: void 0, 24306 timescale: 1 24307 }; 24308 let initData = this.initData; 24309 if (!((_initData = initData) != null && _initData.length)) { 24310 this.generateInitSegment(data); 24311 initData = this.initData; 24312 } 24313 if (!((_initData2 = initData) != null && _initData2.length)) { 24314 logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."); 24315 return result; 24316 } 24317 if (this.emitInitSegment) { 24318 initSegment.tracks = this.initTracks; 24319 this.emitInitSegment = false; 24320 } 24321 const duration = getDuration(data, initData); 24322 const startDTS = getStartDTS(initData, data); 24323 const decodeTime = startDTS === null ? timeOffset : startDTS; 24324 if (isInvalidInitPts(initPTS, decodeTime, timeOffset, duration) || initSegment.timescale !== initPTS.timescale && accurateTimeOffset) { 24325 initSegment.initPTS = decodeTime - timeOffset; 24326 if (initPTS && initPTS.timescale === 1) { 24327 logger.warn(`Adjusting initPTS by ${initSegment.initPTS - initPTS.baseTime}`); 24328 } 24329 this.initPTS = initPTS = { 24330 baseTime: initSegment.initPTS, 24331 timescale: 1 24332 }; 24333 } 24334 const startTime = audioTrack ? decodeTime - initPTS.baseTime / initPTS.timescale : lastEndTime; 24335 const endTime = startTime + duration; 24336 offsetStartDTS(initData, data, initPTS.baseTime / initPTS.timescale); 24337 if (duration > 0) { 24338 this.lastEndTime = endTime; 24339 } else { 24340 logger.warn("Duration parsed from mp4 should be greater than zero"); 24341 this.resetNextTimestamp(); 24342 } 24343 const hasAudio = !!initData.audio; 24344 const hasVideo = !!initData.video; 24345 let type = ""; 24346 if (hasAudio) { 24347 type += "audio"; 24348 } 24349 if (hasVideo) { 24350 type += "video"; 24351 } 24352 const track = { 24353 data1: data, 24354 startPTS: startTime, 24355 startDTS: startTime, 24356 endPTS: endTime, 24357 endDTS: endTime, 24358 type, 24359 hasAudio, 24360 hasVideo, 24361 nb: 1, 24362 dropped: 0 24363 }; 24364 result.audio = track.type === "audio" ? track : void 0; 24365 result.video = track.type !== "audio" ? track : void 0; 24366 result.initSegment = initSegment; 24367 result.id3 = flushTextTrackMetadataCueSamples(id3Track, timeOffset, initPTS, initPTS); 24368 if (textTrack.samples.length) { 24369 result.text = flushTextTrackUserdataCueSamples(textTrack, timeOffset, initPTS); 24370 } 24371 return result; 24372 } 24373}; 24374function isInvalidInitPts(initPTS, startDTS, timeOffset, duration) { 24375 if (initPTS === null) { 24376 return true; 24377 } 24378 const minDuration = Math.max(duration, 1); 24379 const startTime = startDTS - initPTS.baseTime / initPTS.timescale; 24380 return Math.abs(startTime - timeOffset) > minDuration; 24381} 24382function getParsedTrackCodec(track, type) { 24383 const parsedCodec = track == null ? void 0 : track.codec; 24384 if (parsedCodec && parsedCodec.length > 4) { 24385 return parsedCodec; 24386 } 24387 if (type === ElementaryStreamTypes.AUDIO) { 24388 if (parsedCodec === "ec-3" || parsedCodec === "ac-3" || parsedCodec === "alac") { 24389 return parsedCodec; 24390 } 24391 if (parsedCodec === "fLaC" || parsedCodec === "Opus") { 24392 const preferManagedMediaSource = false;
24393 return getCodecCompatibleName(parsedCodec, preferManagedMediaSource); 24394 } 24395 const result = "mp4a.40.5"; 24396 logger.info(`Parsed audio codec "${parsedCodec}" or audio object type not handled. Using "${result}"`); 24397 return result; 24398 } 24399 logger.warn(`Unhandled video codec "${parsedCodec}"`); 24400 if (parsedCodec === "hvc1" || parsedCodec === "hev1") { 24401 return "hvc1.1.6.L120.90"; 24402 } 24403 if (parsedCodec === "av01") { 24404 return "av01.0.04M.08"; 24405 } 24406 return "avc1.42e01e"; 24407} 24408var now; 24409try { 24410 now = self.performance.now.bind(self.performance); 24411} catch (err) { 24412 logger.debug("Unable to use Performance API on this environment"); 24413 now = optionalSelf == null ? void 0 : optionalSelf.Date.now; 24414} 24415var muxConfig = [{ 24416 demux: MP4Demuxer, 24417 remux: PassThroughRemuxer 24418}, { 24419 demux: TSDemuxer, 24420 remux: MP4Remuxer 24421}, { 24422 demux: AACDemuxer, 24423 remux: MP4Remuxer 24424}, { 24425 demux: MP3Demuxer, 24426 remux: MP4Remuxer 24427}]; 24428{ 24429 muxConfig.splice(2, 0, { 24430 demux: AC3Demuxer, 24431 remux: MP4Remuxer 24432 }); 24433} 24434var Transmuxer = class { 24435 constructor(observer2, typeSupported, config, vendor, id) { 24436 this.async = false; 24437 this.observer = void 0; 24438 this.typeSupported = void 0; 24439 this.config = void 0; 24440 this.vendor = void 0; 24441 this.id = void 0; 24442 this.demuxer = void 0; 24443 this.remuxer = void 0; 24444 this.decrypter = void 0; 24445 this.probe = void 0; 24446 this.decryptionPromise = null; 24447 this.transmuxConfig = void 0; 24448 this.currentTransmuxState = void 0; 24449 this.observer = observer2; 24450 this.typeSupported = typeSupported; 24451 this.config = config; 24452 this.vendor = vendor; 24453 this.id = id; 24454 } 24455 configure(transmuxConfig) { 24456 this.transmuxConfig = transmuxConfig; 24457 if (this.decrypter) { 24458 this.decrypter.reset(); 24459 } 24460 } 24461 push(data, decryptdata, chunkMeta, state) { 24462 const stats = chunkMeta.transmuxing; 24463 stats.executeStart = now(); 24464 let uintData = new Uint8Array(data); 24465 const { 24466 currentTransmuxState, 24467 transmuxConfig 24468 } = this; 24469 if (state) { 24470 this.currentTransmuxState = state; 24471 } 24472 const { 24473 contiguous, 24474 discontinuity, 24475 trackSwitch, 24476 accurateTimeOffset, 24477 timeOffset, 24478 initSegmentChange 24479 } = state || currentTransmuxState; 24480 const { 24481 audioCodec, 24482 videoCodec, 24483 defaultInitPts, 24484 duration, 24485 initSegmentData 24486 } = transmuxConfig; 24487 const keyData = getEncryptionType(uintData, decryptdata); 24488 if (keyData && keyData.method === "AES-128") { 24489 const decrypter = this.getDecrypter(); 24490 if (decrypter.isSync()) { 24491 let decryptedData = decrypter.softwareDecrypt(uintData, keyData.key.buffer, keyData.iv.buffer); 24492 const loadingParts = chunkMeta.part > -1; 24493 if (loadingParts) { 24494 decryptedData = decrypter.flush(); 24495 } 24496 if (!decryptedData) { 24497 stats.executeEnd = now(); 24498 return emptyResult(chunkMeta); 24499 } 24500 uintData = new Uint8Array(decryptedData); 24501 } else { 24502 this.decryptionPromise = decrypter.webCryptoDecrypt(uintData, keyData.key.buffer, keyData.iv.buffer).then((decryptedData) => { 24503 const result2 = this.push(decryptedData, null, chunkMeta); 24504 this.decryptionPromise = null; 24505 return result2; 24506 }); 24507 return this.decryptionPromise; 24508 } 24509 } 24510 const resetMuxers = this.needsProbing(discontinuity, trackSwitch); 24511 if (resetMuxers) { 24512 const error = this.configureTransmuxer(uintData); 24513 if (error) { 24514 logger.warn(`[transmuxer] ${error.message}`); 24515 this.observer.emit(Events.ERROR, Events.ERROR, { 24516 type: ErrorTypes.MEDIA_ERROR, 24517 details: ErrorDetails.FRAG_PARSING_ERROR, 24518 fatal: false, 24519 error, 24520 reason: error.message 24521 }); 24522 stats.executeEnd = now(); 24523 return emptyResult(chunkMeta); 24524 } 24525 } 24526 if (discontinuity || trackSwitch || initSegmentChange || resetMuxers) { 24527 this.resetInitSegment(initSegmentData, audioCodec, videoCodec, duration, decryptdata); 24528 } 24529 if (discontinuity || initSegmentChange || resetMuxers) { 24530 this.resetInitialTimestamp(defaultInitPts); 24531 } 24532 if (!contiguous) { 24533 this.resetContiguity(); 24534 } 24535 const result = this.transmux(uintData, keyData, timeOffset, accurateTimeOff
24535set, chunkMeta); 24536 const currentState = this.currentTransmuxState; 24537 currentState.contiguous = true; 24538 currentState.discontinuity = false; 24539 currentState.trackSwitch = false; 24540 stats.executeEnd = now(); 24541 return result; 24542 } 24543 // Due to data caching, flush calls can produce more than one TransmuxerResult (hence the Array type) 24544 flush(chunkMeta) { 24545 const stats = chunkMeta.transmuxing; 24546 stats.executeStart = now(); 24547 const { 24548 decrypter, 24549 currentTransmuxState, 24550 decryptionPromise 24551 } = this; 24552 if (decryptionPromise) { 24553 return decryptionPromise.then(() => { 24554 return this.flush(chunkMeta); 24555 }); 24556 } 24557 const transmuxResults = []; 24558 const { 24559 timeOffset 24560 } = currentTransmuxState; 24561 if (decrypter) { 24562 const decryptedData = decrypter.flush(); 24563 if (decryptedData) { 24564 transmuxResults.push(this.push(decryptedData, null, chunkMeta)); 24565 } 24566 } 24567 const { 24568 demuxer, 24569 remuxer 24570 } = this; 24571 if (!demuxer || !remuxer) { 24572 stats.executeEnd = now(); 24573 return [emptyResult(chunkMeta)]; 24574 } 24575 const demuxResultOrPromise = demuxer.flush(timeOffset); 24576 if (isPromise(demuxResultOrPromise)) { 24577 return demuxResultOrPromise.then((demuxResult) => { 24578 this.flushRemux(transmuxResults, demuxResult, chunkMeta); 24579 return transmuxResults; 24580 }); 24581 } 24582 this.flushRemux(transmuxResults, demuxResultOrPromise, chunkMeta); 24583 return transmuxResults; 24584 } 24585 flushRemux(transmuxResults, demuxResult, chunkMeta) { 24586 const { 24587 audioTrack, 24588 videoTrack, 24589 id3Track, 24590 textTrack 24591 } = demuxResult; 24592 const { 24593 accurateTimeOffset, 24594 timeOffset 24595 } = this.currentTransmuxState; 24596 logger.log(`[transmuxer.ts]: Flushed fragment ${chunkMeta.sn}${chunkMeta.part > -1 ? " p: " + chunkMeta.part : ""} of level ${chunkMeta.level}`); 24597 const remuxResult = this.remuxer.remux(audioTrack, videoTrack, id3Track, textTrack, timeOffset, accurateTimeOffset, true, this.id); 24598 transmuxResults.push({ 24599 remuxResult, 24600 chunkMeta 24601 }); 24602 chunkMeta.transmuxing.executeEnd = now(); 24603 } 24604 resetInitialTimestamp(defaultInitPts) { 24605 const { 24606 demuxer, 24607 remuxer 24608 } = this; 24609 if (!demuxer || !remuxer) { 24610 return; 24611 } 24612 demuxer.resetTimeStamp(defaultInitPts); 24613 remuxer.resetTimeStamp(defaultInitPts); 24614 } 24615 resetContiguity() { 24616 const { 24617 demuxer, 24618 remuxer 24619 } = this; 24620 if (!demuxer || !remuxer) { 24621 return; 24622 } 24623 demuxer.resetContiguity(); 24624 remuxer.resetNextTimestamp(); 24625 } 24626 resetInitSegment(initSegmentData, audioCodec, videoCodec, trackDuration, decryptdata) { 24627 const { 24628 demuxer, 24629 remuxer 24630 } = this; 24631 if (!demuxer || !remuxer) { 24632 return; 24633 } 24634 demuxer.resetInitSegment(initSegmentData, audioCodec, videoCodec, trackDuration); 24635 remuxer.resetInitSegment(initSegmentData, audioCodec, videoCodec, decryptdata); 24636 } 24637 destroy() { 24638 if (this.demuxer) { 24639 this.demuxer.destroy(); 24640 this.demuxer = void 0; 24641 } 24642 if (this.remuxer) { 24643 this.remuxer.destroy(); 24644 this.remuxer = void 0; 24645 } 24646 } 24647 transmux(data, keyData, timeOffset, accurateTimeOffset, chunkMeta) { 24648 let result; 24649 if (keyData && keyData.method === "SAMPLE-AES") { 24650 result = this.transmuxSampleAes(data, keyData, timeOffset, accurateTimeOffset, chunkMeta); 24651 } else { 24652 result = this.transmuxUnencrypted(data, timeOffset, accurateTimeOffset, chunkMeta); 24653 } 24654 return result; 24655 } 24656 transmuxUnencrypted(data, timeOffset, accurateTimeOffset, chunkMeta) { 24657 const { 24658 audioTrack, 24659 videoTrack, 24660 id3Track, 24661 textTrack 24662 } = this.demuxer.demux(data, timeOffset, false, !this.config.progressive); 24663 const remuxResult = this.remuxer.remux(audioTrack, videoTrack, id3Track, textTrack, timeOffset, accurateTimeOffset, false, this.id); 24664 return { 24665 remuxResult, 24666 chunkMeta 24667 }; 24668 } 24669 transmuxSampleAes(data, decryptData, timeOffset, accurateTimeOffset, chunkMeta) { 24670 return this.demuxer.demuxSampleAes(data, decryptData, timeOffset).then((demuxResult) => { 24671 const remuxResult = this.remuxer.remux(demuxResult.audioTrack, demuxResult.videoTrack, demuxResult.id3Track, demuxResult.textTrack, timeOffset, accurateTimeOff
vendor: 9,871 bytes, lines 24671-24954
24671set, false, this.id); 24672 return { 24673 remuxResult, 24674 chunkMeta 24675 }; 24676 }); 24677 } 24678 configureTransmuxer(data) { 24679 const { 24680 config, 24681 observer: observer2, 24682 typeSupported, 24683 vendor 24684 } = this; 24685 let mux; 24686 for (let i3 = 0, len = muxConfig.length; i3 < len; i3++) { 24687 var _muxConfig$i$demux; 24688 if ((_muxConfig$i$demux = muxConfig[i3].demux) != null && _muxConfig$i$demux.probe(data)) { 24689 mux = muxConfig[i3]; 24690 break; 24691 } 24692 } 24693 if (!mux) { 24694 return new Error("Failed to find demuxer by probing fragment data"); 24695 } 24696 const demuxer = this.demuxer; 24697 const remuxer = this.remuxer; 24698 const Remuxer = mux.remux; 24699 const Demuxer = mux.demux; 24700 if (!remuxer || !(remuxer instanceof Remuxer)) { 24701 this.remuxer = new Remuxer(observer2, config, typeSupported, vendor); 24702 } 24703 if (!demuxer || !(demuxer instanceof Demuxer)) { 24704 this.demuxer = new Demuxer(observer2, config, typeSupported); 24705 this.probe = Demuxer.probe; 24706 } 24707 } 24708 needsProbing(discontinuity, trackSwitch) { 24709 return !this.demuxer || !this.remuxer || discontinuity || trackSwitch; 24710 } 24711 getDecrypter() { 24712 let decrypter = this.decrypter; 24713 if (!decrypter) { 24714 decrypter = this.decrypter = new Decrypter(this.config); 24715 } 24716 return decrypter; 24717 } 24718}; 24719function getEncryptionType(data, decryptData) { 24720 let encryptionType = null; 24721 if (data.byteLength > 0 && (decryptData == null ? void 0 : decryptData.key) != null && decryptData.iv !== null && decryptData.method != null) { 24722 encryptionType = decryptData; 24723 } 24724 return encryptionType; 24725} 24726var emptyResult = (chunkMeta) => ({ 24727 remuxResult: {}, 24728 chunkMeta 24729}); 24730function isPromise(p3) { 24731 return "then" in p3 && p3.then instanceof Function; 24732} 24733var TransmuxConfig = class { 24734 constructor(audioCodec, videoCodec, initSegmentData, duration, defaultInitPts) { 24735 this.audioCodec = void 0; 24736 this.videoCodec = void 0; 24737 this.initSegmentData = void 0; 24738 this.duration = void 0; 24739 this.defaultInitPts = void 0; 24740 this.audioCodec = audioCodec; 24741 this.videoCodec = videoCodec; 24742 this.initSegmentData = initSegmentData; 24743 this.duration = duration; 24744 this.defaultInitPts = defaultInitPts || null; 24745 } 24746}; 24747var TransmuxState = class { 24748 constructor(discontinuity, contiguous, accurateTimeOffset, trackSwitch, timeOffset, initSegmentChange) { 24749 this.discontinuity = void 0; 24750 this.contiguous = void 0; 24751 this.accurateTimeOffset = void 0; 24752 this.trackSwitch = void 0; 24753 this.timeOffset = void 0; 24754 this.initSegmentChange = void 0; 24755 this.discontinuity = discontinuity; 24756 this.contiguous = contiguous; 24757 this.accurateTimeOffset = accurateTimeOffset; 24758 this.trackSwitch = trackSwitch; 24759 this.timeOffset = timeOffset; 24760 this.initSegmentChange = initSegmentChange; 24761 } 24762}; 24763var eventemitter3 = { exports: {} }; 24764(function(module) { 24765 var has = Object.prototype.hasOwnProperty, prefix3 = "~"; 24766 function Events2() { 24767 } 24768 if (Object.create) { 24769 Events2.prototype = /* @__PURE__ */ Object.create(null); 24770 if (!new Events2().__proto__) prefix3 = false; 24771 } 24772 function EE(fn, context, once) { 24773 this.fn = fn; 24774 this.context = context; 24775 this.once = once || false; 24776 } 24777 function addListener2(emitter, event, fn, context, once) { 24778 if (typeof fn !== "function") { 24779 throw new TypeError("The listener must be a function"); 24780 } 24781 var listener = new EE(fn, context || emitter, once), evt = prefix3 ? prefix3 + event : event; 24782 if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++; 24783 else if (!emitter._events[evt].fn) emitter._events[evt].push(listener); 24784 else emitter._events[evt] = [emitter._events[evt], listener]; 24785 return emitter; 24786 } 24787 function clearEvent(emitter, evt) { 24788 if (--emitter._eventsCount === 0) emitter._events = new Events2(); 24789 else delete emitter._events[evt]; 24790 } 24791 function EventEmitter2() { 24792 this._events = new Events2(); 24793 this._eventsCount = 0; 24794 } 24795 EventEmitter2.prototype.eventNames = function eventNames() { 24796 var names = [], events2, name; 24797 if (this._eventsCount === 0) return names; 24798 for (name in events2 = this._events) { 24799 if (has.call(events2, name)) names.push(prefix3 ? name.slice(1) : name); 24800 } 24801 if (Object.getOwnPropertySymbols) { 24802 return names.concat(Object.getOwnPropertySymbols(events2)); 24803 } 24804 return names; 24805 }; 24806 EventEmitter2.prototype.listeners = function listeners(event) { 24807 var evt = prefix3 ? prefix3 + event : event, handlers2 = this._events[evt]; 24808 if (!handlers2) return []; 24809 if (handlers2.fn) return [handlers2.fn]; 24810 for (var i3 = 0, l2 = handlers2.length, ee6 = new Array(l2); i3 < l2; i3++) { 24811 ee6[i3] = handlers2[i3].fn; 24812 } 24813 return ee6; 24814 }; 24815 EventEmitter2.prototype.listenerCount = function listenerCount(event) { 24816 var evt = prefix3 ? prefix3 + event : event, listeners = this._events[evt]; 24817 if (!listeners) return 0; 24818 if (listeners.fn) return 1; 24819 return listeners.length; 24820 }; 24821 EventEmitter2.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { 24822 var evt = prefix3 ? prefix3 + event : event; 24823 if (!this._events[evt]) return false; 24824 var listeners = this._events[evt], len = arguments.length, args, i3; 24825 if (listeners.fn) { 24826 if (listeners.once) this.removeListener(event, listeners.fn, void 0, true); 24827 switch (len) { 24828 case 1: 24829 return listeners.fn.call(listeners.context), true; 24830 case 2: 24831 return listeners.fn.call(listeners.context, a1), true; 24832 case 3: 24833 return listeners.fn.call(listeners.context, a1, a2), true; 24834 case 4: 24835 return listeners.fn.call(listeners.context, a1, a2, a3), true; 24836 case 5: 24837 return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; 24838 case 6: 24839 return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; 24840 } 24841 for (i3 = 1, args = new Array(len - 1); i3 < len; i3++) { 24842 args[i3 - 1] = arguments[i3]; 24843 } 24844 listeners.fn.apply(listeners.context, args); 24845 } else { 24846 var length2 = listeners.length, j3; 24847 for (i3 = 0; i3 < length2; i3++) { 24848 if (listeners[i3].once) this.removeListener(event, listeners[i3].fn, void 0, true); 24849 switch (len) { 24850 case 1: 24851 listeners[i3].fn.call(listeners[i3].context); 24852 break; 24853 case 2: 24854 listeners[i3].fn.call(listeners[i3].context, a1); 24855 break; 24856 case 3: 24857 listeners[i3].fn.call(listeners[i3].context, a1, a2); 24858 break; 24859 case 4: 24860 listeners[i3].fn.call(listeners[i3].context, a1, a2, a3); 24861 break; 24862 default: 24863 if (!args) for (j3 = 1, args = new Array(len - 1); j3 < len; j3++) { 24864 args[j3 - 1] = arguments[j3]; 24865 } 24866 listeners[i3].fn.apply(listeners[i3].context, args); 24867 } 24868 } 24869 } 24870 return true; 24871 }; 24872 EventEmitter2.prototype.on = function on(event, fn, context) { 24873 return addListener2(this, event, fn, context, false); 24874 }; 24875 EventEmitter2.prototype.once = function once(event, fn, context) { 24876 return addListener2(this, event, fn, context, true); 24877 }; 24878 EventEmitter2.prototype.removeListener = function removeListener2(event, fn, context, once) { 24879 var evt = prefix3 ? prefix3 + event : event; 24880 if (!this._events[evt]) return this; 24881 if (!fn) { 24882 clearEvent(this, evt); 24883 return this; 24884 } 24885 var listeners = this._events[evt]; 24886 if (listeners.fn) { 24887 if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) { 24888 clearEvent(this, evt); 24889 } 24890 } else { 24891 for (var i3 = 0, events2 = [], length2 = listeners.length; i3 < length2; i3++) { 24892 if (listeners[i3].fn !== fn || once && !listeners[i3].once || context && listeners[i3].context !== context) { 24893 events2.push(listeners[i3]); 24894 } 24895 } 24896 if (events2.length) this._events[evt] = events2.length === 1 ? events2[0] : events2; 24897 else clearEvent(this, evt); 24898 } 24899 return this; 24900 }; 24901 EventEmitter2.prototype.removeAllListeners = function removeAllListeners(event) { 24902 var evt; 24903 if (event) { 24904 evt = prefix3 ? prefix3 + event : event; 24905 if (this._events[evt]) clearEvent(this, evt); 24906 } else { 24907 this._events = new Events2(); 24908 this._eventsCount = 0; 24909 } 24910 return this; 24911 }; 24912 EventEmitter2.prototype.off = EventEmitter2.prototype.removeListener; 24913 EventEmitter2.prototype.addListener = EventEmitter2.prototype.on; 24914 EventEmitter2.prefixed = prefix3; 24915 EventEmitter2.EventEmitter = EventEmitter2; 24916 { 24917 module.exports = EventEmitter2; 24918 } 24919})(eventemitter3); 24920var eventemitter3Exports = eventemitter3.exports; 24921var EventEmitter = getDefaultExportFromCjs(eventemitter3Exports); 24922var TransmuxerInterface = class { 24923 constructor(hls, id, onTransmuxComplete, onFlush) { 24924 this.error = null; 24925 this.hls = void 0; 24926 this.id = void 0; 24927 this.observer = void 0; 24928 this.frag = null; 24929 this.part = null; 24930 this.useWorker = void 0; 24931 this.workerContext = null; 24932 this.onwmsg = void 0; 24933 this.transmuxer = null; 24934 this.onTransmuxComplete = void 0; 24935 this.onFlush = void 0; 24936 const config = hls.config; 24937 this.hls = hls; 24938 this.id = id; 24939 this.useWorker = !!config.enableWorker; 24940 this.onTransmuxComplete = onTransmuxComplete; 24941 this.onFlush = onFlush; 24942 const forwardMessage = (ev, data) => { 24943 data = data || {}; 24944 data.frag = this.frag; 24945 data.id = this.id; 24946 if (ev === Events.ERROR) { 24947 this.error = data.error; 24948 } 24949 this.hls.trigger(ev, data); 24950 }; 24951 this.observer = new EventEmitter(); 24952 this.observer.on(Events.FRAG_DECRYPTED, forwardMessage); 24953 this.observer.on(Events.ERROR, forwardMessage); 24954 const MediaSource = getMediaSource(config.preferManagedMediaSource) || {
24955 isTypeSupported: () => false 24956 }; 24957 const m2tsTypeSupported = { 24958 mpeg: MediaSource.isTypeSupported("audio/mpeg"), 24959 mp3: MediaSource.isTypeSupported('audio/mp4; codecs="mp3"'), 24960 ac3: MediaSource.isTypeSupported('audio/mp4; codecs="ac-3"') 24961 }; 24962 if (this.useWorker && typeof Worker !== "undefined") { 24963 const canCreateWorker = config.workerPath || hasUMDWorker(); 24964 if (canCreateWorker) { 24965 try { 24966 if (config.workerPath) { 24967 logger.log(`loading Web Worker ${config.workerPath} for "${id}"`); 24968 this.workerContext = loadWorker(config.workerPath); 24969 } else { 24970 logger.log(`injecting Web Worker for "${id}"`); 24971 this.workerContext = injectWorker(); 24972 } 24973 this.onwmsg = (event) => this.onWorkerMessage(event); 24974 const { 24975 worker 24976 } = this.workerContext; 24977 worker.addEventListener("message", this.onwmsg); 24978 worker.onerror = (event) => { 24979 const error = new Error(`${event.message} (${event.filename}:${event.lineno})`); 24980 config.enableWorker = false;
24981 logger.warn(`Error in "${id}" Web Worker, fallback to inline`); 24982 this.hls.trigger(Events.ERROR, { 24983 type: ErrorTypes.OTHER_ERROR, 24984 details: ErrorDetails.INTERNAL_EXCEPTION, 24985 fatal: false, 24986 event: "demuxerWorker", 24987 error 24988 }); 24989 }; 24990 worker.postMessage({ 24991 cmd: "init", 24992 typeSupported: m2tsTypeSupported, 24993 vendor: "", 24994 id, 24995 config: JSON.stringify(config) 24996 }); 24997 } catch (err) { 24998 logger.warn(`Error setting up "${id}" Web Worker, fallback to inline`, err); 24999 this.resetWorker(); 25000 this.error = null; 25001 this.transmuxer = new Transmuxer(this.observer, m2tsTypeSupported, config, "", id); 25002 } 25003 return; 25004 } 25005 } 25006 this.transmuxer = new Transmuxer(this.observer, m2tsTypeSupported, config, "", id); 25007 } 25008 resetWorker() { 25009 if (this.workerContext) { 25010 const { 25011 worker, 25012 objectURL 25013 } = this.workerContext; 25014 if (objectURL) { 25015 self.URL.revokeObjectURL(objectURL); 25016 } 25017 worker.removeEventListener("message", this.onwmsg); 25018 worker.onerror = null; 25019 worker.terminate(); 25020 this.workerContext = null; 25021 } 25022 } 25023 destroy() { 25024 if (this.workerContext) { 25025 this.resetWorker(); 25026 this.onwmsg = void 0; 25027 } else { 25028 const transmuxer = this.transmuxer; 25029 if (transmuxer) { 25030 transmuxer.destroy(); 25031 this.transmuxer = null; 25032 } 25033 } 25034 const observer2 = this.observer; 25035 if (observer2) { 25036 observer2.removeAllListeners(); 25037 } 25038 this.frag = null; 25039 this.observer = null; 25040 this.hls = null; 25041 } 25042 push(data, initSegmentData, audioCodec, videoCodec, frag, part, duration, accurateTimeOffset, chunkMeta, defaultInitPTS) { 25043 var _frag$initSegment, _lastFrag$initSegment; 25044 chunkMeta.transmuxing.start = self.performance.now(); 25045 const { 25046 transmuxer 25047 } = this; 25048 const timeOffset = part ? part.start : frag.start; 25049 const decryptdata = frag.decryptdata; 25050 const lastFrag = this.frag; 25051 const discontinuity = !(lastFrag && frag.cc === lastFrag.cc); 25052 const trackSwitch = !(lastFrag && chunkMeta.level === lastFrag.level); 25053 const snDiff = lastFrag ? chunkMeta.sn - lastFrag.sn : -1; 25054 const partDiff = this.part ? chunkMeta.part - this.part.index : -1; 25055 const progressive = snDiff === 0 && chunkMeta.id > 1 && chunkMeta.id === (lastFrag == null ? void 0 : lastFrag.stats.chunkCount); 25056 const contiguous = !trackSwitch && (snDiff === 1 || snDiff === 0 && (partDiff === 1 || progressive && partDiff <= 0)); 25057 const now2 = self.performance.now(); 25058 if (trackSwitch || snDiff || frag.stats.parsing.start === 0) { 25059 frag.stats.parsing.start = now2; 25060 } 25061 if (part && (partDiff || !contiguous)) { 25062 part.stats.parsing.start = now2; 25063 } 25064 const initSegmentChange = !(lastFrag && ((_frag$initSegment = frag.initSegment) == null ? void 0 : _frag$initSegment.url) === ((_lastFrag$initSegment = lastFrag.initSegment) == null ? void 0 : _lastFrag$initSegment.url)); 25065 const state = new TransmuxState(discontinuity, contiguous, accurateTimeOffset, trackSwitch, timeOffset, initSegmentChange); 25066 if (!contiguous || discontinuity || initSegmentChange) { 25067 logger.log(`[transmuxer-interface, ${frag.type}]: Starting new transmux session for sn: ${chunkMeta.sn} p: ${chunkMeta.part} level: ${chunkMeta.level} id: ${chunkMeta.id} 25068 discontinuity: ${discontinuity} 25069 trackSwitch: ${trackSwitch} 25070 contiguous: ${contiguous} 25071 accurateTimeOffset: ${accurateTimeOffset} 25072 timeOffset: ${timeOffset} 25073 initSegmentChange: ${initSegmentChange}`); 25074 const config = new TransmuxConfig(audioCodec, videoCodec, initSegmentData, duration, defaultInitPTS); 25075 this.configureTransmuxer(config); 25076 } 25077 this.frag = frag; 25078 this.part = part; 25079 if (this.workerContext) { 25080 this.workerContext.worker.postMessage({ 25081 cmd: "demux", 25082 data, 25083 decryptdata, 25084 chunkMeta, 25085 state 25086 }, data instanceof ArrayBuffer ? [data] : []); 25087 } else if (transmuxer) { 25088 const transmuxResult = transmuxer.push(data, decryptdata, chunkMeta, state);
25089 if (isPromise(transmuxResult)) { 25090 transmuxer.async = true; 25091 transmuxResult.then((data2) => { 25092 this.handleTransmuxComplete(data2); 25093 }).catch((error) => { 25094 this.transmuxerError(error, chunkMeta, "transmuxer-interface push error"); 25095 }); 25096 } else { 25097 transmuxer.async = false; 25098 this.handleTransmuxComplete(transmuxResult); 25099 } 25100 } 25101 } 25102 flush(chunkMeta) { 25103 chunkMeta.transmuxing.start = self.performance.now(); 25104 const { 25105 transmuxer 25106 } = this; 25107 if (this.workerContext) { 25108 this.workerContext.worker.postMessage({ 25109 cmd: "flush", 25110 chunkMeta 25111 }); 25112 } else if (transmuxer) { 25113 let transmuxResult = transmuxer.flush(chunkMeta); 25114 const asyncFlush = isPromise(transmuxResult); 25115 if (asyncFlush || transmuxer.async) { 25116 if (!isPromise(transmuxResult)) { 25117 transmuxResult = Promise.resolve(transmuxResult); 25118 } 25119 transmuxResult.then((data) => { 25120 this.handleFlushResult(data, chunkMeta); 25121 }).catch((error) => { 25122 this.transmuxerError(error, chunkMeta, "transmuxer-interface flush error"); 25123 }); 25124 } else { 25125 this.handleFlushResult(transmuxResult, chunkMeta); 25126 } 25127 } 25128 } 25129 transmuxerError(error, chunkMeta, reason) { 25130 if (!this.hls) { 25131 return; 25132 } 25133 this.error = error; 25134 this.hls.trigger(Events.ERROR, { 25135 type: ErrorTypes.MEDIA_ERROR, 25136 details: ErrorDetails.FRAG_PARSING_ERROR, 25137 chunkMeta, 25138 frag: this.frag || void 0, 25139 fatal: false, 25140 error, 25141 err: error, 25142 reason 25143 }); 25144 } 25145 handleFlushResult(results, chunkMeta) { 25146 results.forEach((result) => { 25147 this.handleTransmuxComplete(result); 25148 }); 25149 this.onFlush(chunkMeta); 25150 } 25151 onWorkerMessage(event) { 25152 const data = event.data; 25153 if (!(data != null && data.event)) { 25154 logger.warn(`worker message received with no ${data ? "event name" : "data"}`); 25155 return; 25156 } 25157 const hls = this.hls; 25158 if (!this.hls) { 25159 return; 25160 } 25161 switch (data.event) { 25162 case "init": { 25163 var _this$workerContext; 25164 const objectURL = (_this$workerContext = this.workerContext) == null ? void 0 : _this$workerContext.objectURL; 25165 if (objectURL) { 25166 self.URL.revokeObjectURL(objectURL); 25167 } 25168 break; 25169 } 25170 case "transmuxComplete": { 25171 this.handleTransmuxComplete(data.data); 25172 break; 25173 } 25174 case "flush": { 25175 this.onFlush(data.data); 25176 break; 25177 } 25178 case "workerLog": 25179 if (logger[data.data.logType]) { 25180 logger[data.data.logType](data.data.message); 25181 } 25182 break; 25183 default: { 25184 data.data = data.data || {}; 25185 data.data.frag = this.frag; 25186 data.data.id = this.id; 25187 hls.trigger(data.event, data.data); 25188 break; 25189 } 25190 } 25191 } 25192 configureTransmuxer(config) { 25193 const { 25194 transmuxer 25195 } = this; 25196 if (this.workerContext) { 25197 this.workerContext.worker.postMessage({ 25198 cmd: "configure", 25199 config 25200 }); 25201 } else if (transmuxer) { 25202 transmuxer.configure(config); 25203 } 25204 } 25205 handleTransmuxComplete(result) { 25206 result.chunkMeta.transmuxing.end = self.performance.now(); 25207 this.onTransmuxComplete(result); 25208 } 25209}; 25210var TICK_INTERVAL$2 = 100; 25211var AudioStreamController = class extends BaseStreamController { 25212 constructor(hls, fragmentTracker, keyLoader) { 25213 super(hls, fragmentTracker, keyLoader, "[audio-stream-controller]", PlaylistLevelType.AUDIO); 25214 this.videoBuffer = null; 25215 this.videoTrackCC = -1; 25216 this.waitingVideoCC = -1; 25217 this.bufferedTrack = null; 25218 this.switchingTrack = null; 25219 this.trackId = -1; 25220 this.waitingData = null; 25221 this.mainDetails = null; 25222 this.flushing = false; 25223 this.bufferFlushed = false; 25224 this.cachedTrackLoadedData = null; 25225 this._registerListeners(); 25226 } 25227 onHandlerDestroying() { 25228 this._unregisterListeners(); 25229 super.onHandlerDestroying(); 25230 this.mainDetails = null; 25231 this.bufferedTrack = null; 25232 this.switchingTrack = null; 25233 } 25234 _registerListeners() { 25235 const { 25236 hls 25237 } = this;
25238 hls.on(Events.MEDIA_ATTACHED, this.onMediaAttached, this); 25239 hls.on(Events.MEDIA_DETACHING, this.onMediaDetaching, this); 25240 hls.on(Events.MANIFEST_LOADING, this.onManifestLoading, this); 25241 hls.on(Events.LEVEL_LOADED, this.onLevelLoaded, this); 25242 hls.on(Events.AUDIO_TRACKS_UPDATED, this.onAudioTracksUpdated, this); 25243 hls.on(Events.AUDIO_TRACK_SWITCHING, this.onAudioTrackSwitching, this); 25244 hls.on(Events.AUDIO_TRACK_LOADED, this.onAudioTrackLoaded, this); 25245 hls.on(Events.ERROR, this.onError, this); 25246 hls.on(Events.BUFFER_RESET, this.onBufferReset, this); 25247 hls.on(Events.BUFFER_CREATED, this.onBufferCreated, this); 25248 hls.on(Events.BUFFER_FLUSHING, this.onBufferFlushing, this); 25249 hls.on(Events.BUFFER_FLUSHED, this.onBufferFlushed, this); 25250 hls.on(Events.INIT_PTS_FOUND, this.onInitPtsFound, this); 25251 hls.on(Events.FRAG_BUFFERED, this.onFragBuffered, this); 25252 } 25253 _unregisterListeners() { 25254 const { 25255 hls 25256 } = this; 25257 hls.off(Events.MEDIA_ATTACHED, this.onMediaAttached, this); 25258 hls.off(Events.MEDIA_DETACHING, this.onMediaDetaching, this); 25259 hls.off(Events.MANIFEST_LOADING, this.onManifestLoading, this); 25260 hls.off(Events.LEVEL_LOADED, this.onLevelLoaded, this); 25261 hls.off(Events.AUDIO_TRACKS_UPDATED, this.onAudioTracksUpdated, this); 25262 hls.off(Events.AUDIO_TRACK_SWITCHING, this.onAudioTrackSwitching, this); 25263 hls.off(Events.AUDIO_TRACK_LOADED, this.onAudioTrackLoaded, this); 25264 hls.off(Events.ERROR, this.onError, this); 25265 hls.off(Events.BUFFER_RESET, this.onBufferReset, this); 25266 hls.off(Events.BUFFER_CREATED, this.onBufferCreated, this); 25267 hls.off(Events.BUFFER_FLUSHING, this.onBufferFlushing, this); 25268 hls.off(Events.BUFFER_FLUSHED, this.onBufferFlushed, this); 25269 hls.off(Events.INIT_PTS_FOUND, this.onInitPtsFound, this); 25270 hls.off(Events.FRAG_BUFFERED, this.onFragBuffered, this); 25271 } 25272 // INIT_PTS_FOUND is triggered when the video track parsed in the stream-controller has a new PTS value 25273 onInitPtsFound(event, { 25274 frag, 25275 id, 25276 initPTS, 25277 timescale 25278 }) { 25279 if (id === "main") { 25280 const cc = frag.cc; 25281 this.initPTS[frag.cc] = { 25282 baseTime: initPTS, 25283 timescale 25284 }; 25285 this.log(`InitPTS for cc: ${cc} found from main: ${initPTS}`); 25286 this.videoTrackCC = cc; 25287 if (this.state === State.WAITING_INIT_PTS) { 25288 this.tick(); 25289 } 25290 } 25291 } 25292 startLoad(startPosition) { 25293 if (!this.levels) { 25294 this.startPosition = startPosition; 25295 this.state = State.STOPPED; 25296 return; 25297 } 25298 const lastCurrentTime = this.lastCurrentTime; 25299 this.stopLoad(); 25300 this.setInterval(TICK_INTERVAL$2); 25301 if (lastCurrentTime > 0 && startPosition === -1) { 25302 this.log(`Override startPosition with lastCurrentTime @${lastCurrentTime.toFixed(3)}`); 25303 startPosition = lastCurrentTime; 25304 this.state = State.IDLE; 25305 } else { 25306 this.loadedmetadata = false; 25307 this.state = State.WAITING_TRACK; 25308 } 25309 this.nextLoadPosition = this.startPosition = this.lastCurrentTime = startPosition; 25310 this.tick(); 25311 } 25312 doTick() { 25313 switch (this.state) { 25314 case State.IDLE: 25315 this.doTickIdle(); 25316 break; 25317 case State.WAITING_TRACK: { 25318 var _levels$trackId; 25319 const { 25320 levels, 25321 trackId 25322 } = this; 25323 const details = levels == null ? void 0 : (_levels$trackId = levels[trackId]) == null ? void 0 : _levels$trackId.details; 25324 if (details) { 25325 if (this.waitForCdnTuneIn(details)) { 25326 break; 25327 } 25328 this.state = State.WAITING_INIT_PTS; 25329 } 25330 break; 25331 } 25332 case State.FRAG_LOADING_WAITING_RETRY: { 25333 var _this$media; 25334 const now2 = performance.now(); 25335 const retryDate = this.retryDate; 25336 if (!retryDate || now2 >= retryDate || (_this$media = this.media) != null && _this$media.seeking) { 25337 const { 25338 levels, 25339 trackId 25340 } = this; 25341 this.log("RetryDate reached, switch back to IDLE state"); 25342 this.resetStartWhenNotLoaded((levels == null ? void 0 : levels[trackId]) || null); 25343 this.state = State.IDLE; 25344 } 25345 break; 25346 } 25347 case State.WAITING_INIT_PTS: { 25348 const waitingData = this.waitingData; 25349 if (waitingData) { 25350 const { 25351 frag, 25352 part, 25353 cache, 25354 complete 25355 } = waitingData; 25356 if (this.initPTS[frag.cc] !== void 0) { 25357 this.waitingData = null; 25358 this.waitingVideoCC = -1; 25359 this.state = State.FRAG_LOADING; 25360 const payload = cache.flush(); 25361 const data = { 25362 frag, 25363 part, 25364 payload, 25365 networkDetails: null 25366 }; 25367 this._handleFragmentLoadProgress(data); 25368 if (complete) { 25369 super._handleFragmentLoadComplete(data); 25370 } 25371 } else if (this.videoTrackCC !== this.waitingVideoCC) { 25372 this.log(`Waiting fragment cc (${frag.cc}) cancelled because video is at cc ${this.videoTrackCC}`); 25373 this.clearWaitingFragment(); 25374 } else { 25375 const pos = this.getLoadPosition(); 25376 const bufferInfo = BufferHelper.bufferInfo(this.mediaBuffer, pos, this.config.maxBufferHole); 25377 const waitingFragmentAtPosition = fragmentWithinToleranceTest(bufferInfo.end, this.config.maxFragLookUpTolerance, frag); 25378 if (waitingFragmentAtPosition < 0) { 25379 this.log(`Waiting fragment cc (${frag.cc}) @ ${frag.start} cancelled because another fragment at ${bufferInfo.end} is needed`); 25380 this.clearWaitingFragment(); 25381 } 25382 } 25383 } else { 25384 this.state = State.IDLE; 25385 } 25386 } 25387 } 25388 this.onTickEnd(); 25389 } 25390 clearWaitingFragment() { 25391 const waitingData = this.waitingData; 25392 if (waitingData) { 25393 this.fragmentTracker.removeFragment(waitingData.frag); 25394 this.waitingData = null; 25395 this.waitingVideoCC = -1; 25396 this.state = State.IDLE; 25397 } 25398 } 25399 resetLoadingState() { 25400 this.clearWaitingFragment(); 25401 super.resetLoadingState(); 25402 } 25403 onTickEnd() { 25404 const { 25405 media 25406 } = this; 25407 if (!(media != null && media.readyState)) { 25408 return; 25409 } 25410 this.lastCurrentTime = media.currentTime; 25411 } 25412 doTickIdle() { 25413 const { 25414 hls, 25415 levels, 25416 media, 25417 trackId 25418 } = this; 25419 const config = hls.config; 25420 if (!this.buffering || !media && (this.startFragRequested || !config.startFragPrefetch) || !(levels != null && levels[trackId])) { 25421 return; 25422 } 25423 const levelInfo = levels[trackId];
25424 const trackDetails = levelInfo.details; 25425 if (!trackDetails || trackDetails.live && this.levelLastLoaded !== levelInfo || this.waitForCdnTuneIn(trackDetails)) { 25426 this.state = State.WAITING_TRACK; 25427 return; 25428 } 25429 const bufferable = this.mediaBuffer ? this.mediaBuffer : this.media; 25430 if (this.bufferFlushed && bufferable) { 25431 this.bufferFlushed = false; 25432 this.afterBufferFlushed(bufferable, ElementaryStreamTypes.AUDIO, PlaylistLevelType.AUDIO); 25433 } 25434 const bufferInfo = this.getFwdBufferInfo(bufferable, PlaylistLevelType.AUDIO); 25435 if (bufferInfo === null) { 25436 return; 25437 } 25438 if (!this.switchingTrack && this._streamEnded(bufferInfo, trackDetails)) { 25439 hls.trigger(Events.BUFFER_EOS, { 25440 type: "audio" 25441 }); 25442 this.state = State.ENDED; 25443 return; 25444 } 25445 const mainBufferInfo = this.getFwdBufferInfo(this.videoBuffer ? this.videoBuffer : this.media, PlaylistLevelType.MAIN); 25446 const bufferLen = bufferInfo.len; 25447 const maxBufLen = this.getMaxBufferLength(mainBufferInfo == null ? void 0 : mainBufferInfo.len); 25448 const fragments = trackDetails.fragments; 25449 const start = fragments[0].start; 25450 const loadPosition = this.getLoadPosition(); 25451 const targetBufferTime = this.flushing ? loadPosition : bufferInfo.end; 25452 if (this.switchingTrack && media) { 25453 const pos = loadPosition; 25454 if (trackDetails.PTSKnown && pos < start) { 25455 if (bufferInfo.end > start || bufferInfo.nextStart) { 25456 this.log("Alt audio track ahead of main track, seek to start of alt audio track"); 25457 media.currentTime = start + 0.05; 25458 } 25459 } 25460 } 25461 if (bufferLen >= maxBufLen && !this.switchingTrack && targetBufferTime < fragments[fragments.length - 1].start) { 25462 return; 25463 } 25464 let frag = this.getNextFragment(targetBufferTime, trackDetails); 25465 let atGap = false; 25466 if (frag && this.isLoopLoading(frag, targetBufferTime)) { 25467 atGap = !!frag.gap; 25468 frag = this.getNextFragmentLoopLoading(frag, trackDetails, bufferInfo, PlaylistLevelType.MAIN, maxBufLen); 25469 } 25470 if (!frag) { 25471 this.bufferFlushed = true; 25472 return; 25473 } 25474 const atBufferSyncLimit = mainBufferInfo && frag.start > mainBufferInfo.end + trackDetails.targetduration; 25475 if (atBufferSyncLimit || // Or wait for main buffer after buffing some audio 25476 !(mainBufferInfo != null && mainBufferInfo.len) && bufferInfo.len) { 25477 const mainFrag = this.getAppendedFrag(frag.start, PlaylistLevelType.MAIN); 25478 if (mainFrag === null) { 25479 return; 25480 } 25481 atGap || (atGap = !!mainFrag.gap || !!atBufferSyncLimit && mainBufferInfo.len === 0); 25482 if (atBufferSyncLimit && !atGap || atGap && bufferInfo.nextStart && bufferInfo.nextStart < mainFrag.end) { 25483 return; 25484 } 25485 } 25486 this.loadFragment(frag, levelInfo, targetBufferTime); 25487 } 25488 getMaxBufferLength(mainBufferLength) { 25489 const maxConfigBuffer = super.getMaxBufferLength(); 25490 if (!mainBufferLength) { 25491 return maxConfigBuffer; 25492 } 25493 return Math.min(Math.max(maxConfigBuffer, mainBufferLength), this.config.maxMaxBufferLength); 25494 } 25495 onMediaDetaching() { 25496 this.videoBuffer = null; 25497 this.bufferFlushed = this.flushing = false; 25498 super.onMediaDetaching(); 25499 } 25500 onAudioTracksUpdated(event, { 25501 audioTracks 25502 }) { 25503 this.resetTransmuxer(); 25504 this.levels = audioTracks.map((mediaPlaylist) => new Level(mediaPlaylist)); 25505 } 25506 onAudioTrackSwitching(event, data) { 25507 const altAudio = !!data.url; 25508 this.trackId = data.id; 25509 const { 25510 fragCurrent 25511 } = this; 25512 if (fragCurrent) { 25513 fragCurrent.abortRequests(); 25514 this.removeUnbufferedFrags(fragCurrent.start); 25515 } 25516 this.resetLoadingState(); 25517 if (!altAudio) { 25518 this.resetTransmuxer(); 25519 } else { 25520 this.setInterval(TICK_INTERVAL$2); 25521 } 25522 if (altAudio) { 25523 this.switchingTrack = data; 25524 this.state = State.IDLE; 25525 this.flushAudioIfNeeded(data); 25526 } else { 25527 this.switchingTrack = null; 25528 this.bufferedTrack = data; 25529 this.state = State.STOPPED; 25530 } 25531 this.tick(); 25532 } 25533 onManifestLoading() { 25534 this.fragmentTracker.removeAllFragments(); 25535 this.startPosition = this.lastCurrentTime = 0; 25536 this.bufferFlushed = this.flushing = false;
vendor: 4,623 bytes, lines 25537-25656
25537 this.levels = this.mainDetails = this.waitingData = this.bufferedTrack = this.cachedTrackLoadedData = this.switchingTrack = null; 25538 this.startFragRequested = false; 25539 this.trackId = this.videoTrackCC = this.waitingVideoCC = -1; 25540 } 25541 onLevelLoaded(event, data) { 25542 this.mainDetails = data.details; 25543 if (this.cachedTrackLoadedData !== null) { 25544 this.hls.trigger(Events.AUDIO_TRACK_LOADED, this.cachedTrackLoadedData); 25545 this.cachedTrackLoadedData = null; 25546 } 25547 } 25548 onAudioTrackLoaded(event, data) { 25549 var _track$details; 25550 if (this.mainDetails == null) { 25551 this.cachedTrackLoadedData = data; 25552 return; 25553 } 25554 const { 25555 levels 25556 } = this; 25557 const { 25558 details: newDetails, 25559 id: trackId 25560 } = data; 25561 if (!levels) { 25562 this.warn(`Audio tracks were reset while loading level ${trackId}`); 25563 return; 25564 } 25565 this.log(`Audio track ${trackId} loaded [${newDetails.startSN},${newDetails.endSN}]${newDetails.lastPartSn ? `[part-${newDetails.lastPartSn}-${newDetails.lastPartIndex}]` : ""},duration:${newDetails.totalduration}`); 25566 const track = levels[trackId]; 25567 let sliding = 0; 25568 if (newDetails.live || (_track$details = track.details) != null && _track$details.live) { 25569 this.checkLiveUpdate(newDetails); 25570 const mainDetails = this.mainDetails; 25571 if (newDetails.deltaUpdateFailed || !mainDetails) { 25572 return; 25573 } 25574 if (!track.details && newDetails.hasProgramDateTime && mainDetails.hasProgramDateTime) { 25575 alignMediaPlaylistByPDT(newDetails, mainDetails); 25576 sliding = newDetails.fragments[0].start; 25577 } else { 25578 var _this$levelLastLoaded; 25579 sliding = this.alignPlaylists(newDetails, track.details, (_this$levelLastLoaded = this.levelLastLoaded) == null ? void 0 : _this$levelLastLoaded.details); 25580 } 25581 } 25582 track.details = newDetails; 25583 this.levelLastLoaded = track; 25584 if (!this.startFragRequested && (this.mainDetails || !newDetails.live)) { 25585 this.setStartPosition(this.mainDetails || newDetails, sliding); 25586 } 25587 if (this.state === State.WAITING_TRACK && !this.waitForCdnTuneIn(newDetails)) { 25588 this.state = State.IDLE; 25589 } 25590 this.tick(); 25591 } 25592 _handleFragmentLoadProgress(data) { 25593 var _frag$initSegment; 25594 const { 25595 frag, 25596 part, 25597 payload 25598 } = data; 25599 const { 25600 config, 25601 trackId, 25602 levels 25603 } = this; 25604 if (!levels) { 25605 this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${frag.sn} of level ${frag.level} will not be buffered`); 25606 return; 25607 } 25608 const track = levels[trackId]; 25609 if (!track) { 25610 this.warn("Audio track is undefined on fragment load progress"); 25611 return; 25612 } 25613 const details = track.details; 25614 if (!details) { 25615 this.warn("Audio track details undefined on fragment load progress"); 25616 this.removeUnbufferedFrags(frag.start); 25617 return; 25618 } 25619 const audioCodec = config.defaultAudioCodec || track.audioCodec || "mp4a.40.2"; 25620 let transmuxer = this.transmuxer; 25621 if (!transmuxer) { 25622 transmuxer = this.transmuxer = new TransmuxerInterface(this.hls, PlaylistLevelType.AUDIO, this._handleTransmuxComplete.bind(this), this._handleTransmuxerFlush.bind(this)); 25623 } 25624 const initPTS = this.initPTS[frag.cc]; 25625 const initSegmentData = (_frag$initSegment = frag.initSegment) == null ? void 0 : _frag$initSegment.data; 25626 if (initPTS !== void 0) { 25627 const accurateTimeOffset = false; 25628 const partIndex = part ? part.index : -1; 25629 const partial = partIndex !== -1; 25630 const chunkMeta = new ChunkMetadata(frag.level, frag.sn, frag.stats.chunkCount, payload.byteLength, partIndex, partial); 25631 transmuxer.push(payload, initSegmentData, audioCodec, "", frag, part, details.totalduration, accurateTimeOffset, chunkMeta, initPTS); 25632 } else { 25633 this.log(`Unknown video PTS for cc ${frag.cc}, waiting for video PTS before demuxing audio frag ${frag.sn} of [${details.startSN} ,${details.endSN}],track ${trackId}`); 25634 const { 25635 cache 25636 } = this.waitingData = this.waitingData || { 25637 frag, 25638 part, 25639 cache: new ChunkCache(), 25640 complete: false 25641 }; 25642 cache.push(new Uint8Array(payload)); 25643 this.waitingVideoCC = this.videoTrackCC; 25644 this.state = State.WAITING_INIT_PTS; 25645 } 25646 } 25647 _handleFragmentLoadComplete(fragLoadedData) { 25648 if (this.waitingData) { 25649 this.waitingData.complete = true; 25650 return; 25651 } 25652 super._handleFragmentLoadComplete(fragLoadedData); 25653 } 25654 onBufferReset() { 25655 this.mediaBuffer = this.videoBuffer = null; 25656 this.loadedmetadata = false;
vendor: 8,539 bytes, lines 25657-25935
25657 } 25658 onBufferCreated(event, data) { 25659 const audioTrack = data.tracks.audio; 25660 if (audioTrack) { 25661 this.mediaBuffer = audioTrack.buffer || null; 25662 } 25663 if (data.tracks.video) { 25664 this.videoBuffer = data.tracks.video.buffer || null; 25665 } 25666 } 25667 onFragBuffered(event, data) { 25668 const { 25669 frag, 25670 part 25671 } = data; 25672 if (frag.type !== PlaylistLevelType.AUDIO) { 25673 if (!this.loadedmetadata && frag.type === PlaylistLevelType.MAIN) { 25674 const bufferable = this.videoBuffer || this.media; 25675 if (bufferable) { 25676 const bufferedTimeRanges = BufferHelper.getBuffered(bufferable); 25677 if (bufferedTimeRanges.length) { 25678 this.loadedmetadata = true; 25679 } 25680 } 25681 } 25682 return; 25683 } 25684 if (this.fragContextChanged(frag)) { 25685 this.warn(`Fragment ${frag.sn}${part ? " p: " + part.index : ""} of level ${frag.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack ? this.switchingTrack.name : "false"}`); 25686 return; 25687 } 25688 if (frag.sn !== "initSegment") { 25689 this.fragPrevious = frag; 25690 const track = this.switchingTrack; 25691 if (track) { 25692 this.bufferedTrack = track; 25693 this.switchingTrack = null; 25694 this.hls.trigger(Events.AUDIO_TRACK_SWITCHED, _objectSpread23({}, track)); 25695 } 25696 } 25697 this.fragBufferedComplete(frag, part); 25698 } 25699 onError(event, data) { 25700 var _data$context; 25701 if (data.fatal) { 25702 this.state = State.ERROR; 25703 return; 25704 } 25705 switch (data.details) { 25706 case ErrorDetails.FRAG_GAP: 25707 case ErrorDetails.FRAG_PARSING_ERROR: 25708 case ErrorDetails.FRAG_DECRYPT_ERROR: 25709 case ErrorDetails.FRAG_LOAD_ERROR: 25710 case ErrorDetails.FRAG_LOAD_TIMEOUT: 25711 case ErrorDetails.KEY_LOAD_ERROR: 25712 case ErrorDetails.KEY_LOAD_TIMEOUT: 25713 this.onFragmentOrKeyLoadError(PlaylistLevelType.AUDIO, data); 25714 break; 25715 case ErrorDetails.AUDIO_TRACK_LOAD_ERROR: 25716 case ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT: 25717 case ErrorDetails.LEVEL_PARSING_ERROR: 25718 if (!data.levelRetry && this.state === State.WAITING_TRACK && ((_data$context = data.context) == null ? void 0 : _data$context.type) === PlaylistContextType.AUDIO_TRACK) { 25719 this.state = State.IDLE; 25720 } 25721 break; 25722 case ErrorDetails.BUFFER_APPEND_ERROR: 25723 case ErrorDetails.BUFFER_FULL_ERROR: 25724 if (!data.parent || data.parent !== "audio") { 25725 return; 25726 } 25727 if (data.details === ErrorDetails.BUFFER_APPEND_ERROR) { 25728 this.resetLoadingState(); 25729 return; 25730 } 25731 if (this.reduceLengthAndFlushBuffer(data)) { 25732 this.bufferedTrack = null; 25733 super.flushMainBuffer(0, Number.POSITIVE_INFINITY, "audio"); 25734 } 25735 break; 25736 case ErrorDetails.INTERNAL_EXCEPTION: 25737 this.recoverWorkerError(data); 25738 break; 25739 } 25740 } 25741 onBufferFlushing(event, { 25742 type 25743 }) { 25744 if (type !== ElementaryStreamTypes.VIDEO) { 25745 this.flushing = true; 25746 } 25747 } 25748 onBufferFlushed(event, { 25749 type 25750 }) { 25751 if (type !== ElementaryStreamTypes.VIDEO) { 25752 this.flushing = false; 25753 this.bufferFlushed = true; 25754 if (this.state === State.ENDED) { 25755 this.state = State.IDLE; 25756 } 25757 const mediaBuffer = this.mediaBuffer || this.media; 25758 if (mediaBuffer) { 25759 this.afterBufferFlushed(mediaBuffer, type, PlaylistLevelType.AUDIO); 25760 this.tick(); 25761 } 25762 } 25763 } 25764 _handleTransmuxComplete(transmuxResult) { 25765 var _id3$samples; 25766 const id = "audio"; 25767 const { 25768 hls 25769 } = this; 25770 const { 25771 remuxResult, 25772 chunkMeta 25773 } = transmuxResult; 25774 const context = this.getCurrentContext(chunkMeta); 25775 if (!context) { 25776 this.resetWhenMissingContext(chunkMeta); 25777 return; 25778 } 25779 const { 25780 frag, 25781 part, 25782 level 25783 } = context; 25784 const { 25785 details 25786 } = level; 25787 const { 25788 audio, 25789 text, 25790 id3, 25791 initSegment 25792 } = remuxResult; 25793 if (this.fragContextChanged(frag) || !details) { 25794 this.fragmentTracker.removeFragment(frag); 25795 return; 25796 } 25797 this.state = State.PARSING; 25798 if (this.switchingTrack && audio) { 25799 this.completeAudioSwitch(this.switchingTrack); 25800 } 25801 if (initSegment != null && initSegment.tracks) { 25802 const mapFragment = frag.initSegment || frag; 25803 this._bufferInitSegment(level, initSegment.tracks, mapFragment, chunkMeta); 25804 hls.trigger(Events.FRAG_PARSING_INIT_SEGMENT, { 25805 frag: mapFragment, 25806 id, 25807 tracks: initSegment.tracks 25808 }); 25809 } 25810 if (audio) { 25811 const { 25812 startPTS, 25813 endPTS, 25814 startDTS, 25815 endDTS 25816 } = audio; 25817 if (part) { 25818 part.elementaryStreams[ElementaryStreamTypes.AUDIO] = { 25819 startPTS, 25820 endPTS, 25821 startDTS, 25822 endDTS 25823 }; 25824 } 25825 frag.setElementaryStreamInfo(ElementaryStreamTypes.AUDIO, startPTS, endPTS, startDTS, endDTS); 25826 this.bufferFragmentData(audio, frag, part, chunkMeta); 25827 } 25828 if (id3 != null && (_id3$samples = id3.samples) != null && _id3$samples.length) { 25829 const emittedID3 = _extends2({ 25830 id, 25831 frag, 25832 details 25833 }, id3); 25834 hls.trigger(Events.FRAG_PARSING_METADATA, emittedID3); 25835 } 25836 if (text) { 25837 const emittedText = _extends2({ 25838 id, 25839 frag, 25840 details 25841 }, text); 25842 hls.trigger(Events.FRAG_PARSING_USERDATA, emittedText); 25843 } 25844 } 25845 _bufferInitSegment(currentLevel, tracks, frag, chunkMeta) { 25846 if (this.state !== State.PARSING) { 25847 return; 25848 } 25849 if (tracks.video) { 25850 delete tracks.video; 25851 } 25852 const track = tracks.audio; 25853 if (!track) { 25854 return; 25855 } 25856 track.id = "audio"; 25857 const variantAudioCodecs = currentLevel.audioCodec; 25858 this.log(`Init audio buffer, container:${track.container}, codecs[level/parsed]=[${variantAudioCodecs}/${track.codec}]`); 25859 if (variantAudioCodecs && variantAudioCodecs.split(",").length === 1) { 25860 track.levelCodec = variantAudioCodecs; 25861 } 25862 this.hls.trigger(Events.BUFFER_CODECS, tracks); 25863 const initSegment = track.initSegment; 25864 if (initSegment != null && initSegment.byteLength) { 25865 const segment = { 25866 type: "audio", 25867 frag, 25868 part: null, 25869 chunkMeta, 25870 parent: frag.type, 25871 data: initSegment 25872 }; 25873 this.hls.trigger(Events.BUFFER_APPENDING, segment); 25874 } 25875 this.tickImmediate(); 25876 } 25877 loadFragment(frag, track, targetBufferTime) { 25878 const fragState = this.fragmentTracker.getState(frag); 25879 this.fragCurrent = frag; 25880 if (this.switchingTrack || fragState === FragmentState.NOT_LOADED || fragState === FragmentState.PARTIAL) { 25881 var _track$details2; 25882 if (frag.sn === "initSegment") { 25883 this._loadInitSegment(frag, track); 25884 } else if ((_track$details2 = track.details) != null && _track$details2.live && !this.initPTS[frag.cc]) { 25885 this.log(`Waiting for video PTS in continuity counter ${frag.cc} of live stream before loading audio fragment ${frag.sn} of level ${this.trackId}`); 25886 this.state = State.WAITING_INIT_PTS; 25887 const mainDetails = this.mainDetails; 25888 if (mainDetails && mainDetails.fragments[0].start !== track.details.fragments[0].start) { 25889 alignMediaPlaylistByPDT(track.details, mainDetails); 25890 } 25891 } else { 25892 this.startFragRequested = true; 25893 super.loadFragment(frag, track, targetBufferTime); 25894 } 25895 } else { 25896 this.clearTrackerIfNeeded(frag); 25897 } 25898 } 25899 flushAudioIfNeeded(switchingTrack) { 25900 if (this.media && this.bufferedTrack) { 25901 const { 25902 name, 25903 lang, 25904 assocLang, 25905 characteristics, 25906 audioCodec, 25907 channels 25908 } = this.bufferedTrack; 25909 if (!matchesOption({ 25910 name, 25911 lang, 25912 assocLang, 25913 characteristics, 25914 audioCodec, 25915 channels 25916 }, switchingTrack, audioMatchPredicate)) { 25917 this.log("Switching audio track : flushing all audio"); 25918 super.flushMainBuffer(0, Number.POSITIVE_INFINITY, "audio"); 25919 this.bufferedTrack = null; 25920 } 25921 } 25922 } 25923 completeAudioSwitch(switchingTrack) { 25924 const { 25925 hls 25926 } = this; 25927 this.flushAudioIfNeeded(switchingTrack); 25928 this.bufferedTrack = switchingTrack; 25929 this.switchingTrack = null; 25930 hls.trigger(Events.AUDIO_TRACK_SWITCHED, _objectSpread23({}, switchingTrack)); 25931 } 25932}; 25933function subtitleOptionsIdentical(trackList1, trackList2) { 25934 if (trackList1.length !== trackList2.length) { 25935 return false;
vendor: 4,341 bytes, lines 25936-26044
25936 } 25937 for (let i3 = 0; i3 < trackList1.length; i3++) { 25938 if (!mediaAttributesIdentical(trackList1[i3].attrs, trackList2[i3].attrs)) { 25939 return false; 25940 } 25941 } 25942 return true; 25943} 25944function mediaAttributesIdentical(attrs1, attrs2, customAttributes) { 25945 const stableRenditionId = attrs1["STABLE-RENDITION-ID"]; 25946 if (stableRenditionId && !customAttributes) { 25947 return stableRenditionId === attrs2["STABLE-RENDITION-ID"]; 25948 } 25949 return !(customAttributes || ["LANGUAGE", "NAME", "CHARACTERISTICS", "AUTOSELECT", "DEFAULT", "FORCED", "ASSOC-LANGUAGE"]).some((subtitleAttribute) => attrs1[subtitleAttribute] !== attrs2[subtitleAttribute]); 25950} 25951function subtitleTrackMatchesTextTrack(subtitleTrack, textTrack) { 25952 return textTrack.label.toLowerCase() === subtitleTrack.name.toLowerCase() && (!textTrack.language || textTrack.language.toLowerCase() === (subtitleTrack.lang || "").toLowerCase()); 25953} 25954var AudioTrackController = class extends BasePlaylistController { 25955 constructor(hls) { 25956 super(hls, "[audio-track-controller]"); 25957 this.tracks = []; 25958 this.groupIds = null; 25959 this.tracksInGroup = []; 25960 this.trackId = -1; 25961 this.currentTrack = null; 25962 this.selectDefaultTrack = true; 25963 this.registerListeners(); 25964 } 25965 registerListeners() { 25966 const { 25967 hls 25968 } = this; 25969 hls.on(Events.MANIFEST_LOADING, this.onManifestLoading, this); 25970 hls.on(Events.MANIFEST_PARSED, this.onManifestParsed, this); 25971 hls.on(Events.LEVEL_LOADING, this.onLevelLoading, this); 25972 hls.on(Events.LEVEL_SWITCHING, this.onLevelSwitching, this); 25973 hls.on(Events.AUDIO_TRACK_LOADED, this.onAudioTrackLoaded, this); 25974 hls.on(Events.ERROR, this.onError, this); 25975 } 25976 unregisterListeners() { 25977 const { 25978 hls 25979 } = this; 25980 hls.off(Events.MANIFEST_LOADING, this.onManifestLoading, this); 25981 hls.off(Events.MANIFEST_PARSED, this.onManifestParsed, this); 25982 hls.off(Events.LEVEL_LOADING, this.onLevelLoading, this); 25983 hls.off(Events.LEVEL_SWITCHING, this.onLevelSwitching, this); 25984 hls.off(Events.AUDIO_TRACK_LOADED, this.onAudioTrackLoaded, this); 25985 hls.off(Events.ERROR, this.onError, this); 25986 } 25987 destroy() { 25988 this.unregisterListeners(); 25989 this.tracks.length = 0; 25990 this.tracksInGroup.length = 0; 25991 this.currentTrack = null; 25992 super.destroy(); 25993 } 25994 onManifestLoading() { 25995 this.tracks = []; 25996 this.tracksInGroup = []; 25997 this.groupIds = null; 25998 this.currentTrack = null; 25999 this.trackId = -1; 26000 this.selectDefaultTrack = true; 26001 } 26002 onManifestParsed(event, data) { 26003 this.tracks = data.audioTracks || []; 26004 } 26005 onAudioTrackLoaded(event, data) { 26006 const { 26007 id, 26008 groupId, 26009 details 26010 } = data; 26011 const trackInActiveGroup = this.tracksInGroup[id]; 26012 if (!trackInActiveGroup || trackInActiveGroup.groupId !== groupId) { 26013 this.warn(`Audio track with id:${id} and group:${groupId} not found in active group ${trackInActiveGroup == null ? void 0 : trackInActiveGroup.groupId}`); 26014 return; 26015 } 26016 const curDetails = trackInActiveGroup.details; 26017 trackInActiveGroup.details = data.details; 26018 this.log(`Audio track ${id} "${trackInActiveGroup.name}" lang:${trackInActiveGroup.lang} group:${groupId} loaded [${details.startSN}-${details.endSN}]`); 26019 if (id === this.trackId) { 26020 this.playlistLoaded(id, data, curDetails); 26021 } 26022 } 26023 onLevelLoading(event, data) { 26024 this.switchLevel(data.level); 26025 } 26026 onLevelSwitching(event, data) { 26027 this.switchLevel(data.level); 26028 } 26029 switchLevel(levelIndex) { 26030 const levelInfo = this.hls.levels[levelIndex]; 26031 if (!levelInfo) { 26032 return; 26033 } 26034 const audioGroups = levelInfo.audioGroups || null; 26035 const currentGroups = this.groupIds; 26036 let currentTrack = this.currentTrack; 26037 if (!audioGroups || (currentGroups == null ? void 0 : currentGroups.length) !== (audioGroups == null ? void 0 : audioGroups.length) || audioGroups != null && audioGroups.some((groupId) => (currentGroups == null ? void 0 : currentGroups.indexOf(groupId)) === -1)) { 26038 this.groupIds = audioGroups; 26039 this.trackId = -1; 26040 this.currentTrack = null; 26041 const audioTracks = this.tracks.filter((track) => !audioGroups || audioGroups.indexOf(track.groupId) !== -1); 26042 if (audioTracks.length) { 26043 if (this.selectDefaultTrack && !audioTracks.some((track) => track.default)) { 26044 this.selectDefaultTrack = false;
vendor: 4,158 bytes, lines 26045-26156
26045 } 26046 audioTracks.forEach((track, i3) => { 26047 track.id = i3; 26048 }); 26049 } else if (!currentTrack && !this.tracksInGroup.length) { 26050 return; 26051 } 26052 this.tracksInGroup = audioTracks; 26053 const audioPreference = this.hls.config.audioPreference; 26054 if (!currentTrack && audioPreference) { 26055 const groupIndex = findMatchingOption(audioPreference, audioTracks, audioMatchPredicate); 26056 if (groupIndex > -1) { 26057 currentTrack = audioTracks[groupIndex]; 26058 } else { 26059 const allIndex = findMatchingOption(audioPreference, this.tracks); 26060 currentTrack = this.tracks[allIndex]; 26061 } 26062 } 26063 let trackId = this.findTrackId(currentTrack); 26064 if (trackId === -1 && currentTrack) { 26065 trackId = this.findTrackId(null); 26066 } 26067 const audioTracksUpdated = { 26068 audioTracks 26069 }; 26070 this.log(`Updating audio tracks, ${audioTracks.length} track(s) found in group(s): ${audioGroups == null ? void 0 : audioGroups.join(",")}`); 26071 this.hls.trigger(Events.AUDIO_TRACKS_UPDATED, audioTracksUpdated); 26072 const selectedTrackId = this.trackId; 26073 if (trackId !== -1 && selectedTrackId === -1) { 26074 this.setAudioTrack(trackId); 26075 } else if (audioTracks.length && selectedTrackId === -1) { 26076 var _this$groupIds; 26077 const error = new Error(`No audio track selected for current audio group-ID(s): ${(_this$groupIds = this.groupIds) == null ? void 0 : _this$groupIds.join(",")} track count: ${audioTracks.length}`); 26078 this.warn(error.message); 26079 this.hls.trigger(Events.ERROR, { 26080 type: ErrorTypes.MEDIA_ERROR, 26081 details: ErrorDetails.AUDIO_TRACK_LOAD_ERROR, 26082 fatal: true, 26083 error 26084 }); 26085 } 26086 } else if (this.shouldReloadPlaylist(currentTrack)) { 26087 this.setAudioTrack(this.trackId); 26088 } 26089 } 26090 onError(event, data) { 26091 if (data.fatal || !data.context) { 26092 return; 26093 } 26094 if (data.context.type === PlaylistContextType.AUDIO_TRACK && data.context.id === this.trackId && (!this.groupIds || this.groupIds.indexOf(data.context.groupId) !== -1)) { 26095 this.requestScheduled = -1; 26096 this.checkRetry(data); 26097 } 26098 } 26099 get allAudioTracks() { 26100 return this.tracks; 26101 } 26102 get audioTracks() { 26103 return this.tracksInGroup; 26104 } 26105 get audioTrack() { 26106 return this.trackId; 26107 } 26108 set audioTrack(newId) { 26109 this.selectDefaultTrack = false; 26110 this.setAudioTrack(newId); 26111 } 26112 setAudioOption(audioOption) { 26113 const hls = this.hls; 26114 hls.config.audioPreference = audioOption; 26115 if (audioOption) { 26116 const allAudioTracks = this.allAudioTracks; 26117 this.selectDefaultTrack = false; 26118 if (allAudioTracks.length) { 26119 const currentTrack = this.currentTrack; 26120 if (currentTrack && matchesOption(audioOption, currentTrack, audioMatchPredicate)) { 26121 return currentTrack; 26122 } 26123 const groupIndex = findMatchingOption(audioOption, this.tracksInGroup, audioMatchPredicate); 26124 if (groupIndex > -1) { 26125 const track = this.tracksInGroup[groupIndex]; 26126 this.setAudioTrack(groupIndex); 26127 return track; 26128 } else if (currentTrack) { 26129 let searchIndex = hls.loadLevel; 26130 if (searchIndex === -1) { 26131 searchIndex = hls.firstAutoLevel; 26132 } 26133 const switchIndex = findClosestLevelWithAudioGroup(audioOption, hls.levels, allAudioTracks, searchIndex, audioMatchPredicate); 26134 if (switchIndex === -1) { 26135 return null; 26136 } 26137 hls.nextLoadLevel = switchIndex; 26138 } 26139 if (audioOption.channels || audioOption.audioCodec) { 26140 const withoutCodecAndChannelsMatch = findMatchingOption(audioOption, allAudioTracks); 26141 if (withoutCodecAndChannelsMatch > -1) { 26142 return allAudioTracks[withoutCodecAndChannelsMatch]; 26143 } 26144 } 26145 } 26146 } 26147 return null; 26148 } 26149 setAudioTrack(newId) { 26150 const tracks = this.tracksInGroup; 26151 if (newId < 0 || newId >= tracks.length) { 26152 this.warn(`Invalid audio track id: ${newId}`); 26153 return; 26154 } 26155 this.clearTimer(); 26156 this.selectDefaultTrack = false;
vendor: 4,255 bytes, lines 26157-26279
26157 const lastTrack = this.currentTrack; 26158 const track = tracks[newId]; 26159 const trackLoaded = track.details && !track.details.live; 26160 if (newId === this.trackId && track === lastTrack && trackLoaded) { 26161 return; 26162 } 26163 this.log(`Switching to audio-track ${newId} "${track.name}" lang:${track.lang} group:${track.groupId} channels:${track.channels}`); 26164 this.trackId = newId; 26165 this.currentTrack = track; 26166 this.hls.trigger(Events.AUDIO_TRACK_SWITCHING, _objectSpread23({}, track)); 26167 if (trackLoaded) { 26168 return; 26169 } 26170 const hlsUrlParameters = this.switchParams(track.url, lastTrack == null ? void 0 : lastTrack.details, track.details); 26171 this.loadPlaylist(hlsUrlParameters); 26172 } 26173 findTrackId(currentTrack) { 26174 const audioTracks = this.tracksInGroup; 26175 for (let i3 = 0; i3 < audioTracks.length; i3++) { 26176 const track = audioTracks[i3]; 26177 if (this.selectDefaultTrack && !track.default) { 26178 continue; 26179 } 26180 if (!currentTrack || matchesOption(currentTrack, track, audioMatchPredicate)) { 26181 return i3; 26182 } 26183 } 26184 if (currentTrack) { 26185 const { 26186 name, 26187 lang, 26188 assocLang, 26189 characteristics, 26190 audioCodec, 26191 channels 26192 } = currentTrack; 26193 for (let i3 = 0; i3 < audioTracks.length; i3++) { 26194 const track = audioTracks[i3]; 26195 if (matchesOption({ 26196 name, 26197 lang, 26198 assocLang, 26199 characteristics, 26200 audioCodec, 26201 channels 26202 }, track, audioMatchPredicate)) { 26203 return i3; 26204 } 26205 } 26206 for (let i3 = 0; i3 < audioTracks.length; i3++) { 26207 const track = audioTracks[i3]; 26208 if (mediaAttributesIdentical(currentTrack.attrs, track.attrs, ["LANGUAGE", "ASSOC-LANGUAGE", "CHARACTERISTICS"])) { 26209 return i3; 26210 } 26211 } 26212 for (let i3 = 0; i3 < audioTracks.length; i3++) { 26213 const track = audioTracks[i3]; 26214 if (mediaAttributesIdentical(currentTrack.attrs, track.attrs, ["LANGUAGE"])) { 26215 return i3; 26216 } 26217 } 26218 } 26219 return -1; 26220 } 26221 loadPlaylist(hlsUrlParameters) { 26222 const audioTrack = this.currentTrack; 26223 if (this.shouldLoadPlaylist(audioTrack) && audioTrack) { 26224 super.loadPlaylist(); 26225 const id = audioTrack.id; 26226 const groupId = audioTrack.groupId; 26227 let url = audioTrack.url; 26228 if (hlsUrlParameters) { 26229 try { 26230 url = hlsUrlParameters.addDirectives(url); 26231 } catch (error) { 26232 this.warn(`Could not construct new URL with HLS Delivery Directives: ${error}`); 26233 } 26234 } 26235 this.log(`loading audio-track playlist ${id} "${audioTrack.name}" lang:${audioTrack.lang} group:${groupId}`); 26236 this.clearTimer(); 26237 this.hls.trigger(Events.AUDIO_TRACK_LOADING, { 26238 url, 26239 id, 26240 groupId, 26241 deliveryDirectives: hlsUrlParameters || null 26242 }); 26243 } 26244 } 26245}; 26246var TICK_INTERVAL$1 = 500; 26247var SubtitleStreamController = class extends BaseStreamController { 26248 constructor(hls, fragmentTracker, keyLoader) { 26249 super(hls, fragmentTracker, keyLoader, "[subtitle-stream-controller]", PlaylistLevelType.SUBTITLE); 26250 this.currentTrackId = -1; 26251 this.tracksBuffered = []; 26252 this.mainDetails = null; 26253 this._registerListeners(); 26254 } 26255 onHandlerDestroying() { 26256 this._unregisterListeners(); 26257 super.onHandlerDestroying(); 26258 this.mainDetails = null; 26259 } 26260 _registerListeners() { 26261 const { 26262 hls 26263 } = this; 26264 hls.on(Events.MEDIA_ATTACHED, this.onMediaAttached, this); 26265 hls.on(Events.MEDIA_DETACHING, this.onMediaDetaching, this); 26266 hls.on(Events.MANIFEST_LOADING, this.onManifestLoading, this); 26267 hls.on(Events.LEVEL_LOADED, this.onLevelLoaded, this); 26268 hls.on(Events.ERROR, this.onError, this); 26269 hls.on(Events.SUBTITLE_TRACKS_UPDATED, this.onSubtitleTracksUpdated, this); 26270 hls.on(Events.SUBTITLE_TRACK_SWITCH, this.onSubtitleTrackSwitch, this); 26271 hls.on(Events.SUBTITLE_TRACK_LOADED, this.onSubtitleTrackLoaded, this); 26272 hls.on(Events.SUBTITLE_FRAG_PROCESSED, this.onSubtitleFragProcessed, this); 26273 hls.on(Events.BUFFER_FLUSHING, this.onBufferFlushing, this); 26274 hls.on(Events.FRAG_BUFFERED, this.onFragBuffered, this); 26275 } 26276 _unregisterListeners() { 26277 const { 26278 hls 26279 } = this;
vendor: 7,775 bytes, lines 26280-26503
26280 hls.off(Events.MEDIA_ATTACHED, this.onMediaAttached, this); 26281 hls.off(Events.MEDIA_DETACHING, this.onMediaDetaching, this); 26282 hls.off(Events.MANIFEST_LOADING, this.onManifestLoading, this); 26283 hls.off(Events.LEVEL_LOADED, this.onLevelLoaded, this); 26284 hls.off(Events.ERROR, this.onError, this); 26285 hls.off(Events.SUBTITLE_TRACKS_UPDATED, this.onSubtitleTracksUpdated, this); 26286 hls.off(Events.SUBTITLE_TRACK_SWITCH, this.onSubtitleTrackSwitch, this); 26287 hls.off(Events.SUBTITLE_TRACK_LOADED, this.onSubtitleTrackLoaded, this); 26288 hls.off(Events.SUBTITLE_FRAG_PROCESSED, this.onSubtitleFragProcessed, this); 26289 hls.off(Events.BUFFER_FLUSHING, this.onBufferFlushing, this); 26290 hls.off(Events.FRAG_BUFFERED, this.onFragBuffered, this); 26291 } 26292 startLoad(startPosition) { 26293 this.stopLoad(); 26294 this.state = State.IDLE; 26295 this.setInterval(TICK_INTERVAL$1); 26296 this.nextLoadPosition = this.startPosition = this.lastCurrentTime = startPosition; 26297 this.tick(); 26298 } 26299 onManifestLoading() { 26300 this.mainDetails = null; 26301 this.fragmentTracker.removeAllFragments(); 26302 } 26303 onMediaDetaching() { 26304 this.tracksBuffered = []; 26305 super.onMediaDetaching(); 26306 } 26307 onLevelLoaded(event, data) { 26308 this.mainDetails = data.details; 26309 } 26310 onSubtitleFragProcessed(event, data) { 26311 const { 26312 frag, 26313 success 26314 } = data; 26315 this.fragPrevious = frag; 26316 this.state = State.IDLE; 26317 if (!success) { 26318 return; 26319 } 26320 const buffered = this.tracksBuffered[this.currentTrackId]; 26321 if (!buffered) { 26322 return; 26323 } 26324 let timeRange; 26325 const fragStart = frag.start; 26326 for (let i3 = 0; i3 < buffered.length; i3++) { 26327 if (fragStart >= buffered[i3].start && fragStart <= buffered[i3].end) { 26328 timeRange = buffered[i3]; 26329 break; 26330 } 26331 } 26332 const fragEnd = frag.start + frag.duration; 26333 if (timeRange) { 26334 timeRange.end = fragEnd; 26335 } else { 26336 timeRange = { 26337 start: fragStart, 26338 end: fragEnd 26339 }; 26340 buffered.push(timeRange); 26341 } 26342 this.fragmentTracker.fragBuffered(frag); 26343 this.fragBufferedComplete(frag, null); 26344 } 26345 onBufferFlushing(event, data) { 26346 const { 26347 startOffset, 26348 endOffset 26349 } = data; 26350 if (startOffset === 0 && endOffset !== Number.POSITIVE_INFINITY) { 26351 const endOffsetSubtitles = endOffset - 1; 26352 if (endOffsetSubtitles <= 0) { 26353 return; 26354 } 26355 data.endOffsetSubtitles = Math.max(0, endOffsetSubtitles); 26356 this.tracksBuffered.forEach((buffered) => { 26357 for (let i3 = 0; i3 < buffered.length; ) { 26358 if (buffered[i3].end <= endOffsetSubtitles) { 26359 buffered.shift(); 26360 continue; 26361 } else if (buffered[i3].start < endOffsetSubtitles) { 26362 buffered[i3].start = endOffsetSubtitles; 26363 } else { 26364 break; 26365 } 26366 i3++; 26367 } 26368 }); 26369 this.fragmentTracker.removeFragmentsInRange(startOffset, endOffsetSubtitles, PlaylistLevelType.SUBTITLE); 26370 } 26371 } 26372 onFragBuffered(event, data) { 26373 if (!this.loadedmetadata && data.frag.type === PlaylistLevelType.MAIN) { 26374 var _this$media; 26375 if ((_this$media = this.media) != null && _this$media.buffered.length) { 26376 this.loadedmetadata = true; 26377 } 26378 } 26379 } 26380 // If something goes wrong, proceed to next frag, if we were processing one. 26381 onError(event, data) { 26382 const frag = data.frag; 26383 if ((frag == null ? void 0 : frag.type) === PlaylistLevelType.SUBTITLE) { 26384 if (data.details === ErrorDetails.FRAG_GAP) { 26385 this.fragmentTracker.fragBuffered(frag, true); 26386 } 26387 if (this.fragCurrent) { 26388 this.fragCurrent.abortRequests(); 26389 } 26390 if (this.state !== State.STOPPED) { 26391 this.state = State.IDLE; 26392 } 26393 } 26394 } 26395 // Got all new subtitle levels. 26396 onSubtitleTracksUpdated(event, { 26397 subtitleTracks 26398 }) { 26399 if (this.levels && subtitleOptionsIdentical(this.levels, subtitleTracks)) { 26400 this.levels = subtitleTracks.map((mediaPlaylist) => new Level(mediaPlaylist)); 26401 return; 26402 } 26403 this.tracksBuffered = []; 26404 this.levels = subtitleTracks.map((mediaPlaylist) => { 26405 const level = new Level(mediaPlaylist); 26406 this.tracksBuffered[level.id] = []; 26407 return level; 26408 }); 26409 this.fragmentTracker.removeFragmentsInRange(0, Number.POSITIVE_INFINITY, PlaylistLevelType.SUBTITLE); 26410 this.fragPrevious = null; 26411 this.mediaBuffer = null; 26412 } 26413 onSubtitleTrackSwitch(event, data) { 26414 var _this$levels; 26415 this.currentTrackId = data.id; 26416 if (!((_this$levels = this.levels) != null && _this$levels.length) || this.currentTrackId === -1) { 26417 this.clearInterval(); 26418 return; 26419 } 26420 const currentTrack = this.levels[this.currentTrackId]; 26421 if (currentTrack != null && currentTrack.details) { 26422 this.mediaBuffer = this.mediaBufferTimeRanges; 26423 } else { 26424 this.mediaBuffer = null; 26425 } 26426 if (currentTrack) { 26427 this.setInterval(TICK_INTERVAL$1); 26428 } 26429 } 26430 // Got a new set of subtitle fragments. 26431 onSubtitleTrackLoaded(event, data) { 26432 var _track$details; 26433 const { 26434 currentTrackId, 26435 levels 26436 } = this; 26437 const { 26438 details: newDetails, 26439 id: trackId 26440 } = data; 26441 if (!levels) { 26442 this.warn(`Subtitle tracks were reset while loading level ${trackId}`); 26443 return; 26444 } 26445 const track = levels[trackId]; 26446 if (trackId >= levels.length || !track) { 26447 return; 26448 } 26449 this.log(`Subtitle track ${trackId} loaded [${newDetails.startSN},${newDetails.endSN}]${newDetails.lastPartSn ? `[part-${newDetails.lastPartSn}-${newDetails.lastPartIndex}]` : ""},duration:${newDetails.totalduration}`); 26450 this.mediaBuffer = this.mediaBufferTimeRanges; 26451 let sliding = 0; 26452 if (newDetails.live || (_track$details = track.details) != null && _track$details.live) { 26453 const mainDetails = this.mainDetails; 26454 if (newDetails.deltaUpdateFailed || !mainDetails) { 26455 return; 26456 } 26457 const mainSlidingStartFragment = mainDetails.fragments[0]; 26458 if (!track.details) { 26459 if (newDetails.hasProgramDateTime && mainDetails.hasProgramDateTime) { 26460 alignMediaPlaylistByPDT(newDetails, mainDetails); 26461 sliding = newDetails.fragments[0].start; 26462 } else if (mainSlidingStartFragment) { 26463 sliding = mainSlidingStartFragment.start; 26464 addSliding(newDetails, sliding); 26465 } 26466 } else { 26467 var _this$levelLastLoaded; 26468 sliding = this.alignPlaylists(newDetails, track.details, (_this$levelLastLoaded = this.levelLastLoaded) == null ? void 0 : _this$levelLastLoaded.details); 26469 if (sliding === 0 && mainSlidingStartFragment) { 26470 sliding = mainSlidingStartFragment.start; 26471 addSliding(newDetails, sliding); 26472 } 26473 } 26474 } 26475 track.details = newDetails; 26476 this.levelLastLoaded = track; 26477 if (trackId !== currentTrackId) { 26478 return; 26479 } 26480 if (!this.startFragRequested && (this.mainDetails || !newDetails.live)) { 26481 this.setStartPosition(this.mainDetails || newDetails, sliding); 26482 } 26483 this.tick(); 26484 if (newDetails.live && !this.fragCurrent && this.media && this.state === State.IDLE) { 26485 const foundFrag = findFragmentByPTS(null, newDetails.fragments, this.media.currentTime, 0); 26486 if (!foundFrag) { 26487 this.warn("Subtitle playlist not aligned with playback"); 26488 track.details = void 0; 26489 } 26490 } 26491 } 26492 _handleFragmentLoadComplete(fragLoadedData) { 26493 const { 26494 frag, 26495 payload 26496 } = fragLoadedData; 26497 const decryptData = frag.decryptdata; 26498 const hls = this.hls; 26499 if (this.fragContextChanged(frag)) { 26500 return; 26501 } 26502 if (payload && payload.byteLength > 0 && decryptData != null && decryptData.key && decryptData.iv && decryptData.method === "AES-128") { 26503 const startTime = performance.now();
26504 this.decrypter.decrypt(new Uint8Array(payload), decryptData.key.buffer, decryptData.iv.buffer).catch((err) => { 26505 hls.trigger(Events.ERROR, { 26506 type: ErrorTypes.MEDIA_ERROR, 26507 details: ErrorDetails.FRAG_DECRYPT_ERROR, 26508 fatal: false, 26509 error: err, 26510 reason: err.message, 26511 frag 26512 }); 26513 throw err; 26514 }).then((decryptedData) => { 26515 const endTime = performance.now(); 26516 hls.trigger(Events.FRAG_DECRYPTED, { 26517 frag, 26518 payload: decryptedData, 26519 stats: { 26520 tstart: startTime, 26521 tdecrypt: endTime 26522 } 26523 }); 26524 }).catch((err) => { 26525 this.warn(`${err.name}: ${err.message}`); 26526 this.state = State.IDLE; 26527 }); 26528 } 26529 } 26530 doTick() { 26531 if (!this.media) { 26532 this.state = State.IDLE; 26533 return; 26534 } 26535 if (this.state === State.IDLE) { 26536 const { 26537 currentTrackId, 26538 levels 26539 } = this; 26540 const track = levels == null ? void 0 : levels[currentTrackId]; 26541 if (!track || !levels.length || !track.details) { 26542 return; 26543 } 26544 const { 26545 config 26546 } = this; 26547 const currentTime = this.getLoadPosition(); 26548 const bufferedInfo = BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId] || [], currentTime, config.maxBufferHole); 26549 const { 26550 end: targetBufferTime, 26551 len: bufferLen 26552 } = bufferedInfo; 26553 const mainBufferInfo = this.getFwdBufferInfo(this.media, PlaylistLevelType.MAIN); 26554 const trackDetails = track.details; 26555 const maxBufLen = this.getMaxBufferLength(mainBufferInfo == null ? void 0 : mainBufferInfo.len) + trackDetails.levelTargetDuration; 26556 if (bufferLen > maxBufLen) { 26557 return; 26558 } 26559 const fragments = trackDetails.fragments; 26560 const fragLen = fragments.length; 26561 const end = trackDetails.edge; 26562 let foundFrag = null; 26563 const fragPrevious = this.fragPrevious; 26564 if (targetBufferTime < end) { 26565 const tolerance = config.maxFragLookUpTolerance; 26566 const lookupTolerance = targetBufferTime > end - tolerance ? 0 : tolerance; 26567 foundFrag = findFragmentByPTS(fragPrevious, fragments, Math.max(fragments[0].start, targetBufferTime), lookupTolerance); 26568 if (!foundFrag && fragPrevious && fragPrevious.start < fragments[0].start) { 26569 foundFrag = fragments[0]; 26570 } 26571 } else { 26572 foundFrag = fragments[fragLen - 1]; 26573 } 26574 if (!foundFrag) { 26575 return; 26576 } 26577 foundFrag = this.mapToInitFragWhenRequired(foundFrag); 26578 if (foundFrag.sn !== "initSegment") { 26579 const curSNIdx = foundFrag.sn - trackDetails.startSN; 26580 const prevFrag = fragments[curSNIdx - 1]; 26581 if (prevFrag && prevFrag.cc === foundFrag.cc && this.fragmentTracker.getState(prevFrag) === FragmentState.NOT_LOADED) { 26582 foundFrag = prevFrag; 26583 } 26584 } 26585 if (this.fragmentTracker.getState(foundFrag) === FragmentState.NOT_LOADED) { 26586 this.loadFragment(foundFrag, track, targetBufferTime); 26587 } 26588 } 26589 } 26590 getMaxBufferLength(mainBufferLength) { 26591 const maxConfigBuffer = super.getMaxBufferLength(); 26592 if (!mainBufferLength) { 26593 return maxConfigBuffer; 26594 } 26595 return Math.max(maxConfigBuffer, mainBufferLength); 26596 } 26597 loadFragment(frag, level, targetBufferTime) { 26598 this.fragCurrent = frag; 26599 if (frag.sn === "initSegment") { 26600 this._loadInitSegment(frag, level); 26601 } else { 26602 this.startFragRequested = true; 26603 super.loadFragment(frag, level, targetBufferTime); 26604 } 26605 } 26606 get mediaBufferTimeRanges() { 26607 return new BufferableInstance(this.tracksBuffered[this.currentTrackId] || []); 26608 } 26609}; 26610var BufferableInstance = class { 26611 constructor(timeranges) { 26612 this.buffered = void 0; 26613 const getRange = (name, index2, length2) => { 26614 index2 = index2 >>> 0; 26615 if (index2 > length2 - 1) { 26616 throw new DOMException(`Failed to execute '${name}' on 'TimeRanges': The index provided (${index2}) is greater than the maximum bound (${length2})`); 26617 } 26618 return timeranges[index2][name]; 26619 }; 26620 this.buffered = { 26621 get length() { 26622 return timeranges.length; 26623 }, 26624 end(index2) { 26625 return getRange("end", index2, timeranges.length); 26626 }, 26627 start(index2) { 26628 return getRange("start", index2, timeranges.length); 26629 } 26630 }; 26631 } 26632}; 26633var SubtitleTrackController = class extends BasePlaylistController { 26634 constructor(hls) { 26635 super(hls, "[subtitle-track-controller]"); 26636 this.media = null; 26637 this.tracks = []; 26638 this.groupIds = null; 26639 this.tracksInGroup = []; 26640 this.trackId = -1; 26641 this.currentTrack = null; 26642 this.selectDefaultTrack = true; 26643 this.queuedDefaultTrack = -1; 26644 this.asyncPollTrackChange = () => this.pollTrackChange(0); 26645 this.useTextTrackPolling = false;
vendor: 5,167 bytes, lines 26646-26796
26646 this.subtitlePollingInterval = -1; 26647 this._subtitleDisplay = true; 26648 this.onTextTracksChanged = () => { 26649 if (!this.useTextTrackPolling) { 26650 self.clearInterval(this.subtitlePollingInterval); 26651 } 26652 if (!this.media || !this.hls.config.renderTextTracksNatively) { 26653 return; 26654 } 26655 let textTrack = null; 26656 const tracks = filterSubtitleTracks(this.media.textTracks); 26657 for (let i3 = 0; i3 < tracks.length; i3++) { 26658 if (tracks[i3].mode === "hidden") { 26659 textTrack = tracks[i3]; 26660 } else if (tracks[i3].mode === "showing") { 26661 textTrack = tracks[i3]; 26662 break; 26663 } 26664 } 26665 const trackId = this.findTrackForTextTrack(textTrack); 26666 if (this.subtitleTrack !== trackId) { 26667 this.setSubtitleTrack(trackId); 26668 } 26669 }; 26670 this.registerListeners(); 26671 } 26672 destroy() { 26673 this.unregisterListeners(); 26674 this.tracks.length = 0; 26675 this.tracksInGroup.length = 0; 26676 this.currentTrack = null; 26677 this.onTextTracksChanged = this.asyncPollTrackChange = null; 26678 super.destroy(); 26679 } 26680 get subtitleDisplay() { 26681 return this._subtitleDisplay; 26682 } 26683 set subtitleDisplay(value) { 26684 this._subtitleDisplay = value; 26685 if (this.trackId > -1) { 26686 this.toggleTrackModes(); 26687 } 26688 } 26689 registerListeners() { 26690 const { 26691 hls 26692 } = this; 26693 hls.on(Events.MEDIA_ATTACHED, this.onMediaAttached, this); 26694 hls.on(Events.MEDIA_DETACHING, this.onMediaDetaching, this); 26695 hls.on(Events.MANIFEST_LOADING, this.onManifestLoading, this); 26696 hls.on(Events.MANIFEST_PARSED, this.onManifestParsed, this); 26697 hls.on(Events.LEVEL_LOADING, this.onLevelLoading, this); 26698 hls.on(Events.LEVEL_SWITCHING, this.onLevelSwitching, this); 26699 hls.on(Events.SUBTITLE_TRACK_LOADED, this.onSubtitleTrackLoaded, this); 26700 hls.on(Events.ERROR, this.onError, this); 26701 } 26702 unregisterListeners() { 26703 const { 26704 hls 26705 } = this; 26706 hls.off(Events.MEDIA_ATTACHED, this.onMediaAttached, this); 26707 hls.off(Events.MEDIA_DETACHING, this.onMediaDetaching, this); 26708 hls.off(Events.MANIFEST_LOADING, this.onManifestLoading, this); 26709 hls.off(Events.MANIFEST_PARSED, this.onManifestParsed, this); 26710 hls.off(Events.LEVEL_LOADING, this.onLevelLoading, this); 26711 hls.off(Events.LEVEL_SWITCHING, this.onLevelSwitching, this); 26712 hls.off(Events.SUBTITLE_TRACK_LOADED, this.onSubtitleTrackLoaded, this); 26713 hls.off(Events.ERROR, this.onError, this); 26714 } 26715 // Listen for subtitle track change, then extract the current track ID. 26716 onMediaAttached(event, data) { 26717 this.media = data.media; 26718 if (!this.media) { 26719 return; 26720 } 26721 if (this.queuedDefaultTrack > -1) { 26722 this.subtitleTrack = this.queuedDefaultTrack; 26723 this.queuedDefaultTrack = -1; 26724 } 26725 this.useTextTrackPolling = !(this.media.textTracks && "onchange" in this.media.textTracks); 26726 if (this.useTextTrackPolling) { 26727 this.pollTrackChange(500); 26728 } else { 26729 this.media.textTracks.addEventListener("change", this.asyncPollTrackChange); 26730 } 26731 } 26732 pollTrackChange(timeout) { 26733 self.clearInterval(this.subtitlePollingInterval); 26734 this.subtitlePollingInterval = self.setInterval(this.onTextTracksChanged, timeout); 26735 } 26736 onMediaDetaching() { 26737 if (!this.media) { 26738 return; 26739 } 26740 self.clearInterval(this.subtitlePollingInterval); 26741 if (!this.useTextTrackPolling) { 26742 this.media.textTracks.removeEventListener("change", this.asyncPollTrackChange); 26743 } 26744 if (this.trackId > -1) { 26745 this.queuedDefaultTrack = this.trackId; 26746 } 26747 const textTracks = filterSubtitleTracks(this.media.textTracks); 26748 textTracks.forEach((track) => { 26749 clearCurrentCues(track); 26750 }); 26751 this.subtitleTrack = -1; 26752 this.media = null; 26753 } 26754 onManifestLoading() { 26755 this.tracks = []; 26756 this.groupIds = null; 26757 this.tracksInGroup = []; 26758 this.trackId = -1; 26759 this.currentTrack = null; 26760 this.selectDefaultTrack = true; 26761 } 26762 // Fired whenever a new manifest is loaded. 26763 onManifestParsed(event, data) { 26764 this.tracks = data.subtitleTracks; 26765 } 26766 onSubtitleTrackLoaded(event, data) { 26767 const { 26768 id, 26769 groupId, 26770 details 26771 } = data; 26772 const trackInActiveGroup = this.tracksInGroup[id]; 26773 if (!trackInActiveGroup || trackInActiveGroup.groupId !== groupId) { 26774 this.warn(`Subtitle track with id:${id} and group:${groupId} not found in active group ${trackInActiveGroup == null ? void 0 : trackInActiveGroup.groupId}`); 26775 return; 26776 } 26777 const curDetails = trackInActiveGroup.details; 26778 trackInActiveGroup.details = data.details; 26779 this.log(`Subtitle track ${id} "${trackInActiveGroup.name}" lang:${trackInActiveGroup.lang} group:${groupId} loaded [${details.startSN}-${details.endSN}]`); 26780 if (id === this.trackId) { 26781 this.playlistLoaded(id, data, curDetails); 26782 } 26783 } 26784 onLevelLoading(event, data) { 26785 this.switchLevel(data.level); 26786 } 26787 onLevelSwitching(event, data) { 26788 this.switchLevel(data.level); 26789 } 26790 switchLevel(levelIndex) { 26791 const levelInfo = this.hls.levels[levelIndex]; 26792 if (!levelInfo) { 26793 return; 26794 } 26795 const subtitleGroups = levelInfo.subtitleGroups || null; 26796 const currentGroups = this.groupIds;
vendor: 6,455 bytes, lines 26797-26974
26797 let currentTrack = this.currentTrack; 26798 if (!subtitleGroups || (currentGroups == null ? void 0 : currentGroups.length) !== (subtitleGroups == null ? void 0 : subtitleGroups.length) || subtitleGroups != null && subtitleGroups.some((groupId) => (currentGroups == null ? void 0 : currentGroups.indexOf(groupId)) === -1)) { 26799 this.groupIds = subtitleGroups; 26800 this.trackId = -1; 26801 this.currentTrack = null; 26802 const subtitleTracks = this.tracks.filter((track) => !subtitleGroups || subtitleGroups.indexOf(track.groupId) !== -1); 26803 if (subtitleTracks.length) { 26804 if (this.selectDefaultTrack && !subtitleTracks.some((track) => track.default)) { 26805 this.selectDefaultTrack = false; 26806 } 26807 subtitleTracks.forEach((track, i3) => { 26808 track.id = i3; 26809 }); 26810 } else if (!currentTrack && !this.tracksInGroup.length) { 26811 return; 26812 } 26813 this.tracksInGroup = subtitleTracks; 26814 const subtitlePreference = this.hls.config.subtitlePreference; 26815 if (!currentTrack && subtitlePreference) { 26816 this.selectDefaultTrack = false; 26817 const groupIndex = findMatchingOption(subtitlePreference, subtitleTracks); 26818 if (groupIndex > -1) { 26819 currentTrack = subtitleTracks[groupIndex]; 26820 } else { 26821 const allIndex = findMatchingOption(subtitlePreference, this.tracks); 26822 currentTrack = this.tracks[allIndex]; 26823 } 26824 } 26825 let trackId = this.findTrackId(currentTrack); 26826 if (trackId === -1 && currentTrack) { 26827 trackId = this.findTrackId(null); 26828 } 26829 const subtitleTracksUpdated = { 26830 subtitleTracks 26831 }; 26832 this.log(`Updating subtitle tracks, ${subtitleTracks.length} track(s) found in "${subtitleGroups == null ? void 0 : subtitleGroups.join(",")}" group-id`); 26833 this.hls.trigger(Events.SUBTITLE_TRACKS_UPDATED, subtitleTracksUpdated); 26834 if (trackId !== -1 && this.trackId === -1) { 26835 this.setSubtitleTrack(trackId); 26836 } 26837 } else if (this.shouldReloadPlaylist(currentTrack)) { 26838 this.setSubtitleTrack(this.trackId); 26839 } 26840 } 26841 findTrackId(currentTrack) { 26842 const tracks = this.tracksInGroup; 26843 const selectDefault = this.selectDefaultTrack; 26844 for (let i3 = 0; i3 < tracks.length; i3++) { 26845 const track = tracks[i3]; 26846 if (selectDefault && !track.default || !selectDefault && !currentTrack) { 26847 continue; 26848 } 26849 if (!currentTrack || matchesOption(track, currentTrack)) { 26850 return i3; 26851 } 26852 } 26853 if (currentTrack) { 26854 for (let i3 = 0; i3 < tracks.length; i3++) { 26855 const track = tracks[i3]; 26856 if (mediaAttributesIdentical(currentTrack.attrs, track.attrs, ["LANGUAGE", "ASSOC-LANGUAGE", "CHARACTERISTICS"])) { 26857 return i3; 26858 } 26859 } 26860 for (let i3 = 0; i3 < tracks.length; i3++) { 26861 const track = tracks[i3]; 26862 if (mediaAttributesIdentical(currentTrack.attrs, track.attrs, ["LANGUAGE"])) { 26863 return i3; 26864 } 26865 } 26866 } 26867 return -1; 26868 } 26869 findTrackForTextTrack(textTrack) { 26870 if (textTrack) { 26871 const tracks = this.tracksInGroup; 26872 for (let i3 = 0; i3 < tracks.length; i3++) { 26873 const track = tracks[i3]; 26874 if (subtitleTrackMatchesTextTrack(track, textTrack)) { 26875 return i3; 26876 } 26877 } 26878 } 26879 return -1; 26880 } 26881 onError(event, data) { 26882 if (data.fatal || !data.context) { 26883 return; 26884 } 26885 if (data.context.type === PlaylistContextType.SUBTITLE_TRACK && data.context.id === this.trackId && (!this.groupIds || this.groupIds.indexOf(data.context.groupId) !== -1)) { 26886 this.checkRetry(data); 26887 } 26888 } 26889 get allSubtitleTracks() { 26890 return this.tracks; 26891 } 26892 /** get alternate subtitle tracks list from playlist **/ 26893 get subtitleTracks() { 26894 return this.tracksInGroup; 26895 } 26896 /** get/set index of the selected subtitle track (based on index in subtitle track lists) **/ 26897 get subtitleTrack() { 26898 return this.trackId; 26899 } 26900 set subtitleTrack(newId) { 26901 this.selectDefaultTrack = false; 26902 this.setSubtitleTrack(newId); 26903 } 26904 setSubtitleOption(subtitleOption) { 26905 this.hls.config.subtitlePreference = subtitleOption; 26906 if (subtitleOption) { 26907 const allSubtitleTracks = this.allSubtitleTracks; 26908 this.selectDefaultTrack = false; 26909 if (allSubtitleTracks.length) { 26910 const currentTrack = this.currentTrack; 26911 if (currentTrack && matchesOption(subtitleOption, currentTrack)) { 26912 return currentTrack; 26913 } 26914 const groupIndex = findMatchingOption(subtitleOption, this.tracksInGroup); 26915 if (groupIndex > -1) { 26916 const track = this.tracksInGroup[groupIndex]; 26917 this.setSubtitleTrack(groupIndex); 26918 return track; 26919 } else if (currentTrack) { 26920 return null; 26921 } else { 26922 const allIndex = findMatchingOption(subtitleOption, allSubtitleTracks); 26923 if (allIndex > -1) { 26924 return allSubtitleTracks[allIndex]; 26925 } 26926 } 26927 } 26928 } 26929 return null; 26930 } 26931 loadPlaylist(hlsUrlParameters) { 26932 super.loadPlaylist(); 26933 const currentTrack = this.currentTrack; 26934 if (this.shouldLoadPlaylist(currentTrack) && currentTrack) { 26935 const id = currentTrack.id; 26936 const groupId = currentTrack.groupId; 26937 let url = currentTrack.url; 26938 if (hlsUrlParameters) { 26939 try { 26940 url = hlsUrlParameters.addDirectives(url); 26941 } catch (error) { 26942 this.warn(`Could not construct new URL with HLS Delivery Directives: ${error}`); 26943 } 26944 } 26945 this.log(`Loading subtitle playlist for id ${id}`); 26946 this.hls.trigger(Events.SUBTITLE_TRACK_LOADING, { 26947 url, 26948 id, 26949 groupId, 26950 deliveryDirectives: hlsUrlParameters || null 26951 }); 26952 } 26953 } 26954 /** 26955 * Disables the old subtitleTrack and sets current mode on the next subtitleTrack. 26956 * This operates on the DOM textTracks. 26957 * A value of -1 will disable all subtitle tracks. 26958 */ 26959 toggleTrackModes() { 26960 const { 26961 media 26962 } = this; 26963 if (!media) { 26964 return; 26965 } 26966 const textTracks = filterSubtitleTracks(media.textTracks); 26967 const currentTrack = this.currentTrack; 26968 let nextTrack; 26969 if (currentTrack) { 26970 nextTrack = textTracks.filter((textTrack) => subtitleTrackMatchesTextTrack(currentTrack, textTrack))[0]; 26971 if (!nextTrack) { 26972 this.warn(`Unable to find subtitle TextTrack with name "${currentTrack.name}" and language "${currentTrack.lang}"`); 26973 } 26974 }
26975 [].slice.call(textTracks).forEach((track) => { 26976 if (track.mode !== "disabled" && track !== nextTrack) { 26977 track.mode = "disabled"; 26978 } 26979 }); 26980 if (nextTrack) { 26981 const mode = this.subtitleDisplay ? "showing" : "hidden"; 26982 if (nextTrack.mode !== mode) { 26983 nextTrack.mode = mode; 26984 } 26985 } 26986 } 26987 /** 26988 * This method is responsible for validating the subtitle index and periodically reloading if live. 26989 * Dispatches the SUBTITLE_TRACK_SWITCH event, which instructs the subtitle-stream-controller to load the selected track. 26990 */ 26991 setSubtitleTrack(newId) { 26992 const tracks = this.tracksInGroup; 26993 if (!this.media) { 26994 this.queuedDefaultTrack = newId; 26995 return; 26996 } 26997 if (newId < -1 || newId >= tracks.length || !isFiniteNumber(newId)) { 26998 this.warn(`Invalid subtitle track id: ${newId}`); 26999 return; 27000 } 27001 this.clearTimer(); 27002 this.selectDefaultTrack = false; 27003 const lastTrack = this.currentTrack; 27004 const track = tracks[newId] || null; 27005 this.trackId = newId; 27006 this.currentTrack = track; 27007 this.toggleTrackModes(); 27008 if (!track) { 27009 this.hls.trigger(Events.SUBTITLE_TRACK_SWITCH, { 27010 id: newId 27011 }); 27012 return; 27013 } 27014 const trackLoaded = !!track.details && !track.details.live; 27015 if (newId === this.trackId && track === lastTrack && trackLoaded) { 27016 return; 27017 } 27018 this.log(`Switching to subtitle-track ${newId}` + (track ? ` "${track.name}" lang:${track.lang} group:${track.groupId}` : "")); 27019 const { 27020 id, 27021 groupId = "", 27022 name, 27023 type, 27024 url 27025 } = track; 27026 this.hls.trigger(Events.SUBTITLE_TRACK_SWITCH, { 27027 id, 27028 groupId, 27029 name, 27030 type, 27031 url 27032 }); 27033 const hlsUrlParameters = this.switchParams(track.url, lastTrack == null ? void 0 : lastTrack.details, track.details); 27034 this.loadPlaylist(hlsUrlParameters); 27035 } 27036}; 27037var BufferOperationQueue = class { 27038 constructor(sourceBufferReference) { 27039 this.buffers = void 0; 27040 this.queues = { 27041 video: [], 27042 audio: [], 27043 audiovideo: [] 27044 }; 27045 this.buffers = sourceBufferReference; 27046 } 27047 append(operation, type, pending) { 27048 const queue = this.queues[type]; 27049 queue.push(operation); 27050 if (queue.length === 1 && !pending) { 27051 this.executeNext(type); 27052 } 27053 } 27054 insertAbort(operation, type) { 27055 const queue = this.queues[type]; 27056 queue.unshift(operation); 27057 this.executeNext(type); 27058 } 27059 appendBlocker(type) { 27060 let execute; 27061 const promise = new Promise((resolve) => { 27062 execute = resolve; 27063 }); 27064 const operation = { 27065 execute, 27066 onStart: () => { 27067 }, 27068 onComplete: () => { 27069 }, 27070 onError: () => { 27071 } 27072 }; 27073 this.append(operation, type); 27074 return promise; 27075 } 27076 executeNext(type) { 27077 const queue = this.queues[type]; 27078 if (queue.length) { 27079 const operation = queue[0]; 27080 try { 27081 operation.execute(); 27082 } catch (error) { 27083 logger.warn(`[buffer-operation-queue]: Exception executing "${type}" SourceBuffer operation: ${error}`); 27084 operation.onError(error); 27085 const sb = this.buffers[type]; 27086 if (!(sb != null && sb.updating)) { 27087 this.shiftAndExecuteNext(type); 27088 } 27089 } 27090 } 27091 } 27092 shiftAndExecuteNext(type) { 27093 this.queues[type].shift(); 27094 this.executeNext(type); 27095 } 27096 current(type) { 27097 return this.queues[type][0]; 27098 } 27099}; 27100var VIDEO_CODEC_PROFILE_REPLACE = /(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/; 27101var BufferController = class { 27102 constructor(hls) { 27103 this.details = null; 27104 this._objectUrl = null; 27105 this.operationQueue = void 0; 27106 this.listeners = void 0; 27107 this.hls = void 0; 27108 this.bufferCodecEventsExpected = 0; 27109 this._bufferCodecEventsTotal = 0; 27110 this.media = null; 27111 this.mediaSource = null; 27112 this.lastMpegAudioChunk = null; 27113 this.appendSource = void 0; 27114 this.appendErrors = { 27115 audio: 0, 27116 video: 0, 27117 audiovideo: 0 27118 }; 27119 this.tracks = {}; 27120 this.pendingTracks = {}; 27121 this.sourceBuffer = void 0; 27122 this.log = void 0; 27123 this.warn = void 0; 27124 this.error = void 0; 27125 this._onEndStreaming = (event) => { 27126 if (!this.hls) { 27127 return; 27128 }
27129 this.hls.pauseBuffering(); 27130 }; 27131 this._onStartStreaming = (event) => { 27132 if (!this.hls) { 27133 return; 27134 } 27135 this.hls.resumeBuffering(); 27136 }; 27137 this._onMediaSourceOpen = () => { 27138 const { 27139 media, 27140 mediaSource 27141 } = this; 27142 this.log("Media source opened"); 27143 if (media) { 27144 media.removeEventListener("emptied", this._onMediaEmptied); 27145 this.updateMediaElementDuration(); 27146 this.hls.trigger(Events.MEDIA_ATTACHED, { 27147 media, 27148 mediaSource 27149 }); 27150 } 27151 if (mediaSource) { 27152 mediaSource.removeEventListener("sourceopen", this._onMediaSourceOpen); 27153 } 27154 this.checkPendingTracks(); 27155 }; 27156 this._onMediaSourceClose = () => { 27157 this.log("Media source closed"); 27158 }; 27159 this._onMediaSourceEnded = () => { 27160 this.log("Media source ended"); 27161 }; 27162 this._onMediaEmptied = () => { 27163 const { 27164 mediaSrc, 27165 _objectUrl 27166 } = this; 27167 if (mediaSrc !== _objectUrl) { 27168 logger.error(`Media element src was set while attaching MediaSource (${_objectUrl} > ${mediaSrc})`); 27169 } 27170 }; 27171 this.hls = hls; 27172 const logPrefix = "[buffer-controller]"; 27173 this.appendSource = isManagedMediaSource(getMediaSource(hls.config.preferManagedMediaSource)); 27174 this.log = logger.log.bind(logger, logPrefix); 27175 this.warn = logger.warn.bind(logger, logPrefix); 27176 this.error = logger.error.bind(logger, logPrefix); 27177 this._initSourceBuffer(); 27178 this.registerListeners(); 27179 } 27180 hasSourceTypes() { 27181 return this.getSourceBufferTypes().length > 0 || Object.keys(this.pendingTracks).length > 0; 27182 } 27183 destroy() { 27184 this.unregisterListeners(); 27185 this.details = null; 27186 this.lastMpegAudioChunk = null; 27187 this.hls = null; 27188 } 27189 registerListeners() { 27190 const { 27191 hls 27192 } = this; 27193 hls.on(Events.MEDIA_ATTACHING, this.onMediaAttaching, this); 27194 hls.on(Events.MEDIA_DETACHING, this.onMediaDetaching, this); 27195 hls.on(Events.MANIFEST_LOADING, this.onManifestLoading, this); 27196 hls.on(Events.MANIFEST_PARSED, this.onManifestParsed, this); 27197 hls.on(Events.BUFFER_RESET, this.onBufferReset, this); 27198 hls.on(Events.BUFFER_APPENDING, this.onBufferAppending, this); 27199 hls.on(Events.BUFFER_CODECS, this.onBufferCodecs, this); 27200 hls.on(Events.BUFFER_EOS, this.onBufferEos, this); 27201 hls.on(Events.BUFFER_FLUSHING, this.onBufferFlushing, this); 27202 hls.on(Events.LEVEL_UPDATED, this.onLevelUpdated, this); 27203 hls.on(Events.FRAG_PARSED, this.onFragParsed, this); 27204 hls.on(Events.FRAG_CHANGED, this.onFragChanged, this); 27205 } 27206 unregisterListeners() { 27207 const { 27208 hls 27209 } = this; 27210 hls.off(Events.MEDIA_ATTACHING, this.onMediaAttaching, this); 27211 hls.off(Events.MEDIA_DETACHING, this.onMediaDetaching, this); 27212 hls.off(Events.MANIFEST_LOADING, this.onManifestLoading, this); 27213 hls.off(Events.MANIFEST_PARSED, this.onManifestParsed, this); 27214 hls.off(Events.BUFFER_RESET, this.onBufferReset, this); 27215 hls.off(Events.BUFFER_APPENDING, this.onBufferAppending, this); 27216 hls.off(Events.BUFFER_CODECS, this.onBufferCodecs, this); 27217 hls.off(Events.BUFFER_EOS, this.onBufferEos, this); 27218 hls.off(Events.BUFFER_FLUSHING, this.onBufferFlushing, this); 27219 hls.off(Events.LEVEL_UPDATED, this.onLevelUpdated, this); 27220 hls.off(Events.FRAG_PARSED, this.onFragParsed, this); 27221 hls.off(Events.FRAG_CHANGED, this.onFragChanged, this); 27222 } 27223 _initSourceBuffer() { 27224 this.sourceBuffer = {}; 27225 this.operationQueue = new BufferOperationQueue(this.sourceBuffer); 27226 this.listeners = { 27227 audio: [], 27228 video: [], 27229 audiovideo: [] 27230 }; 27231 this.appendErrors = { 27232 audio: 0, 27233 video: 0, 27234 audiovideo: 0 27235 }; 27236 this.lastMpegAudioChunk = null; 27237 } 27238 onManifestLoading() { 27239 this.bufferCodecEventsExpected = this._bufferCodecEventsTotal = 0; 27240 this.details = null; 27241 } 27242 onManifestParsed(event, data) {
27243 let codecEvents = 2; 27244 if (data.audio && !data.video || !data.altAudio || false) { 27245 codecEvents = 1; 27246 } 27247 this.bufferCodecEventsExpected = this._bufferCodecEventsTotal = codecEvents; 27248 this.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`); 27249 } 27250 onMediaAttaching(event, data) { 27251 const media = this.media = data.media; 27252 const MediaSource = getMediaSource(this.appendSource); 27253 if (media && MediaSource) { 27254 var _ms$constructor; 27255 const ms = this.mediaSource = new MediaSource(); 27256 this.log(`created media source: ${(_ms$constructor = ms.constructor) == null ? void 0 : _ms$constructor.name}`); 27257 ms.addEventListener("sourceopen", this._onMediaSourceOpen); 27258 ms.addEventListener("sourceended", this._onMediaSourceEnded); 27259 ms.addEventListener("sourceclose", this._onMediaSourceClose); 27260 if (this.appendSource) { 27261 ms.addEventListener("startstreaming", this._onStartStreaming); 27262 ms.addEventListener("endstreaming", this._onEndStreaming); 27263 } 27264 const objectUrl = this._objectUrl = self.URL.createObjectURL(ms); 27265 if (this.appendSource) { 27266 try { 27267 media.removeAttribute("src"); 27268 const MMS = self.ManagedMediaSource; 27269 media.disableRemotePlayback = media.disableRemotePlayback || MMS && ms instanceof MMS; 27270 removeSourceChildren(media); 27271 addSource(media, objectUrl); 27272 media.load(); 27273 } catch (error) { 27274 media.src = objectUrl; 27275 } 27276 } else { 27277 media.src = objectUrl; 27278 } 27279 media.addEventListener("emptied", this._onMediaEmptied); 27280 } 27281 } 27282 onMediaDetaching() { 27283 const { 27284 media, 27285 mediaSource, 27286 _objectUrl 27287 } = this; 27288 if (mediaSource) { 27289 this.log("media source detaching"); 27290 if (mediaSource.readyState === "open") { 27291 try { 27292 mediaSource.endOfStream(); 27293 } catch (err) { 27294 this.warn(`onMediaDetaching: ${err.message} while calling endOfStream`); 27295 } 27296 } 27297 this.onBufferReset(); 27298 mediaSource.removeEventListener("sourceopen", this._onMediaSourceOpen); 27299 mediaSource.removeEventListener("sourceended", this._onMediaSourceEnded); 27300 mediaSource.removeEventListener("sourceclose", this._onMediaSourceClose); 27301 if (this.appendSource) { 27302 mediaSource.removeEventListener("startstreaming", this._onStartStreaming); 27303 mediaSource.removeEventListener("endstreaming", this._onEndStreaming); 27304 } 27305 if (media) { 27306 media.removeEventListener("emptied", this._onMediaEmptied); 27307 if (_objectUrl) { 27308 self.URL.revokeObjectURL(_objectUrl); 27309 } 27310 if (this.mediaSrc === _objectUrl) { 27311 media.removeAttribute("src"); 27312 if (this.appendSource) { 27313 removeSourceChildren(media); 27314 } 27315 media.load(); 27316 } else { 27317 this.warn("media|source.src was changed by a third party - skip cleanup"); 27318 } 27319 } 27320 this.mediaSource = null; 27321 this.media = null; 27322 this._objectUrl = null; 27323 this.bufferCodecEventsExpected = this._bufferCodecEventsTotal; 27324 this.pendingTracks = {}; 27325 this.tracks = {}; 27326 } 27327 this.hls.trigger(Events.MEDIA_DETACHED, void 0); 27328 } 27329 onBufferReset() { 27330 this.getSourceBufferTypes().forEach((type) => { 27331 this.resetBuffer(type); 27332 }); 27333 this._initSourceBuffer(); 27334 this.hls.resumeBuffering(); 27335 } 27336 resetBuffer(type) { 27337 const sb = this.sourceBuffer[type]; 27338 try { 27339 if (sb) { 27340 var _this$mediaSource; 27341 this.removeBufferListeners(type); 27342 this.sourceBuffer[type] = void 0; 27343 if ((_this$mediaSource = this.mediaSource) != null && _this$mediaSource.sourceBuffers.length) { 27344 this.mediaSource.removeSourceBuffer(sb); 27345 } 27346 } 27347 } catch (err) { 27348 this.warn(`onBufferReset ${type}`, err); 27349 } 27350 } 27351 onBufferCodecs(event, data) { 27352 const sourceBufferCount = this.getSourceBufferTypes().length; 27353 const trackNames = Object.keys(data); 27354 trackNames.forEach((trackName) => { 27355 if (sourceBufferCount) { 27356 const track = this.tracks[trackName]; 27357 if (track && typeof track.buffer.changeType === "function") { 27358 var _trackCodec; 27359 const { 27360 id, 27361 codec, 27362 levelCodec, 27363 container, 27364 metadata 27365 } = data[trackName]; 27366 const currentCodecFull = pickMostCompleteCodecName(track.codec, track.levelCodec); 27367 const currentCodec = currentCodecFull == null ? void 0 : currentCodecFull.replace(VIDEO_CODEC_PROFILE_REPLACE, "$1"); 27368 let trackCodec = pickMostCompleteCodecName(codec, levelCodec); 27369 const nextCodec = (_trackCodec = trackCodec) == null ? void 0 : _trackCodec.replace(VIDEO_CODEC_PROFILE_REPLACE, "$1"); 27370 if (trackCodec && currentCodec !== nextCodec) { 27371 if (trackName.slice(0, 5) === "audio") { 27372 trackCodec = getCodecCompatibleName(trackCodec, this.appendSource); 27373 } 27374 const mimeType = `${container};codecs=${trackCodec}`; 27375 this.appendChangeType(trackName, mimeType); 27376 this.log(`switching codec ${currentCodecFull} to ${trackCodec}`); 27377 this.tracks[trackName] = { 27378 buffer: track.buffer, 27379 codec, 27380 container, 27381 levelCodec, 27382 metadata, 27383 id 27384 }; 27385 } 27386 } 27387 } else { 27388 this.pendingTracks[trackName] = data[trackName]; 27389 } 27390 }); 27391 if (sourceBufferCount) { 27392 return; 27393 } 27394 const bufferCodecEventsExpected = Math.max(this.bufferCodecEventsExpected - 1, 0); 27395 if (this.bufferCodecEventsExpected !== bufferCodecEventsExpected) { 27396 this.log(`${bufferCodecEventsExpected}
27396 bufferCodec event(s) expected ${trackNames.join(",")}`); 27397 this.bufferCodecEventsExpected = bufferCodecEventsExpected; 27398 } 27399 if (this.mediaSource && this.mediaSource.readyState === "open") { 27400 this.checkPendingTracks(); 27401 } 27402 } 27403 appendChangeType(type, mimeType) { 27404 const { 27405 operationQueue 27406 } = this; 27407 const operation = { 27408 execute: () => { 27409 const sb = this.sourceBuffer[type]; 27410 if (sb) { 27411 this.log(`changing ${type} sourceBuffer type to ${mimeType}`); 27412 sb.changeType(mimeType); 27413 } 27414 operationQueue.shiftAndExecuteNext(type); 27415 }, 27416 onStart: () => { 27417 }, 27418 onComplete: () => { 27419 }, 27420 onError: (error) => { 27421 this.warn(`Failed to change ${type} SourceBuffer type`, error); 27422 } 27423 }; 27424 operationQueue.append(operation, type, !!this.pendingTracks[type]); 27425 } 27426 onBufferAppending(event, eventData) { 27427 const { 27428 hls, 27429 operationQueue, 27430 tracks 27431 } = this; 27432 const { 27433 data, 27434 type, 27435 frag, 27436 part, 27437 chunkMeta 27438 } = eventData; 27439 const chunkStats = chunkMeta.buffering[type]; 27440 const bufferAppendingStart = self.performance.now(); 27441 chunkStats.start = bufferAppendingStart; 27442 const fragBuffering = frag.stats.buffering; 27443 const partBuffering = part ? part.stats.buffering : null; 27444 if (fragBuffering.start === 0) { 27445 fragBuffering.start = bufferAppendingStart; 27446 } 27447 if (partBuffering && partBuffering.start === 0) { 27448 partBuffering.start = bufferAppendingStart; 27449 } 27450 const audioTrack = tracks.audio; 27451 let checkTimestampOffset = false; 27452 if (type === "audio" && (audioTrack == null ? void 0 : audioTrack.container) === "audio/mpeg") { 27453 checkTimestampOffset = !this.lastMpegAudioChunk || chunkMeta.id === 1 || this.lastMpegAudioChunk.sn !== chunkMeta.sn; 27454 this.lastMpegAudioChunk = chunkMeta; 27455 } 27456 const fragStart = frag.start; 27457 const operation = { 27458 execute: () => { 27459 chunkStats.executeStart = self.performance.now(); 27460 if (checkTimestampOffset) { 27461 const sb = this.sourceBuffer[type]; 27462 if (sb) { 27463 const delta = fragStart - sb.timestampOffset; 27464 if (Math.abs(delta) >= 0.1) { 27465 this.log(`Updating audio SourceBuffer timestampOffset to ${fragStart} (delta: ${delta}) sn: ${frag.sn})`); 27466 sb.timestampOffset = fragStart; 27467 } 27468 } 27469 } 27470 this.appendExecutor(data, type); 27471 }, 27472 onStart: () => { 27473 }, 27474 onComplete: () => { 27475 const end = self.performance.now(); 27476 chunkStats.executeEnd = chunkStats.end = end; 27477 if (fragBuffering.first === 0) { 27478 fragBuffering.first = end; 27479 } 27480 if (partBuffering && partBuffering.first === 0) { 27481 partBuffering.first = end; 27482 } 27483 const { 27484 sourceBuffer 27485 } = this; 27486 const timeRanges = {}; 27487 for (const type2 in sourceBuffer) { 27488 timeRanges[type2] = BufferHelper.getBuffered(sourceBuffer[type2]); 27489 } 27490 this.appendErrors[type] = 0; 27491 if (type === "audio" || type === "video") { 27492 this.appendErrors.audiovideo = 0; 27493 } else { 27494 this.appendErrors.audio = 0; 27495 this.appendErrors.video = 0; 27496 } 27497 this.hls.trigger(Events.BUFFER_APPENDED, { 27498 type, 27499 frag, 27500 part, 27501 chunkMeta, 27502 parent: frag.type, 27503 timeRanges 27504 }); 27505 }, 27506 onError: (error) => { 27507 const event2 = { 27508 type: ErrorTypes.MEDIA_ERROR, 27509 parent: frag.type, 27510 details: ErrorDetails.BUFFER_APPEND_ERROR, 27511 sourceBufferName: type, 27512 frag, 27513 part, 27514 chunkMeta, 27515 error, 27516 err: error, 27517 fatal: false 27518 }; 27519 if (error.code === DOMException.QUOTA_EXCEEDED_ERR) { 27520 event2.details = ErrorDetails.BUFFER_FULL_ERROR; 27521 } else { 27522 const appendErrorCount = ++this.appendErrors[type]; 27523 event2.details = ErrorDetails.BUFFER_APPEND_ERROR; 27524 this.warn(`Failed ${appendErrorCount}/${hls.config.appendErrorMaxRetry} times to append segment in "${type}" sourceBuffer`); 27525 if (appendErrorCount >= hls.config.appendErrorMaxRetry) { 27526 event2.fatal = true; 27527 } 27528 } 27529 hls.trigger(Events.ERROR, event2); 27530 } 27531 }; 27532 operationQueue.append(operation, type, !!this.pendingTracks[type]); 27533 } 27534 onBufferFlushing(event, data) { 27535 const { 27536 operationQueue 27537 } = this; 27538 const flushOperation = (type) => ({ 27539 execute: this.removeExecutor.bind(this, type, data.startOffset, data.endOffset), 27540 onStart: () => { 27541 }, 27542 onComplete: () => { 27543 this.hls.trigger(Events.BUFFER_FLUSHED, { 27544 type 27545 }); 27546 }, 27547 onError: (error) => { 27548 this.warn(`Failed to remove from ${type} SourceBuffer`, error); 27549 } 27550 }); 27551 if (data.type) { 27552 operationQueue.append(flushOperation(data.type), data.type); 27553 } else {
27554 this.getSourceBufferTypes().forEach((type) => { 27555 operationQueue.append(flushOperation(type), type); 27556 }); 27557 } 27558 } 27559 onFragParsed(event, data) { 27560 const { 27561 frag, 27562 part 27563 } = data; 27564 const buffersAppendedTo = []; 27565 const elementaryStreams = part ? part.elementaryStreams : frag.elementaryStreams; 27566 if (elementaryStreams[ElementaryStreamTypes.AUDIOVIDEO]) { 27567 buffersAppendedTo.push("audiovideo"); 27568 } else { 27569 if (elementaryStreams[ElementaryStreamTypes.AUDIO]) { 27570 buffersAppendedTo.push("audio"); 27571 } 27572 if (elementaryStreams[ElementaryStreamTypes.VIDEO]) { 27573 buffersAppendedTo.push("video"); 27574 } 27575 } 27576 const onUnblocked = () => { 27577 const now2 = self.performance.now(); 27578 frag.stats.buffering.end = now2; 27579 if (part) { 27580 part.stats.buffering.end = now2; 27581 } 27582 const stats = part ? part.stats : frag.stats; 27583 this.hls.trigger(Events.FRAG_BUFFERED, { 27584 frag, 27585 part, 27586 stats, 27587 id: frag.type 27588 }); 27589 }; 27590 if (buffersAppendedTo.length === 0) { 27591 this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${frag.type} level: ${frag.level} sn: ${frag.sn}`); 27592 } 27593 this.blockBuffers(onUnblocked, buffersAppendedTo); 27594 } 27595 onFragChanged(event, data) { 27596 this.trimBuffers(); 27597 } 27598 // on BUFFER_EOS mark matching sourcebuffer(s) as ended and trigger checkEos() 27599 // an undefined data.type will mark all buffers as EOS. 27600 onBufferEos(event, data) { 27601 const ended = this.getSourceBufferTypes().reduce((acc, type) => { 27602 const sb = this.sourceBuffer[type]; 27603 if (sb && (!data.type || data.type === type)) { 27604 sb.ending = true; 27605 if (!sb.ended) { 27606 sb.ended = true; 27607 this.log(`${type} sourceBuffer now EOS`); 27608 } 27609 } 27610 return acc && !!(!sb || sb.ended); 27611 }, true); 27612 if (ended) { 27613 this.log(`Queueing mediaSource.endOfStream()`); 27614 this.blockBuffers(() => {
27615 this.getSourceBufferTypes().forEach((type) => { 27616 const sb = this.sourceBuffer[type]; 27617 if (sb) { 27618 sb.ending = false; 27619 } 27620 }); 27621 const { 27622 mediaSource 27623 } = this; 27624 if (!mediaSource || mediaSource.readyState !== "open") { 27625 if (mediaSource) { 27626 this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${mediaSource.readyState}`); 27627 } 27628 return; 27629 } 27630 this.log(`Calling mediaSource.endOfStream()`); 27631 mediaSource.endOfStream(); 27632 }); 27633 } 27634 } 27635 onLevelUpdated(event, { 27636 details 27637 }) { 27638 if (!details.fragments.length) { 27639 return; 27640 } 27641 this.details = details; 27642 if (this.getSourceBufferTypes().length) { 27643 this.blockBuffers(this.updateMediaElementDuration.bind(this)); 27644 } else { 27645 this.updateMediaElementDuration(); 27646 } 27647 } 27648 trimBuffers() { 27649 const { 27650 hls, 27651 details, 27652 media 27653 } = this; 27654 if (!media || details === null) { 27655 return; 27656 } 27657 const sourceBufferTypes = this.getSourceBufferTypes(); 27658 if (!sourceBufferTypes.length) { 27659 return; 27660 } 27661 const config = hls.config; 27662 const currentTime = media.currentTime; 27663 const targetDuration = details.levelTargetDuration; 27664 const backBufferLength = details.live && config.liveBackBufferLength !== null ? config.liveBackBufferLength : config.backBufferLength; 27665 if (isFiniteNumber(backBufferLength) && backBufferLength > 0) { 27666 const maxBackBufferLength = Math.max(backBufferLength, targetDuration); 27667 const targetBackBufferPosition = Math.floor(currentTime / targetDuration) * targetDuration - maxBackBufferLength; 27668 this.flushBackBuffer(currentTime, targetDuration, targetBackBufferPosition); 27669 } 27670 if (isFiniteNumber(config.frontBufferFlushThreshold) && config.frontBufferFlushThreshold > 0) { 27671 const frontBufferLength = Math.max(config.maxBufferLength, config.frontBufferFlushThreshold); 27672 const maxFrontBufferLength = Math.max(frontBufferLength, targetDuration); 27673 const targetFrontBufferPosition = Math.floor(currentTime / targetDuration) * targetDuration + maxFrontBufferLength; 27674 this.flushFrontBuffer(currentTime, targetDuration, targetFrontBufferPosition); 27675 } 27676 } 27677 flushBackBuffer(currentTime, targetDuration, targetBackBufferPosition) { 27678 const { 27679 details, 27680 sourceBuffer 27681 } = this; 27682 const sourceBufferTypes = this.getSourceBufferTypes(); 27683 sourceBufferTypes.forEach((type) => { 27684 const sb = sourceBuffer[type]; 27685 if (sb) { 27686 const buffered = BufferHelper.getBuffered(sb); 27687 if (buffered.length > 0 && targetBackBufferPosition > buffered.start(0)) { 27688 this.hls.trigger(Events.BACK_BUFFER_REACHED, { 27689 bufferEnd: targetBackBufferPosition 27690 }); 27691 if (details != null && details.live) { 27692 this.hls.trigger(Events.LIVE_BACK_BUFFER_REACHED, { 27693 bufferEnd: targetBackBufferPosition 27694 }); 27695 } else if (sb.ended && buffered.end(buffered.length - 1) - currentTime < targetDuration * 2) { 27696 this.log(`Cannot flush ${type} back buffer while SourceBuffer is in ended state`); 27697 return; 27698 } 27699 this.hls.trigger(Events.BUFFER_FLUSHING, { 27700 startOffset: 0, 27701 endOffset: targetBackBufferPosition, 27702 type 27703 }); 27704 } 27705 } 27706 }); 27707 } 27708 flushFrontBuffer(currentTime, targetDuration, targetFrontBufferPosition) { 27709 const { 27710 sourceBuffer 27711 } = this; 27712 const sourceBufferTypes = this.getSourceBufferTypes(); 27713 sourceBufferTypes.forEach((type) => { 27714 const sb = sourceBuffer[type]; 27715 if (sb) { 27716 const buffered = BufferHelper.getBuffered(sb); 27717 const numBufferedRanges = buffered.length; 27718 if (numBufferedRanges < 2) { 27719 return; 27720 } 27721 const bufferStart = buffered.start(numBufferedRanges - 1); 27722 const bufferEnd = buffered.end(numBufferedRanges - 1); 27723 if (targetFrontBufferPosition > bufferStart || currentTime >= bufferStart && currentTime <= bufferEnd) { 27724 return; 27725 } else if (sb.ended && currentTime - bufferEnd < 2 * targetDuration) { 27726 this.log(`Cannot flush ${type} front buffer while SourceBuffer is in ended state`); 27727 return; 27728 } 27729 this.hls.trigger(Events.BUFFER_FLUSHING, { 27730 startOffset: bufferStart, 27731 endOffset: Infinity, 27732 type 27733 }); 27734 } 27735 }); 27736 } 27737 /** 27738 * Update Media Source duration to current level duration or override to Infinity if configuration parameter 27739 * 'liveDurationInfinity` is set to `true` 27740 * More details: https://github.com/video-dev/hls.js/issues/355 27741 */ 27742 updateMediaElementDuration() { 27743 if (!this.details || !this.media || !this.mediaSource || this.mediaSource.readyState !== "open") { 27744 return; 27745 } 27746 const { 27747 details, 27748 hls, 27749 media, 27750 mediaSource 27751 } = this; 27752 const levelDuration = details.fragments[0].start + details.totalduration; 27753 const mediaDuration = media.duration; 27754 const msDuration = isFiniteNumber(mediaSource.duration) ? mediaSource.duration : 0; 27755 if (details.live && hls.config.liveDurationInfinity) { 27756 mediaSource.duration = Infinity; 27757 this.updateSeekableRange(details); 27758 } else if (levelDuration > msDuration && levelDuration > mediaDuration || !isFiniteNumber(mediaDuration)) { 27759 this.log(`Updating Media Source duration to ${levelDuration.toFixed(3)}`); 27760 mediaSource.duration = levelDuration; 27761 } 27762 } 27763 updateSeekableRange(levelDetails) { 27764 const mediaSource = this.mediaSource; 27765 const fragments = levelDetails.fragments; 27766 const len = fragments.length; 27767 if (len && levelDetails.live && mediaSource != null && mediaSource.setLiveSeekableRange) { 27768 const start = Math.max(0, fragments[0].start); 27769 const end = Math.max(start, start + levelDetails.totalduration); 27770 this.log(`Media Source duration is set to ${mediaSource.duration}. Setting seekable range to ${start}-${end}.`); 27771 mediaSource.setLiveSeekableRange(start, end); 27772 } 27773 } 27774 checkPendingTracks() { 27775 const { 27776 bufferCodecEventsExpected, 27777 operationQueue, 27778 pendingTracks 27779 } = this; 27780 const pendingTracksCount = Object.keys(pendingTracks).length; 27781 if (pendingTracksCount && (!bufferCodecEventsExpected || pendingTracksCount === 2 || "audiovideo" in pendingTracks)) { 27782 this.createSourceBuffers(pendingTracks); 27783 this.pendingTracks = {};
27784 const buffers = this.getSourceBufferTypes(); 27785 if (buffers.length) { 27786 this.hls.trigger(Events.BUFFER_CREATED, { 27787 tracks: this.tracks 27788 }); 27789 buffers.forEach((type) => { 27790 operationQueue.executeNext(type); 27791 }); 27792 } else { 27793 const error = new Error("could not create source buffer for media codec(s)"); 27794 this.hls.trigger(Events.ERROR, { 27795 type: ErrorTypes.MEDIA_ERROR, 27796 details: ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR, 27797 fatal: true, 27798 error, 27799 reason: error.message 27800 }); 27801 } 27802 } 27803 } 27804 createSourceBuffers(tracks) { 27805 const { 27806 sourceBuffer, 27807 mediaSource 27808 } = this; 27809 if (!mediaSource) { 27810 throw Error("createSourceBuffers called when mediaSource was null"); 27811 } 27812 for (const trackName in tracks) { 27813 if (!sourceBuffer[trackName]) { 27814 var _track$levelCodec; 27815 const track = tracks[trackName]; 27816 if (!track) { 27817 throw Error(`source buffer exists for track ${trackName}, however track does not`); 27818 } 27819 let codec = ((_track$levelCodec = track.levelCodec) == null ? void 0 : _track$levelCodec.indexOf(",")) === -1 ? track.levelCodec : track.codec; 27820 if (codec) { 27821 if (trackName.slice(0, 5) === "audio") { 27822 codec = getCodecCompatibleName(codec, this.appendSource); 27823 } 27824 } 27825 const mimeType = `${track.container};codecs=${codec}`; 27826 this.log(`creating sourceBuffer(${mimeType})`); 27827 try { 27828 const sb = sourceBuffer[trackName] = mediaSource.addSourceBuffer(mimeType); 27829 const sbName = trackName; 27830 this.addBufferListener(sbName, "updatestart", this._onSBUpdateStart); 27831 this.addBufferListener(sbName, "updateend", this._onSBUpdateEnd); 27832 this.addBufferListener(sbName, "error", this._onSBUpdateError); 27833 if (this.appendSource) { 27834 this.addBufferListener(sbName, "bufferedchange", (type, event) => { 27835 const removedRanges = event.removedRanges; 27836 if (removedRanges != null && removedRanges.length) { 27837 this.hls.trigger(Events.BUFFER_FLUSHED, { 27838 type: trackName 27839 }); 27840 } 27841 }); 27842 } 27843 this.tracks[trackName] = { 27844 buffer: sb, 27845 codec, 27846 container: track.container, 27847 levelCodec: track.levelCodec, 27848 metadata: track.metadata, 27849 id: track.id 27850 }; 27851 } catch (err) { 27852 this.error(`error while trying to add sourceBuffer: ${err.message}`); 27853 this.hls.trigger(Events.ERROR, { 27854 type: ErrorTypes.MEDIA_ERROR, 27855 details: ErrorDetails.BUFFER_ADD_CODEC_ERROR, 27856 fatal: false, 27857 error: err, 27858 sourceBufferName: trackName, 27859 mimeType 27860 }); 27861 } 27862 } 27863 } 27864 } 27865 get mediaSrc() { 27866 var _this$media, _this$media$querySele; 27867 const media = ((_this$media = this.media) == null ? void 0 : (_this$media$querySele = _this$media.querySelector) == null ? void 0 : _this$media$querySele.call(_this$media, "source")) || this.media; 27868 return media == null ? void 0 : media.src; 27869 } 27870 _onSBUpdateStart(type) { 27871 const { 27872 operationQueue 27873 } = this; 27874 const operation = operationQueue.current(type); 27875 operation.onStart(); 27876 } 27877 _onSBUpdateEnd(type) { 27878 var _this$mediaSource2; 27879 if (((_this$mediaSource2 = this.mediaSource) == null ? void 0 : _this$mediaSource2.readyState) === "closed") { 27880 this.resetBuffer(type); 27881 return; 27882 } 27883 const { 27884 operationQueue 27885 } = this; 27886 const operation = operationQueue.current(type); 27887 operation.onComplete(); 27888 operationQueue.shiftAndExecuteNext(type); 27889 } 27890 _onSBUpdateError(type, event) { 27891 var _this$mediaSource3; 27892 const error = new Error(`${type} SourceBuffer error. MediaSource readyState: ${(_this$mediaSource3 = this.mediaSource) == null ? void 0 : _this$mediaSource3.readyState}`); 27893 this.error(`${error}`, event); 27894 this.hls.trigger(Events.ERROR, { 27895 type: ErrorTypes.MEDIA_ERROR, 27896 details: ErrorDetails.BUFFER_APPENDING_ERROR, 27897 sourceBufferName: type, 27898 error, 27899 fatal: false 27900 }); 27901 const operation = this.operationQueue.current(type); 27902 if (operation) { 27903 operation.onError(error); 27904 } 27905 } 27906 // This method must result in an updateend event; if remove is not called, _onSBUpdateEnd must be called manually 27907 removeExecutor(type, startOffset, endOffset) { 27908 const { 27909 media, 27910 mediaSource, 27911 operationQueue, 27912 sourceBuffer 27913 } = this; 27914 const sb = sourceBuffer[type]; 27915 if (!media || !mediaSource || !sb) { 27916 this.warn(`Attempting to remove from the ${type} SourceBuffer, but it does not exist`); 27917 operationQueue.shiftAndExecuteNext(type); 27918 return; 27919 } 27920 const mediaDuration = isFiniteNumber(media.duration) ? media.duration : Infinity; 27921 const msDuration = isFiniteNumber(mediaSource.duration) ? mediaSource.duration : Infinity; 27922 const removeStart = Math.max(0, startOffset); 27923 const removeEnd = Math.min(endOffset, mediaDuration, msDuration); 27924 if (removeEnd > removeStart && (!sb.ending || sb.ended)) { 27925 sb.ended = false;
27926 this.log(`Removing [${removeStart},${removeEnd}] from the ${type} SourceBuffer`); 27927 sb.remove(removeStart, removeEnd); 27928 } else { 27929 operationQueue.shiftAndExecuteNext(type); 27930 } 27931 } 27932 // This method must result in an updateend event; if append is not called, _onSBUpdateEnd must be called manually 27933 appendExecutor(data, type) { 27934 const sb = this.sourceBuffer[type]; 27935 if (!sb) { 27936 if (!this.pendingTracks[type]) { 27937 throw new Error(`Attempting to append to the ${type} SourceBuffer, but it does not exist`); 27938 } 27939 return; 27940 } 27941 sb.ended = false; 27942 sb.appendBuffer(data); 27943 } 27944 // Enqueues an operation to each SourceBuffer queue which, upon execution, resolves a promise. When all promises 27945 // resolve, the onUnblocked function is executed. Functions calling this method do not need to unblock the queue 27946 // upon completion, since we already do it here 27947 blockBuffers(onUnblocked, buffers = this.getSourceBufferTypes()) { 27948 if (!buffers.length) { 27949 this.log("Blocking operation requested, but no SourceBuffers exist"); 27950 Promise.resolve().then(onUnblocked); 27951 return; 27952 } 27953 const { 27954 operationQueue 27955 } = this; 27956 const blockingOperations = buffers.map((type) => operationQueue.appendBlocker(type)); 27957 Promise.all(blockingOperations).then(() => { 27958 onUnblocked(); 27959 buffers.forEach((type) => { 27960 const sb = this.sourceBuffer[type]; 27961 if (!(sb != null && sb.updating)) { 27962 operationQueue.shiftAndExecuteNext(type); 27963 } 27964 }); 27965 }); 27966 } 27967 getSourceBufferTypes() { 27968 return Object.keys(this.sourceBuffer); 27969 } 27970 addBufferListener(type, event, fn) { 27971 const buffer = this.sourceBuffer[type]; 27972 if (!buffer) { 27973 return; 27974 } 27975 const listener = fn.bind(this, type); 27976 this.listeners[type].push({ 27977 event, 27978 listener 27979 }); 27980 buffer.addEventListener(event, listener); 27981 } 27982 removeBufferListeners(type) { 27983 const buffer = this.sourceBuffer[type]; 27984 if (!buffer) { 27985 return; 27986 } 27987 this.listeners[type].forEach((l2) => { 27988 buffer.removeEventListener(l2.event, l2.listener); 27989 }); 27990 } 27991}; 27992function removeSourceChildren(node2) { 27993 const sourceChildren = node2.querySelectorAll("source"); 27994 [].slice.call(sourceChildren).forEach((source) => { 27995 node2.removeChild(source); 27996 }); 27997} 27998function addSource(media, url) { 27999 const source = self.document.createElement("source"); 28000 source.type = "video/mp4"; 28001 source.src = url; 28002 media.appendChild(source); 28003} 28004var specialCea608CharsCodes = { 28005 42: 225, 28006 // lowercase a, acute accent 28007 92: 233, 28008 // lowercase e, acute accent 28009 94: 237, 28010 // lowercase i, acute accent 28011 95: 243, 28012 // lowercase o, acute accent 28013 96: 250, 28014 // lowercase u, acute accent 28015 123: 231, 28016 // lowercase c with cedilla 28017 124: 247, 28018 // division symbol 28019 125: 209, 28020 // uppercase N tilde 28021 126: 241, 28022 // lowercase n tilde 28023 127: 9608, 28024 // Full block 28025 // THIS BLOCK INCLUDES THE 16 EXTENDED (TWO-BYTE) LINE 21 CHARACTERS 28026 // THAT COME FROM HI BYTE=0x11 AND LOW BETWEEN 0x30 AND 0x3F 28027 // THIS MEANS THAT \x50 MUST BE ADDED TO THE VALUES 28028 128: 174, 28029 // Registered symbol (R) 28030 129: 176, 28031 // degree sign 28032 130: 189, 28033 // 1/2 symbol 28034 131: 191, 28035 // Inverted (open) question mark 28036 132: 8482, 28037 // Trademark symbol (TM) 28038 133: 162, 28039 // Cents symbol 28040 134: 163, 28041 // Pounds sterling 28042 135: 9834, 28043 // Music 8'th note 28044 136: 224, 28045 // lowercase a, grave accent 28046 137: 32, 28047 // transparent space (regular) 28048 138: 232, 28049 // lowercase e, grave accent 28050 139: 226, 28051 // lowercase a, circumflex accent 28052 140: 234, 28053 // lowercase e, circumflex accent 28054 141: 238, 28055 // lowercase i, circumflex accent 28056 142: 244, 28057 // lowercase o, circumflex accent 28058 143: 251, 28059 // lowercase u, circumflex accent 28060 // THIS BLOCK INCLUDES THE 32 EXTENDED (TWO-BYTE) LINE 21 CHARACTERS 28061 // THAT COME FROM HI BYTE=0x12 AND LOW BETWEEN 0x20 AND 0x3F 28062 144: 193, 28063 // capital letter A with acute 28064 145: 201, 28065 // capital letter E with acute 28066 146: 211, 28067 // capital letter O with acute 28068 147: 218, 28069 // capital letter U with acute 28070 148: 220, 28071 // capital letter U with diaresis 28072 149: 252, 28073 // lowercase letter U with diaeresis 28074 150: 8216, 28075 // opening single quote 28076 151: 161, 28077 // inverted exclamation mark 28078 152: 42, 28079 // asterisk 28080 153: 8217, 28081 // closing single quote 28082 154: 9473, 28083 // box drawings heavy horizontal 28084 155: 169, 28085 // copyright sign 28086 156: 8480, 28087 // Service mark 28088 157: 8226, 28089 // (round) bullet 28090 158: 8220, 28091 // Left double quotation mark 28092 159: 8221, 28093 // Right double quotation mark 28094 160: 192, 28095 // uppercase A, grave accent 28096 161: 194, 28097 // uppercase A, circumflex 28098 162: 199, 28099 // uppercase C with cedilla 28100 163: 200, 28101 // uppercase E, grave accent 28102 164: 202, 28103 // uppercase E, circumflex 28104 165: 203, 28105 // capital letter E with diaresis 28106 166: 235, 28107 // lowercase letter e with diaresis 28108 167: 206, 28109 // uppercase I, circumflex 28110 168: 207, 28111 // uppercase I, with diaresis 28112 169: 239, 28113 // lowercase i, with diaresis 28114 170: 212, 28115 // uppercase O, circumflex 28116 171: 217, 28117 // uppercase U, grave accent 28118 172: 249, 28119 // lowercase u, grave accent 28120 173: 219, 28121 // uppercase U, circumflex 28122 174: 171, 28123 // left-pointing double angle quotation mark 28124 175: 187, 28125 // right-pointing double angle quotation mark 28126 // THIS BLOCK INCLUDES THE 32 EXTENDED (TWO-BYTE) LINE 21 CHARACTERS 28127 // THAT COME FROM HI BYTE=0x13 AND LOW BETWEEN 0x20 AND 0x3F 28128 176: 195, 28129 // Uppercase A, tilde 28130 177: 227, 28131 // Lowercase a, tilde 28132 178: 205, 28133 // Uppercase I, acute accent 28134 179: 204, 28135 // Uppercase I, grave accent 28136 180: 236, 28137 // Lowercase i, grave accent 28138 181: 210, 28139 // Uppercase O, grave accent 28140 182: 242, 28141 // Lowercase o, grave accent 28142 183: 213, 28143 // Uppercase O, tilde 28144 184: 245, 28145 // Lowercase o, tilde 28146 185: 123, 28147 // Open curly brace 28148 186: 125, 28149 // Closing curly brace 28150 187: 92, 28151 // Backslash 28152 188: 94, 28153 // Caret 28154 189: 95, 28155 // Underscore
28156 190: 124, 28157 // Pipe (vertical line) 28158 191: 8764, 28159 // Tilde operator 28160 192: 196, 28161 // Uppercase A, umlaut 28162 193: 228, 28163 // Lowercase A, umlaut 28164 194: 214, 28165 // Uppercase O, umlaut 28166 195: 246, 28167 // Lowercase o, umlaut 28168 196: 223, 28169 // Esszett (sharp S) 28170 197: 165, 28171 // Yen symbol 28172 198: 164, 28173 // Generic currency sign 28174 199: 9475, 28175 // Box drawings heavy vertical 28176 200: 197, 28177 // Uppercase A, ring 28178 201: 229, 28179 // Lowercase A, ring 28180 202: 216, 28181 // Uppercase O, stroke 28182 203: 248, 28183 // Lowercase o, strok 28184 204: 9487, 28185 // Box drawings heavy down and right 28186 205: 9491, 28187 // Box drawings heavy down and left 28188 206: 9495, 28189 // Box drawings heavy up and right 28190 207: 9499 28191 // Box drawings heavy up and left 28192}; 28193var getCharForByte = (byte) => String.fromCharCode(specialCea608CharsCodes[byte] || byte); 28194var NR_ROWS = 15; 28195var NR_COLS = 100; 28196var rowsLowCh1 = { 28197 17: 1, 28198 18: 3, 28199 21: 5, 28200 22: 7, 28201 23: 9, 28202 16: 11, 28203 19: 12, 28204 20: 14 28205}; 28206var rowsHighCh1 = { 28207 17: 2, 28208 18: 4, 28209 21: 6, 28210 22: 8, 28211 23: 10, 28212 19: 13, 28213 20: 15 28214}; 28215var rowsLowCh2 = { 28216 25: 1, 28217 26: 3, 28218 29: 5, 28219 30: 7, 28220 31: 9, 28221 24: 11, 28222 27: 12, 28223 28: 14 28224}; 28225var rowsHighCh2 = { 28226 25: 2, 28227 26: 4, 28228 29: 6, 28229 30: 8, 28230 31: 10, 28231 27: 13, 28232 28: 15 28233}; 28234var backgroundColors = ["white", "green", "blue", "cyan", "red", "yellow", "magenta", "black", "transparent"]; 28235var CaptionsLogger = class { 28236 constructor() { 28237 this.time = null; 28238 this.verboseLevel = 0; 28239 } 28240 log(severity, msg) { 28241 if (this.verboseLevel >= severity) { 28242 const m2 = typeof msg === "function" ? msg() : msg; 28243 logger.log(`${this.time} [${severity}] ${m2}`); 28244 } 28245 } 28246}; 28247var numArrayToHexArray = function numArrayToHexArray2(numArray) { 28248 const hexArray = []; 28249 for (let j3 = 0; j3 < numArray.length; j3++) { 28250 hexArray.push(numArray[j3].toString(16)); 28251 } 28252 return hexArray; 28253}; 28254var PenState = class { 28255 constructor() { 28256 this.foreground = "white"; 28257 this.underline = false; 28258 this.italics = false; 28259 this.background = "black"; 28260 this.flash = false; 28261 } 28262 reset() { 28263 this.foreground = "white"; 28264 this.underline = false; 28265 this.italics = false; 28266 this.background = "black"; 28267 this.flash = false; 28268 } 28269 setStyles(styles) { 28270 const attribs = ["foreground", "underline", "italics", "background", "flash"]; 28271 for (let i3 = 0; i3 < attribs.length; i3++) { 28272 const style = attribs[i3]; 28273 if (styles.hasOwnProperty(style)) { 28274 this[style] = styles[style]; 28275 } 28276 } 28277 } 28278 isDefault() { 28279 return this.foreground === "white" && !this.underline && !this.italics && this.background === "black" && !this.flash; 28280 } 28281 equals(other) { 28282 return this.foreground === other.foreground && this.underline === other.underline && this.italics === other.italics && this.background === other.background && this.flash === other.flash; 28283 } 28284 copy(newPenState) { 28285 this.foreground = newPenState.foreground; 28286 this.underline = newPenState.underline; 28287 this.italics = newPenState.italics; 28288 this.background = newPenState.background; 28289 this.flash = newPenState.flash; 28290 } 28291 toString() { 28292 return "color=" + this.foreground + ", underline=" + this.underline + ", italics=" + this.italics + ", background=" + this.background + ", flash=" + this.flash; 28293 } 28294}; 28295var StyledUnicodeChar = class { 28296 constructor() { 28297 this.uchar = " "; 28298 this.penState = new PenState(); 28299 } 28300 reset() { 28301 this.uchar = " "; 28302 this.penState.reset(); 28303 } 28304 setChar(uchar, newPenState) { 28305 this.uchar = uchar; 28306 this.penState.copy(newPenState); 28307 } 28308 setPenState(newPenState) { 28309 this.penState.copy(newPenState); 28310 } 28311 equals(other) { 28312 return this.uchar === other.uchar && this.penState.equals(other.penState); 28313 } 28314 copy(newChar) { 28315 this.uchar = newChar.uchar; 28316 this.penState.copy(newChar.penState); 28317 } 28318 isEmpty() { 28319 return this.uchar === " " && this.penState.isDefault(); 28320 } 28321}; 28322var Row = class { 28323 constructor(logger2) { 28324 this.chars = []; 28325 this.pos = 0; 28326 this.currPenState = new PenState(); 28327 this.cueStartTime = null; 28328 this.logger = void 0; 28329 for (let i3 = 0; i3 < NR_COLS; i3++) { 28330 this.chars.push(new StyledUnicodeChar()); 28331 } 28332 this.logger = logger2; 28333 } 28334 equals(other) { 28335 for (let i3 = 0; i3 < NR_COLS; i3++) { 28336 if (!this.chars[i3].equals(other.chars[i3])) { 28337 return false;
vendor: 4,918 bytes, lines 28338-28532
28338 } 28339 } 28340 return true; 28341 } 28342 copy(other) { 28343 for (let i3 = 0; i3 < NR_COLS; i3++) { 28344 this.chars[i3].copy(other.chars[i3]); 28345 } 28346 } 28347 isEmpty() { 28348 let empty = true; 28349 for (let i3 = 0; i3 < NR_COLS; i3++) { 28350 if (!this.chars[i3].isEmpty()) { 28351 empty = false; 28352 break; 28353 } 28354 } 28355 return empty; 28356 } 28357 /** 28358 * Set the cursor to a valid column. 28359 */ 28360 setCursor(absPos) { 28361 if (this.pos !== absPos) { 28362 this.pos = absPos; 28363 } 28364 if (this.pos < 0) { 28365 this.logger.log(3, "Negative cursor position " + this.pos); 28366 this.pos = 0; 28367 } else if (this.pos > NR_COLS) { 28368 this.logger.log(3, "Too large cursor position " + this.pos); 28369 this.pos = NR_COLS; 28370 } 28371 } 28372 /** 28373 * Move the cursor relative to current position. 28374 */ 28375 moveCursor(relPos) { 28376 const newPos = this.pos + relPos; 28377 if (relPos > 1) { 28378 for (let i3 = this.pos + 1; i3 < newPos + 1; i3++) { 28379 this.chars[i3].setPenState(this.currPenState); 28380 } 28381 } 28382 this.setCursor(newPos); 28383 } 28384 /** 28385 * Backspace, move one step back and clear character. 28386 */ 28387 backSpace() { 28388 this.moveCursor(-1); 28389 this.chars[this.pos].setChar(" ", this.currPenState); 28390 } 28391 insertChar(byte) { 28392 if (byte >= 144) { 28393 this.backSpace(); 28394 } 28395 const char2 = getCharForByte(byte); 28396 if (this.pos >= NR_COLS) { 28397 this.logger.log(0, () => "Cannot insert " + byte.toString(16) + " (" + char2 + ") at position " + this.pos + ". Skipping it!"); 28398 return; 28399 } 28400 this.chars[this.pos].setChar(char2, this.currPenState); 28401 this.moveCursor(1); 28402 } 28403 clearFromPos(startPos) { 28404 let i3; 28405 for (i3 = startPos; i3 < NR_COLS; i3++) { 28406 this.chars[i3].reset(); 28407 } 28408 } 28409 clear() { 28410 this.clearFromPos(0); 28411 this.pos = 0; 28412 this.currPenState.reset(); 28413 } 28414 clearToEndOfRow() { 28415 this.clearFromPos(this.pos); 28416 } 28417 getTextString() { 28418 const chars = []; 28419 let empty = true; 28420 for (let i3 = 0; i3 < NR_COLS; i3++) { 28421 const char2 = this.chars[i3].uchar; 28422 if (char2 !== " ") { 28423 empty = false; 28424 } 28425 chars.push(char2); 28426 } 28427 if (empty) { 28428 return ""; 28429 } else { 28430 return chars.join(""); 28431 } 28432 } 28433 setPenStyles(styles) { 28434 this.currPenState.setStyles(styles); 28435 const currChar = this.chars[this.pos]; 28436 currChar.setPenState(this.currPenState); 28437 } 28438}; 28439var CaptionScreen = class { 28440 constructor(logger2) { 28441 this.rows = []; 28442 this.currRow = NR_ROWS - 1; 28443 this.nrRollUpRows = null; 28444 this.lastOutputScreen = null; 28445 this.logger = void 0; 28446 for (let i3 = 0; i3 < NR_ROWS; i3++) { 28447 this.rows.push(new Row(logger2)); 28448 } 28449 this.logger = logger2; 28450 } 28451 reset() { 28452 for (let i3 = 0; i3 < NR_ROWS; i3++) { 28453 this.rows[i3].clear(); 28454 } 28455 this.currRow = NR_ROWS - 1; 28456 } 28457 equals(other) { 28458 let equal = true; 28459 for (let i3 = 0; i3 < NR_ROWS; i3++) { 28460 if (!this.rows[i3].equals(other.rows[i3])) { 28461 equal = false; 28462 break; 28463 } 28464 } 28465 return equal; 28466 } 28467 copy(other) { 28468 for (let i3 = 0; i3 < NR_ROWS; i3++) { 28469 this.rows[i3].copy(other.rows[i3]); 28470 } 28471 } 28472 isEmpty() { 28473 let empty = true; 28474 for (let i3 = 0; i3 < NR_ROWS; i3++) { 28475 if (!this.rows[i3].isEmpty()) { 28476 empty = false; 28477 break; 28478 } 28479 } 28480 return empty; 28481 } 28482 backSpace() { 28483 const row = this.rows[this.currRow]; 28484 row.backSpace(); 28485 } 28486 clearToEndOfRow() { 28487 const row = this.rows[this.currRow]; 28488 row.clearToEndOfRow(); 28489 } 28490 /** 28491 * Insert a character (without styling) in the current row. 28492 */ 28493 insertChar(char2) { 28494 const row = this.rows[this.currRow]; 28495 row.insertChar(char2); 28496 } 28497 setPen(styles) { 28498 const row = this.rows[this.currRow]; 28499 row.setPenStyles(styles); 28500 } 28501 moveCursor(relPos) { 28502 const row = this.rows[this.currRow]; 28503 row.moveCursor(relPos); 28504 } 28505 setCursor(absPos) { 28506 this.logger.log(2, "setCursor: " + absPos); 28507 const row = this.rows[this.currRow]; 28508 row.setCursor(absPos); 28509 } 28510 setPAC(pacData) { 28511 this.logger.log(2, () => "pacData = " + JSON.stringify(pacData)); 28512 let newRow = pacData.row - 1; 28513 if (this.nrRollUpRows && newRow < this.nrRollUpRows - 1) { 28514 newRow = this.nrRollUpRows - 1; 28515 } 28516 if (this.nrRollUpRows && this.currRow !== newRow) { 28517 for (let i3 = 0; i3 < NR_ROWS; i3++) { 28518 this.rows[i3].clear(); 28519 } 28520 const topRowIndex = this.currRow + 1 - this.nrRollUpRows; 28521 const lastOutputScreen = this.lastOutputScreen; 28522 if (lastOutputScreen) { 28523 const prevLineTime = lastOutputScreen.rows[topRowIndex].cueStartTime; 28524 const time = this.logger.time; 28525 if (prevLineTime !== null && time !== null && prevLineTime < time) { 28526 for (let i3 = 0; i3 < this.nrRollUpRows; i3++) { 28527 this.rows[newRow - this.nrRollUpRows + i3 + 1].copy(lastOutputScreen.rows[topRowIndex + i3]); 28528 } 28529 } 28530 } 28531 } 28532 this.currRow = newRow;
vendor: 5,329 bytes, lines 28533-28718
28533 const row = this.rows[this.currRow]; 28534 if (pacData.indent !== null) { 28535 const indent = pacData.indent; 28536 const prevPos = Math.max(indent - 1, 0); 28537 row.setCursor(pacData.indent); 28538 pacData.color = row.chars[prevPos].penState.foreground; 28539 } 28540 const styles = { 28541 foreground: pacData.color, 28542 underline: pacData.underline, 28543 italics: pacData.italics, 28544 background: "black", 28545 flash: false 28546 }; 28547 this.setPen(styles); 28548 } 28549 /** 28550 * Set background/extra foreground, but first do back_space, and then insert space (backwards compatibility). 28551 */ 28552 setBkgData(bkgData) { 28553 this.logger.log(2, () => "bkgData = " + JSON.stringify(bkgData)); 28554 this.backSpace(); 28555 this.setPen(bkgData); 28556 this.insertChar(32); 28557 } 28558 setRollUpRows(nrRows) { 28559 this.nrRollUpRows = nrRows; 28560 } 28561 rollUp() { 28562 if (this.nrRollUpRows === null) { 28563 this.logger.log(3, "roll_up but nrRollUpRows not set yet"); 28564 return; 28565 } 28566 this.logger.log(1, () => this.getDisplayText()); 28567 const topRowIndex = this.currRow + 1 - this.nrRollUpRows; 28568 const topRow = this.rows.splice(topRowIndex, 1)[0]; 28569 topRow.clear(); 28570 this.rows.splice(this.currRow, 0, topRow); 28571 this.logger.log(2, "Rolling up"); 28572 } 28573 /** 28574 * Get all non-empty rows with as unicode text. 28575 */ 28576 getDisplayText(asOneRow) { 28577 asOneRow = asOneRow || false; 28578 const displayText = []; 28579 let text = ""; 28580 let rowNr = -1; 28581 for (let i3 = 0; i3 < NR_ROWS; i3++) { 28582 const rowText = this.rows[i3].getTextString(); 28583 if (rowText) { 28584 rowNr = i3 + 1; 28585 if (asOneRow) { 28586 displayText.push("Row " + rowNr + ": '" + rowText + "'"); 28587 } else { 28588 displayText.push(rowText.trim()); 28589 } 28590 } 28591 } 28592 if (displayText.length > 0) { 28593 if (asOneRow) { 28594 text = "[" + displayText.join(" | ") + "]"; 28595 } else { 28596 text = displayText.join("\n"); 28597 } 28598 } 28599 return text; 28600 } 28601 getTextAndFormat() { 28602 return this.rows; 28603 } 28604}; 28605var Cea608Channel = class { 28606 constructor(channelNumber, outputFilter, logger2) { 28607 this.chNr = void 0; 28608 this.outputFilter = void 0; 28609 this.mode = void 0; 28610 this.verbose = void 0; 28611 this.displayedMemory = void 0; 28612 this.nonDisplayedMemory = void 0; 28613 this.lastOutputScreen = void 0; 28614 this.currRollUpRow = void 0; 28615 this.writeScreen = void 0; 28616 this.cueStartTime = void 0; 28617 this.logger = void 0; 28618 this.chNr = channelNumber; 28619 this.outputFilter = outputFilter; 28620 this.mode = null; 28621 this.verbose = 0; 28622 this.displayedMemory = new CaptionScreen(logger2); 28623 this.nonDisplayedMemory = new CaptionScreen(logger2); 28624 this.lastOutputScreen = new CaptionScreen(logger2); 28625 this.currRollUpRow = this.displayedMemory.rows[NR_ROWS - 1]; 28626 this.writeScreen = this.displayedMemory; 28627 this.mode = null; 28628 this.cueStartTime = null; 28629 this.logger = logger2; 28630 } 28631 reset() { 28632 this.mode = null; 28633 this.displayedMemory.reset(); 28634 this.nonDisplayedMemory.reset(); 28635 this.lastOutputScreen.reset(); 28636 this.outputFilter.reset(); 28637 this.currRollUpRow = this.displayedMemory.rows[NR_ROWS - 1]; 28638 this.writeScreen = this.displayedMemory; 28639 this.mode = null; 28640 this.cueStartTime = null; 28641 } 28642 getHandler() { 28643 return this.outputFilter; 28644 } 28645 setHandler(newHandler) { 28646 this.outputFilter = newHandler; 28647 } 28648 setPAC(pacData) { 28649 this.writeScreen.setPAC(pacData); 28650 } 28651 setBkgData(bkgData) { 28652 this.writeScreen.setBkgData(bkgData); 28653 } 28654 setMode(newMode) { 28655 if (newMode === this.mode) { 28656 return; 28657 } 28658 this.mode = newMode; 28659 this.logger.log(2, () => "MODE=" + newMode); 28660 if (this.mode === "MODE_POP-ON") { 28661 this.writeScreen = this.nonDisplayedMemory; 28662 } else { 28663 this.writeScreen = this.displayedMemory; 28664 this.writeScreen.reset(); 28665 } 28666 if (this.mode !== "MODE_ROLL-UP") { 28667 this.displayedMemory.nrRollUpRows = null; 28668 this.nonDisplayedMemory.nrRollUpRows = null; 28669 } 28670 this.mode = newMode; 28671 } 28672 insertChars(chars) { 28673 for (let i3 = 0; i3 < chars.length; i3++) { 28674 this.writeScreen.insertChar(chars[i3]); 28675 } 28676 const screen = this.writeScreen === this.displayedMemory ? "DISP" : "NON_DISP"; 28677 this.logger.log(2, () => screen + ": " + this.writeScreen.getDisplayText(true)); 28678 if (this.mode === "MODE_PAINT-ON" || this.mode === "MODE_ROLL-UP") { 28679 this.logger.log(1, () => "DISPLAYED: " + this.displayedMemory.getDisplayText(true)); 28680 this.outputDataUpdate(); 28681 } 28682 } 28683 ccRCL() { 28684 this.logger.log(2, "RCL - Resume Caption Loading"); 28685 this.setMode("MODE_POP-ON"); 28686 } 28687 ccBS() { 28688 this.logger.log(2, "BS - BackSpace"); 28689 if (this.mode === "MODE_TEXT") { 28690 return; 28691 } 28692 this.writeScreen.backSpace(); 28693 if (this.writeScreen === this.displayedMemory) { 28694 this.outputDataUpdate(); 28695 } 28696 } 28697 ccAOF() { 28698 } 28699 ccAON() { 28700 } 28701 ccDER() { 28702 this.logger.log(2, "DER- Delete to End of Row"); 28703 this.writeScreen.clearToEndOfRow(); 28704 this.outputDataUpdate(); 28705 } 28706 ccRU(nrRows) { 28707 this.logger.log(2, "RU(" + nrRows + ") - Roll Up"); 28708 this.writeScreen = this.displayedMemory; 28709 this.setMode("MODE_ROLL-UP"); 28710 this.writeScreen.setRollUpRows(nrRows); 28711 } 28712 ccFON() { 28713 this.logger.log(2, "FON - Flash On"); 28714 this.writeScreen.setPen({ 28715 flash: true 28716 }); 28717 } 28718 ccRDC() {
vendor: 13,022 bytes, lines 28719-29160
28719 this.logger.log(2, "RDC - Resume Direct Captioning"); 28720 this.setMode("MODE_PAINT-ON"); 28721 } 28722 ccTR() { 28723 this.logger.log(2, "TR"); 28724 this.setMode("MODE_TEXT"); 28725 } 28726 ccRTD() { 28727 this.logger.log(2, "RTD"); 28728 this.setMode("MODE_TEXT"); 28729 } 28730 ccEDM() { 28731 this.logger.log(2, "EDM - Erase Displayed Memory"); 28732 this.displayedMemory.reset(); 28733 this.outputDataUpdate(true); 28734 } 28735 ccCR() { 28736 this.logger.log(2, "CR - Carriage Return"); 28737 this.writeScreen.rollUp(); 28738 this.outputDataUpdate(true); 28739 } 28740 ccENM() { 28741 this.logger.log(2, "ENM - Erase Non-displayed Memory"); 28742 this.nonDisplayedMemory.reset(); 28743 } 28744 ccEOC() { 28745 this.logger.log(2, "EOC - End Of Caption"); 28746 if (this.mode === "MODE_POP-ON") { 28747 const tmp = this.displayedMemory; 28748 this.displayedMemory = this.nonDisplayedMemory; 28749 this.nonDisplayedMemory = tmp; 28750 this.writeScreen = this.nonDisplayedMemory; 28751 this.logger.log(1, () => "DISP: " + this.displayedMemory.getDisplayText()); 28752 } 28753 this.outputDataUpdate(true); 28754 } 28755 ccTO(nrCols) { 28756 this.logger.log(2, "TO(" + nrCols + ") - Tab Offset"); 28757 this.writeScreen.moveCursor(nrCols); 28758 } 28759 ccMIDROW(secondByte) { 28760 const styles = { 28761 flash: false 28762 }; 28763 styles.underline = secondByte % 2 === 1; 28764 styles.italics = secondByte >= 46; 28765 if (!styles.italics) { 28766 const colorIndex = Math.floor(secondByte / 2) - 16; 28767 const colors2 = ["white", "green", "blue", "cyan", "red", "yellow", "magenta"]; 28768 styles.foreground = colors2[colorIndex]; 28769 } else { 28770 styles.foreground = "white"; 28771 } 28772 this.logger.log(2, "MIDROW: " + JSON.stringify(styles)); 28773 this.writeScreen.setPen(styles); 28774 } 28775 outputDataUpdate(dispatch = false) { 28776 const time = this.logger.time; 28777 if (time === null) { 28778 return; 28779 } 28780 if (this.outputFilter) { 28781 if (this.cueStartTime === null && !this.displayedMemory.isEmpty()) { 28782 this.cueStartTime = time; 28783 } else { 28784 if (!this.displayedMemory.equals(this.lastOutputScreen)) { 28785 this.outputFilter.newCue(this.cueStartTime, time, this.lastOutputScreen); 28786 if (dispatch && this.outputFilter.dispatchCue) { 28787 this.outputFilter.dispatchCue(); 28788 } 28789 this.cueStartTime = this.displayedMemory.isEmpty() ? null : time; 28790 } 28791 } 28792 this.lastOutputScreen.copy(this.displayedMemory); 28793 } 28794 } 28795 cueSplitAtTime(t2) { 28796 if (this.outputFilter) { 28797 if (!this.displayedMemory.isEmpty()) { 28798 if (this.outputFilter.newCue) { 28799 this.outputFilter.newCue(this.cueStartTime, t2, this.displayedMemory); 28800 } 28801 this.cueStartTime = t2; 28802 } 28803 } 28804 } 28805}; 28806var Cea608Parser = class { 28807 constructor(field, out1, out2) { 28808 this.channels = void 0; 28809 this.currentChannel = 0; 28810 this.cmdHistory = createCmdHistory(); 28811 this.logger = void 0; 28812 const logger2 = this.logger = new CaptionsLogger(); 28813 this.channels = [null, new Cea608Channel(field, out1, logger2), new Cea608Channel(field + 1, out2, logger2)]; 28814 } 28815 getHandler(channel) { 28816 return this.channels[channel].getHandler(); 28817 } 28818 setHandler(channel, newHandler) { 28819 this.channels[channel].setHandler(newHandler); 28820 } 28821 /** 28822 * Add data for time t in forms of list of bytes (unsigned ints). The bytes are treated as pairs. 28823 */ 28824 addData(time, byteList) { 28825 this.logger.time = time; 28826 for (let i3 = 0; i3 < byteList.length; i3 += 2) { 28827 const a2 = byteList[i3] & 127; 28828 const b3 = byteList[i3 + 1] & 127; 28829 let cmdFound = false; 28830 let charsFound = null; 28831 if (a2 === 0 && b3 === 0) { 28832 continue; 28833 } else { 28834 this.logger.log(3, () => "[" + numArrayToHexArray([byteList[i3], byteList[i3 + 1]]) + "] -> (" + numArrayToHexArray([a2, b3]) + ")"); 28835 } 28836 const cmdHistory = this.cmdHistory; 28837 const isControlCode = a2 >= 16 && a2 <= 31; 28838 if (isControlCode) { 28839 if (hasCmdRepeated(a2, b3, cmdHistory)) { 28840 setLastCmd(null, null, cmdHistory); 28841 this.logger.log(3, () => "Repeated command (" + numArrayToHexArray([a2, b3]) + ") is dropped"); 28842 continue; 28843 } 28844 setLastCmd(a2, b3, this.cmdHistory); 28845 cmdFound = this.parseCmd(a2, b3); 28846 if (!cmdFound) { 28847 cmdFound = this.parseMidrow(a2, b3); 28848 } 28849 if (!cmdFound) { 28850 cmdFound = this.parsePAC(a2, b3); 28851 } 28852 if (!cmdFound) { 28853 cmdFound = this.parseBackgroundAttributes(a2, b3); 28854 } 28855 } else { 28856 setLastCmd(null, null, cmdHistory); 28857 } 28858 if (!cmdFound) { 28859 charsFound = this.parseChars(a2, b3); 28860 if (charsFound) { 28861 const currChNr = this.currentChannel; 28862 if (currChNr && currChNr > 0) { 28863 const channel = this.channels[currChNr]; 28864 channel.insertChars(charsFound); 28865 } else { 28866 this.logger.log(2, "No channel found yet. TEXT-MODE?"); 28867 } 28868 } 28869 } 28870 if (!cmdFound && !charsFound) { 28871 this.logger.log(2, () => "Couldn't parse cleaned data " + numArrayToHexArray([a2, b3]) + " orig: " + numArrayToHexArray([byteList[i3], byteList[i3 + 1]])); 28872 } 28873 } 28874 } 28875 /** 28876 * Parse Command. 28877 * @returns True if a command was found 28878 */ 28879 parseCmd(a2, b3) { 28880 const cond1 = (a2 === 20 || a2 === 28 || a2 === 21 || a2 === 29) && b3 >= 32 && b3 <= 47; 28881 const cond2 = (a2 === 23 || a2 === 31) && b3 >= 33 && b3 <= 35; 28882 if (!(cond1 || cond2)) { 28883 return false; 28884 } 28885 const chNr = a2 === 20 || a2 === 21 || a2 === 23 ? 1 : 2; 28886 const channel = this.channels[chNr]; 28887 if (a2 === 20 || a2 === 21 || a2 === 28 || a2 === 29) { 28888 if (b3 === 32) { 28889 channel.ccRCL(); 28890 } else if (b3 === 33) { 28891 channel.ccBS(); 28892 } else if (b3 === 34) { 28893 channel.ccAOF(); 28894 } else if (b3 === 35) { 28895 channel.ccAON(); 28896 } else if (b3 === 36) { 28897 channel.ccDER(); 28898 } else if (b3 === 37) { 28899 channel.ccRU(2); 28900 } else if (b3 === 38) { 28901 channel.ccRU(3); 28902 } else if (b3 === 39) { 28903 channel.ccRU(4); 28904 } else if (b3 === 40) { 28905 channel.ccFON(); 28906 } else if (b3 === 41) { 28907 channel.ccRDC(); 28908 } else if (b3 === 42) { 28909 channel.ccTR(); 28910 } else if (b3 === 43) { 28911 channel.ccRTD(); 28912 } else if (b3 === 44) { 28913 channel.ccEDM(); 28914 } else if (b3 === 45) { 28915 channel.ccCR(); 28916 } else if (b3 === 46) { 28917 channel.ccENM(); 28918 } else if (b3 === 47) { 28919 channel.ccEOC(); 28920 } 28921 } else { 28922 channel.ccTO(b3 - 32); 28923 } 28924 this.currentChannel = chNr; 28925 return true; 28926 } 28927 /** 28928 * Parse midrow styling command 28929 */ 28930 parseMidrow(a2, b3) { 28931 let chNr = 0; 28932 if ((a2 === 17 || a2 === 25) && b3 >= 32 && b3 <= 47) { 28933 if (a2 === 17) { 28934 chNr = 1; 28935 } else { 28936 chNr = 2; 28937 } 28938 if (chNr !== this.currentChannel) { 28939 this.logger.log(0, "Mismatch channel in midrow parsing"); 28940 return false; 28941 } 28942 const channel = this.channels[chNr]; 28943 if (!channel) { 28944 return false; 28945 } 28946 channel.ccMIDROW(b3); 28947 this.logger.log(3, () => "MIDROW (" + numArrayToHexArray([a2, b3]) + ")"); 28948 return true; 28949 } 28950 return false; 28951 } 28952 /** 28953 * Parse Preable Access Codes (Table 53). 28954 * @returns {Boolean} Tells if PAC found 28955 */ 28956 parsePAC(a2, b3) { 28957 let row; 28958 const case1 = (a2 >= 17 && a2 <= 23 || a2 >= 25 && a2 <= 31) && b3 >= 64 && b3 <= 127; 28959 const case2 = (a2 === 16 || a2 === 24) && b3 >= 64 && b3 <= 95; 28960 if (!(case1 || case2)) { 28961 return false; 28962 } 28963 const chNr = a2 <= 23 ? 1 : 2; 28964 if (b3 >= 64 && b3 <= 95) { 28965 row = chNr === 1 ? rowsLowCh1[a2] : rowsLowCh2[a2]; 28966 } else { 28967 row = chNr === 1 ? rowsHighCh1[a2] : rowsHighCh2[a2]; 28968 } 28969 const channel = this.channels[chNr]; 28970 if (!channel) { 28971 return false; 28972 } 28973 channel.setPAC(this.interpretPAC(row, b3)); 28974 this.currentChannel = chNr; 28975 return true; 28976 } 28977 /** 28978 * Interpret the second byte of the pac, and return the information. 28979 * @returns pacData with style parameters 28980 */ 28981 interpretPAC(row, byte) { 28982 let pacIndex; 28983 const pacData = { 28984 color: null, 28985 italics: false, 28986 indent: null, 28987 underline: false, 28988 row 28989 }; 28990 if (byte > 95) { 28991 pacIndex = byte - 96; 28992 } else { 28993 pacIndex = byte - 64; 28994 } 28995 pacData.underline = (pacIndex & 1) === 1; 28996 if (pacIndex <= 13) { 28997 pacData.color = ["white", "green", "blue", "cyan", "red", "yellow", "magenta", "white"][Math.floor(pacIndex / 2)]; 28998 } else if (pacIndex <= 15) { 28999 pacData.italics = true; 29000 pacData.color = "white"; 29001 } else { 29002 pacData.indent = Math.floor((pacIndex - 16) / 2) * 4; 29003 } 29004 return pacData; 29005 } 29006 /** 29007 * Parse characters. 29008 * @returns An array with 1 to 2 codes corresponding to chars, if found. null otherwise. 29009 */ 29010 parseChars(a2, b3) { 29011 let channelNr; 29012 let charCodes = null; 29013 let charCode1 = null; 29014 if (a2 >= 25) { 29015 channelNr = 2; 29016 charCode1 = a2 - 8; 29017 } else { 29018 channelNr = 1; 29019 charCode1 = a2; 29020 } 29021 if (charCode1 >= 17 && charCode1 <= 19) { 29022 let oneCode; 29023 if (charCode1 === 17) { 29024 oneCode = b3 + 80; 29025 } else if (charCode1 === 18) { 29026 oneCode = b3 + 112; 29027 } else { 29028 oneCode = b3 + 144; 29029 } 29030 this.logger.log(2, () => "Special char '" + getCharForByte(oneCode) + "' in channel " + channelNr); 29031 charCodes = [oneCode]; 29032 } else if (a2 >= 32 && a2 <= 127) { 29033 charCodes = b3 === 0 ? [a2] : [a2, b3]; 29034 } 29035 if (charCodes) { 29036 this.logger.log(3, () => "Char codes = " + numArrayToHexArray(charCodes).join(",")); 29037 } 29038 return charCodes; 29039 } 29040 /** 29041 * Parse extended background attributes as well as new foreground color black. 29042 * @returns True if background attributes are found 29043 */ 29044 parseBackgroundAttributes(a2, b3) { 29045 const case1 = (a2 === 16 || a2 === 24) && b3 >= 32 && b3 <= 47; 29046 const case2 = (a2 === 23 || a2 === 31) && b3 >= 45 && b3 <= 47; 29047 if (!(case1 || case2)) { 29048 return false; 29049 } 29050 let index2; 29051 const bkgData = {}; 29052 if (a2 === 16 || a2 === 24) { 29053 index2 = Math.floor((b3 - 32) / 2); 29054 bkgData.background = backgroundColors[index2]; 29055 if (b3 % 2 === 1) { 29056 bkgData.background = bkgData.background + "_semi"; 29057 } 29058 } else if (b3 === 45) { 29059 bkgData.background = "transparent"; 29060 } else { 29061 bkgData.foreground = "black"; 29062 if (b3 === 47) { 29063 bkgData.underline = true; 29064 } 29065 } 29066 const chNr = a2 <= 23 ? 1 : 2; 29067 const channel = this.channels[chNr]; 29068 channel.setBkgData(bkgData); 29069 return true; 29070 } 29071 /** 29072 * Reset state of parser and its channels. 29073 */ 29074 reset() { 29075 for (let i3 = 0; i3 < Object.keys(this.channels).length; i3++) { 29076 const channel = this.channels[i3]; 29077 if (channel) { 29078 channel.reset(); 29079 } 29080 } 29081 setLastCmd(null, null, this.cmdHistory); 29082 } 29083 /** 29084 * Trigger the generation of a cue, and the start of a new one if displayScreens are not empty. 29085 */ 29086 cueSplitAtTime(t2) { 29087 for (let i3 = 0; i3 < this.channels.length; i3++) { 29088 const channel = this.channels[i3]; 29089 if (channel) { 29090 channel.cueSplitAtTime(t2); 29091 } 29092 } 29093 } 29094}; 29095function setLastCmd(a2, b3, cmdHistory) { 29096 cmdHistory.a = a2; 29097 cmdHistory.b = b3; 29098} 29099function hasCmdRepeated(a2, b3, cmdHistory) { 29100 return cmdHistory.a === a2 && cmdHistory.b === b3; 29101} 29102function createCmdHistory() { 29103 return { 29104 a: null, 29105 b: null 29106 }; 29107} 29108var OutputFilter = class { 29109 constructor(timelineController, trackName) { 29110 this.timelineController = void 0; 29111 this.cueRanges = []; 29112 this.trackName = void 0; 29113 this.startTime = null; 29114 this.endTime = null; 29115 this.screen = null; 29116 this.timelineController = timelineController; 29117 this.trackName = trackName; 29118 } 29119 dispatchCue() { 29120 if (this.startTime === null) { 29121 return; 29122 } 29123 this.timelineController.addCues(this.trackName, this.startTime, this.endTime, this.screen, this.cueRanges); 29124 this.startTime = null; 29125 } 29126 newCue(startTime, endTime, screen) { 29127 if (this.startTime === null || this.startTime > startTime) { 29128 this.startTime = startTime; 29129 } 29130 this.endTime = endTime; 29131 this.screen = screen; 29132 this.timelineController.createCaptionsTrack(this.trackName); 29133 } 29134 reset() { 29135 this.cueRanges = []; 29136 this.startTime = null; 29137 } 29138}; 29139var VTTCue2 = function() { 29140 if (optionalSelf != null && optionalSelf.VTTCue) { 29141 return self.VTTCue; 29142 } 29143 const AllowedDirections = ["", "lr", "rl"]; 29144 const AllowedAlignments = ["start", "middle", "end", "left", "right"]; 29145 function isAllowedValue(allowed, value) { 29146 if (typeof value !== "string") { 29147 return false; 29148 } 29149 if (!Array.isArray(allowed)) { 29150 return false; 29151 } 29152 const lcValue = value.toLowerCase(); 29153 if (~allowed.indexOf(lcValue)) { 29154 return lcValue; 29155 } 29156 return false; 29157 } 29158 function findDirectionSetting(value) { 29159 return isAllowedValue(AllowedDirections, value); 29160 }
vendor: 11,574 bytes, lines 29161-29558
29161 function findAlignSetting(value) { 29162 return isAllowedValue(AllowedAlignments, value); 29163 } 29164 function extend(obj, ...rest) { 29165 let i3 = 1; 29166 for (; i3 < arguments.length; i3++) { 29167 const cobj = arguments[i3]; 29168 for (const p3 in cobj) { 29169 obj[p3] = cobj[p3]; 29170 } 29171 } 29172 return obj; 29173 } 29174 function VTTCue3(startTime, endTime, text) { 29175 const cue = this; 29176 const baseObj = { 29177 enumerable: true 29178 }; 29179 cue.hasBeenReset = false; 29180 let _id2 = ""; 29181 let _pauseOnExit = false; 29182 let _startTime2 = startTime; 29183 let _endTime = endTime; 29184 let _text = text; 29185 let _region = null; 29186 let _vertical = ""; 29187 let _snapToLines = true; 29188 let _line = "auto"; 29189 let _lineAlign = "start"; 29190 let _position = 50; 29191 let _positionAlign = "middle"; 29192 let _size = 50; 29193 let _align = "middle"; 29194 Object.defineProperty(cue, "id", extend({}, baseObj, { 29195 get: function() { 29196 return _id2; 29197 }, 29198 set: function(value) { 29199 _id2 = "" + value; 29200 } 29201 })); 29202 Object.defineProperty(cue, "pauseOnExit", extend({}, baseObj, { 29203 get: function() { 29204 return _pauseOnExit; 29205 }, 29206 set: function(value) { 29207 _pauseOnExit = !!value; 29208 } 29209 })); 29210 Object.defineProperty(cue, "startTime", extend({}, baseObj, { 29211 get: function() { 29212 return _startTime2; 29213 }, 29214 set: function(value) { 29215 if (typeof value !== "number") { 29216 throw new TypeError("Start time must be set to a number."); 29217 } 29218 _startTime2 = value; 29219 this.hasBeenReset = true; 29220 } 29221 })); 29222 Object.defineProperty(cue, "endTime", extend({}, baseObj, { 29223 get: function() { 29224 return _endTime; 29225 }, 29226 set: function(value) { 29227 if (typeof value !== "number") { 29228 throw new TypeError("End time must be set to a number."); 29229 } 29230 _endTime = value; 29231 this.hasBeenReset = true; 29232 } 29233 })); 29234 Object.defineProperty(cue, "text", extend({}, baseObj, { 29235 get: function() { 29236 return _text; 29237 }, 29238 set: function(value) { 29239 _text = "" + value; 29240 this.hasBeenReset = true; 29241 } 29242 })); 29243 Object.defineProperty(cue, "region", extend({}, baseObj, { 29244 get: function() { 29245 return _region; 29246 }, 29247 set: function(value) { 29248 _region = value; 29249 this.hasBeenReset = true; 29250 } 29251 })); 29252 Object.defineProperty(cue, "vertical", extend({}, baseObj, { 29253 get: function() { 29254 return _vertical; 29255 }, 29256 set: function(value) { 29257 const setting = findDirectionSetting(value); 29258 if (setting === false) { 29259 throw new SyntaxError("An invalid or illegal string was specified."); 29260 } 29261 _vertical = setting; 29262 this.hasBeenReset = true; 29263 } 29264 })); 29265 Object.defineProperty(cue, "snapToLines", extend({}, baseObj, { 29266 get: function() { 29267 return _snapToLines; 29268 }, 29269 set: function(value) { 29270 _snapToLines = !!value; 29271 this.hasBeenReset = true; 29272 } 29273 })); 29274 Object.defineProperty(cue, "line", extend({}, baseObj, { 29275 get: function() { 29276 return _line; 29277 }, 29278 set: function(value) { 29279 if (typeof value !== "number" && value !== "auto") { 29280 throw new SyntaxError("An invalid number or illegal string was specified."); 29281 } 29282 _line = value; 29283 this.hasBeenReset = true; 29284 } 29285 })); 29286 Object.defineProperty(cue, "lineAlign", extend({}, baseObj, { 29287 get: function() { 29288 return _lineAlign; 29289 }, 29290 set: function(value) { 29291 const setting = findAlignSetting(value); 29292 if (!setting) { 29293 throw new SyntaxError("An invalid or illegal string was specified."); 29294 } 29295 _lineAlign = setting; 29296 this.hasBeenReset = true; 29297 } 29298 })); 29299 Object.defineProperty(cue, "position", extend({}, baseObj, { 29300 get: function() { 29301 return _position; 29302 }, 29303 set: function(value) { 29304 if (value < 0 || value > 100) { 29305 throw new Error("Position must be between 0 and 100."); 29306 } 29307 _position = value; 29308 this.hasBeenReset = true; 29309 } 29310 })); 29311 Object.defineProperty(cue, "positionAlign", extend({}, baseObj, { 29312 get: function() { 29313 return _positionAlign; 29314 }, 29315 set: function(value) { 29316 const setting = findAlignSetting(value); 29317 if (!setting) { 29318 throw new SyntaxError("An invalid or illegal string was specified."); 29319 } 29320 _positionAlign = setting; 29321 this.hasBeenReset = true; 29322 } 29323 })); 29324 Object.defineProperty(cue, "size", extend({}, baseObj, { 29325 get: function() { 29326 return _size; 29327 }, 29328 set: function(value) { 29329 if (value < 0 || value > 100) { 29330 throw new Error("Size must be between 0 and 100."); 29331 } 29332 _size = value; 29333 this.hasBeenReset = true; 29334 } 29335 })); 29336 Object.defineProperty(cue, "align", extend({}, baseObj, { 29337 get: function() { 29338 return _align; 29339 }, 29340 set: function(value) { 29341 const setting = findAlignSetting(value); 29342 if (!setting) { 29343 throw new SyntaxError("An invalid or illegal string was specified."); 29344 } 29345 _align = setting; 29346 this.hasBeenReset = true; 29347 } 29348 })); 29349 cue.displayState = void 0; 29350 } 29351 VTTCue3.prototype.getCueAsHTML = function() { 29352 const WebVTT = self.WebVTT; 29353 return WebVTT.convertCueToDOMTree(self, this.text); 29354 }; 29355 return VTTCue3; 29356}(); 29357var StringDecoder = class { 29358 // eslint-disable-next-line @typescript-eslint/no-unused-vars 29359 decode(data, options2) { 29360 if (!data) { 29361 return ""; 29362 } 29363 if (typeof data !== "string") { 29364 throw new Error("Error - expected string data."); 29365 } 29366 return decodeURIComponent(encodeURIComponent(data)); 29367 } 29368}; 29369function parseTimeStamp(input) { 29370 function computeSeconds(h3, m3, s, f) { 29371 return (h3 | 0) * 3600 + (m3 | 0) * 60 + (s | 0) + parseFloat(f || 0); 29372 } 29373 const m2 = input.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/); 29374 if (!m2) { 29375 return null; 29376 } 29377 if (parseFloat(m2[2]) > 59) { 29378 return computeSeconds(m2[2], m2[3], 0, m2[4]); 29379 } 29380 return computeSeconds(m2[1], m2[2], m2[3], m2[4]); 29381} 29382var Settings = class { 29383 constructor() { 29384 this.values = /* @__PURE__ */ Object.create(null); 29385 } 29386 // Only accept the first assignment to any key. 29387 set(k3, v2) { 29388 if (!this.get(k3) && v2 !== "") { 29389 this.values[k3] = v2; 29390 } 29391 } 29392 // Return the value for a key, or a default value. 29393 // If 'defaultKey' is passed then 'dflt' is assumed to be an object with 29394 // a number of possible default values as properties where 'defaultKey' is 29395 // the key of the property that will be chosen; otherwise it's assumed to be 29396 // a single value. 29397 get(k3, dflt, defaultKey) { 29398 if (defaultKey) { 29399 return this.has(k3) ? this.values[k3] : dflt[defaultKey]; 29400 } 29401 return this.has(k3) ? this.values[k3] : dflt; 29402 } 29403 // Check whether we have a value for a key. 29404 has(k3) { 29405 return k3 in this.values; 29406 } 29407 // Accept a setting if its one of the given alternatives. 29408 alt(k3, v2, a2) { 29409 for (let n2 = 0; n2 < a2.length; ++n2) { 29410 if (v2 === a2[n2]) { 29411 this.set(k3, v2); 29412 break; 29413 } 29414 } 29415 } 29416 // Accept a setting if its a valid (signed) integer. 29417 integer(k3, v2) { 29418 if (/^-?\d+$/.test(v2)) { 29419 this.set(k3, parseInt(v2, 10)); 29420 } 29421 } 29422 // Accept a setting if its a valid percentage. 29423 percent(k3, v2) { 29424 if (/^([\d]{1,3})(\.[\d]*)?%$/.test(v2)) { 29425 const percent = parseFloat(v2); 29426 if (percent >= 0 && percent <= 100) { 29427 this.set(k3, percent); 29428 return true; 29429 } 29430 } 29431 return false; 29432 } 29433}; 29434function parseOptions(input, callback, keyValueDelim, groupDelim) { 29435 const groups = groupDelim ? input.split(groupDelim) : [input]; 29436 for (const i3 in groups) { 29437 if (typeof groups[i3] !== "string") { 29438 continue; 29439 } 29440 const kv = groups[i3].split(keyValueDelim); 29441 if (kv.length !== 2) { 29442 continue; 29443 } 29444 const k3 = kv[0]; 29445 const v2 = kv[1]; 29446 callback(k3, v2); 29447 } 29448} 29449var defaults = new VTTCue2(0, 0, ""); 29450var center = defaults.align === "middle" ? "middle" : "center"; 29451function parseCue(input, cue, regionList) { 29452 const oInput = input; 29453 function consumeTimeStamp() { 29454 const ts = parseTimeStamp(input); 29455 if (ts === null) { 29456 throw new Error("Malformed timestamp: " + oInput); 29457 } 29458 input = input.replace(/^[^\sa-zA-Z-]+/, ""); 29459 return ts; 29460 } 29461 function consumeCueSettings(input2, cue2) { 29462 const settings = new Settings(); 29463 parseOptions(input2, function(k3, v2) { 29464 let vals; 29465 switch (k3) { 29466 case "region": 29467 for (let i3 = regionList.length - 1; i3 >= 0; i3--) { 29468 if (regionList[i3].id === v2) { 29469 settings.set(k3, regionList[i3].region); 29470 break; 29471 } 29472 } 29473 break; 29474 case "vertical": 29475 settings.alt(k3, v2, ["rl", "lr"]); 29476 break; 29477 case "line": 29478 vals = v2.split(","); 29479 settings.integer(k3, vals[0]); 29480 if (settings.percent(k3, vals[0])) { 29481 settings.set("snapToLines", false); 29482 } 29483 settings.alt(k3, vals[0], ["auto"]); 29484 if (vals.length === 2) { 29485 settings.alt("lineAlign", vals[1], ["start", center, "end"]); 29486 } 29487 break; 29488 case "position": 29489 vals = v2.split(","); 29490 settings.percent(k3, vals[0]); 29491 if (vals.length === 2) { 29492 settings.alt("positionAlign", vals[1], ["start", center, "end", "line-left", "line-right", "auto"]); 29493 } 29494 break; 29495 case "size": 29496 settings.percent(k3, v2); 29497 break; 29498 case "align": 29499 settings.alt(k3, v2, ["start", center, "end", "left", "right"]); 29500 break; 29501 } 29502 }, /:/, /\s/); 29503 cue2.region = settings.get("region", null); 29504 cue2.vertical = settings.get("vertical", ""); 29505 let line2 = settings.get("line", "auto"); 29506 if (line2 === "auto" && defaults.line === -1) { 29507 line2 = -1; 29508 } 29509 cue2.line = line2; 29510 cue2.lineAlign = settings.get("lineAlign", "start"); 29511 cue2.snapToLines = settings.get("snapToLines", true); 29512 cue2.size = settings.get("size", 100); 29513 cue2.align = settings.get("align", center); 29514 let position2 = settings.get("position", "auto"); 29515 if (position2 === "auto" && defaults.position === 50) { 29516 position2 = cue2.align === "start" || cue2.align === "left" ? 0 : cue2.align === "end" || cue2.align === "right" ? 100 : 50; 29517 } 29518 cue2.position = position2; 29519 } 29520 function skipWhitespace() { 29521 input = input.replace(/^\s+/, ""); 29522 } 29523 skipWhitespace(); 29524 cue.startTime = consumeTimeStamp(); 29525 skipWhitespace(); 29526 if (input.slice(0, 3) !== "-->") { 29527 throw new Error("Malformed time stamp (time stamps must be separated by '-->'): " + oInput); 29528 } 29529 input = input.slice(3); 29530 skipWhitespace(); 29531 cue.endTime = consumeTimeStamp(); 29532 skipWhitespace(); 29533 consumeCueSettings(input, cue); 29534} 29535function fixLineBreaks(input) { 29536 return input.replace(/<br(?: \/)?>/gi, "\n"); 29537} 29538var VTTParser = class { 29539 constructor() { 29540 this.state = "INITIAL"; 29541 this.buffer = ""; 29542 this.decoder = new StringDecoder(); 29543 this.regionList = []; 29544 this.cue = null; 29545 this.oncue = void 0; 29546 this.onparsingerror = void 0; 29547 this.onflush = void 0; 29548 } 29549 parse(data) { 29550 const _this = this; 29551 if (data) { 29552 _this.buffer += _this.decoder.decode(data, { 29553 stream: true 29554 }); 29555 } 29556 function collectNextLine() { 29557 let buffer = _this.buffer; 29558 let pos = 0;
vendor: 7,404 bytes, lines 29559-29796
29559 buffer = fixLineBreaks(buffer); 29560 while (pos < buffer.length && buffer[pos] !== "\r" && buffer[pos] !== "\n") { 29561 ++pos; 29562 } 29563 const line2 = buffer.slice(0, pos); 29564 if (buffer[pos] === "\r") { 29565 ++pos; 29566 } 29567 if (buffer[pos] === "\n") { 29568 ++pos; 29569 } 29570 _this.buffer = buffer.slice(pos); 29571 return line2; 29572 } 29573 function parseHeader2(input) { 29574 parseOptions(input, function(k3, v2) { 29575 }, /:/); 29576 } 29577 try { 29578 let line2 = ""; 29579 if (_this.state === "INITIAL") { 29580 if (!/\r\n|\n/.test(_this.buffer)) { 29581 return this; 29582 } 29583 line2 = collectNextLine(); 29584 const m2 = line2.match(/^()?WEBVTT([ \t].*)?$/); 29585 if (!(m2 != null && m2[0])) { 29586 throw new Error("Malformed WebVTT signature."); 29587 } 29588 _this.state = "HEADER"; 29589 } 29590 let alreadyCollectedLine = false; 29591 while (_this.buffer) { 29592 if (!/\r\n|\n/.test(_this.buffer)) { 29593 return this; 29594 } 29595 if (!alreadyCollectedLine) { 29596 line2 = collectNextLine(); 29597 } else { 29598 alreadyCollectedLine = false; 29599 } 29600 switch (_this.state) { 29601 case "HEADER": 29602 if (/:/.test(line2)) { 29603 parseHeader2(line2); 29604 } else if (!line2) { 29605 _this.state = "ID"; 29606 } 29607 continue; 29608 case "NOTE": 29609 if (!line2) { 29610 _this.state = "ID"; 29611 } 29612 continue; 29613 case "ID": 29614 if (/^NOTE($|[ \t])/.test(line2)) { 29615 _this.state = "NOTE"; 29616 break; 29617 } 29618 if (!line2) { 29619 continue; 29620 } 29621 _this.cue = new VTTCue2(0, 0, ""); 29622 _this.state = "CUE"; 29623 if (line2.indexOf("-->") === -1) { 29624 _this.cue.id = line2; 29625 continue; 29626 } 29627 case "CUE": 29628 if (!_this.cue) { 29629 _this.state = "BADCUE"; 29630 continue; 29631 } 29632 try { 29633 parseCue(line2, _this.cue, _this.regionList); 29634 } catch (e) { 29635 _this.cue = null; 29636 _this.state = "BADCUE"; 29637 continue; 29638 } 29639 _this.state = "CUETEXT"; 29640 continue; 29641 case "CUETEXT": 29642 { 29643 const hasSubstring = line2.indexOf("-->") !== -1; 29644 if (!line2 || hasSubstring && (alreadyCollectedLine = true)) { 29645 if (_this.oncue && _this.cue) { 29646 _this.oncue(_this.cue); 29647 } 29648 _this.cue = null; 29649 _this.state = "ID"; 29650 continue; 29651 } 29652 if (_this.cue === null) { 29653 continue; 29654 } 29655 if (_this.cue.text) { 29656 _this.cue.text += "\n"; 29657 } 29658 _this.cue.text += line2; 29659 } 29660 continue; 29661 case "BADCUE": 29662 if (!line2) { 29663 _this.state = "ID"; 29664 } 29665 } 29666 } 29667 } catch (e) { 29668 if (_this.state === "CUETEXT" && _this.cue && _this.oncue) { 29669 _this.oncue(_this.cue); 29670 } 29671 _this.cue = null; 29672 _this.state = _this.state === "INITIAL" ? "BADWEBVTT" : "BADCUE"; 29673 } 29674 return this; 29675 } 29676 flush() { 29677 const _this = this; 29678 try { 29679 if (_this.cue || _this.state === "HEADER") { 29680 _this.buffer += "\n\n"; 29681 _this.parse(); 29682 } 29683 if (_this.state === "INITIAL" || _this.state === "BADWEBVTT") { 29684 throw new Error("Malformed WebVTT signature."); 29685 } 29686 } catch (e) { 29687 if (_this.onparsingerror) { 29688 _this.onparsingerror(e); 29689 } 29690 } 29691 if (_this.onflush) { 29692 _this.onflush(); 29693 } 29694 return this; 29695 } 29696}; 29697var LINEBREAKS = /\r\n|\n\r|\n|\r/g; 29698var startsWith = function startsWith2(inputString, searchString, position2 = 0) { 29699 return inputString.slice(position2, position2 + searchString.length) === searchString; 29700}; 29701var cueString2millis = function cueString2millis2(timeString) { 29702 let ts = parseInt(timeString.slice(-3)); 29703 const secs = parseInt(timeString.slice(-6, -4)); 29704 const mins = parseInt(timeString.slice(-9, -7)); 29705 const hours = timeString.length > 9 ? parseInt(timeString.substring(0, timeString.indexOf(":"))) : 0; 29706 if (!isFiniteNumber(ts) || !isFiniteNumber(secs) || !isFiniteNumber(mins) || !isFiniteNumber(hours)) { 29707 throw Error(`Malformed X-TIMESTAMP-MAP: Local:${timeString}`); 29708 } 29709 ts += 1e3 * secs; 29710 ts += 60 * 1e3 * mins; 29711 ts += 60 * 60 * 1e3 * hours; 29712 return ts; 29713}; 29714var hash2 = function hash3(text) { 29715 let _hash = 5381; 29716 let i3 = text.length; 29717 while (i3) { 29718 _hash = _hash * 33 ^ text.charCodeAt(--i3); 29719 } 29720 return (_hash >>> 0).toString(); 29721}; 29722function generateCueId(startTime, endTime, text) { 29723 return hash2(startTime.toString()) + hash2(endTime.toString()) + hash2(text); 29724} 29725var calculateOffset = function calculateOffset2(vttCCs, cc, presentationTime) { 29726 let currCC = vttCCs[cc]; 29727 let prevCC = vttCCs[currCC.prevCC]; 29728 if (!prevCC || !prevCC.new && currCC.new) { 29729 vttCCs.ccOffset = vttCCs.presentationOffset = currCC.start; 29730 currCC.new = false; 29731 return; 29732 } 29733 while ((_prevCC = prevCC) != null && _prevCC.new) { 29734 var _prevCC; 29735 vttCCs.ccOffset += currCC.start - prevCC.start; 29736 currCC.new = false; 29737 currCC = prevCC; 29738 prevCC = vttCCs[currCC.prevCC]; 29739 } 29740 vttCCs.presentationOffset = presentationTime; 29741}; 29742function parseWebVTT(vttByteArray, initPTS, vttCCs, cc, timeOffset, callBack, errorCallBack) { 29743 const parser = new VTTParser(); 29744 const vttLines = utf8ArrayToStr(new Uint8Array(vttByteArray)).trim().replace(LINEBREAKS, "\n").split("\n"); 29745 const cues = []; 29746 const init90kHz = initPTS ? toMpegTsClockFromTimescale(initPTS.baseTime, initPTS.timescale) : 0; 29747 let cueTime = "00:00.000"; 29748 let timestampMapMPEGTS = 0; 29749 let timestampMapLOCAL = 0; 29750 let parsingError; 29751 let inHeader = true; 29752 parser.oncue = function(cue) { 29753 const currCC = vttCCs[cc]; 29754 let cueOffset = vttCCs.ccOffset; 29755 const webVttMpegTsMapOffset = (timestampMapMPEGTS - init90kHz) / 9e4; 29756 if (currCC != null && currCC.new) { 29757 if (timestampMapLOCAL !== void 0) { 29758 cueOffset = vttCCs.ccOffset = currCC.start; 29759 } else { 29760 calculateOffset(vttCCs, cc, webVttMpegTsMapOffset); 29761 } 29762 } 29763 if (webVttMpegTsMapOffset) { 29764 if (!initPTS) { 29765 parsingError = new Error("Missing initPTS for VTT MPEGTS"); 29766 return; 29767 } 29768 cueOffset = webVttMpegTsMapOffset - vttCCs.presentationOffset; 29769 } 29770 const duration = cue.endTime - cue.startTime; 29771 const startTime = normalizePts((cue.startTime + cueOffset - timestampMapLOCAL) * 9e4, timeOffset * 9e4) / 9e4; 29772 cue.startTime = Math.max(startTime, 0); 29773 cue.endTime = Math.max(startTime + duration, 0); 29774 const text = cue.text.trim(); 29775 cue.text = decodeURIComponent(encodeURIComponent(text)); 29776 if (!cue.id) { 29777 cue.id = generateCueId(cue.startTime, cue.endTime, text); 29778 } 29779 if (cue.endTime > 0) { 29780 cues.push(cue); 29781 } 29782 }; 29783 parser.onparsingerror = function(error) { 29784 parsingError = error; 29785 }; 29786 parser.onflush = function() { 29787 if (parsingError) { 29788 errorCallBack(parsingError); 29789 return; 29790 } 29791 callBack(cues); 29792 }; 29793 vttLines.forEach((line2) => { 29794 if (inHeader) { 29795 if (startsWith(line2, "X-TIMESTAMP-MAP=")) { 29796 inHeader = false;
vendor: 7,249 bytes, lines 29797-30018
29797 line2.slice(16).split(",").forEach((timestamp) => { 29798 if (startsWith(timestamp, "LOCAL:")) { 29799 cueTime = timestamp.slice(6); 29800 } else if (startsWith(timestamp, "MPEGTS:")) { 29801 timestampMapMPEGTS = parseInt(timestamp.slice(7)); 29802 } 29803 }); 29804 try { 29805 timestampMapLOCAL = cueString2millis(cueTime) / 1e3; 29806 } catch (error) { 29807 parsingError = error; 29808 } 29809 return; 29810 } else if (line2 === "") { 29811 inHeader = false; 29812 } 29813 } 29814 parser.parse(line2 + "\n"); 29815 }); 29816 parser.flush(); 29817} 29818var IMSC1_CODEC = "stpp.ttml.im1t"; 29819var HMSF_REGEX = /^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/; 29820var TIME_UNIT_REGEX = /^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/; 29821var textAlignToLineAlign = { 29822 left: "start", 29823 center: "center", 29824 right: "end", 29825 start: "start", 29826 end: "end" 29827}; 29828function parseIMSC1(payload, initPTS, callBack, errorCallBack) { 29829 const results = findBox(new Uint8Array(payload), ["mdat"]); 29830 if (results.length === 0) { 29831 errorCallBack(new Error("Could not parse IMSC1 mdat")); 29832 return; 29833 } 29834 const ttmlList = results.map((mdat) => utf8ArrayToStr(mdat)); 29835 const syncTime = toTimescaleFromScale(initPTS.baseTime, 1, initPTS.timescale); 29836 try { 29837 ttmlList.forEach((ttml) => callBack(parseTTML(ttml, syncTime))); 29838 } catch (error) { 29839 errorCallBack(error); 29840 } 29841} 29842function parseTTML(ttml, syncTime) { 29843 const parser = new DOMParser(); 29844 const xmlDoc = parser.parseFromString(ttml, "text/xml"); 29845 const tt4 = xmlDoc.getElementsByTagName("tt")[0]; 29846 if (!tt4) { 29847 throw new Error("Invalid ttml"); 29848 } 29849 const defaultRateInfo = { 29850 frameRate: 30, 29851 subFrameRate: 1, 29852 frameRateMultiplier: 0, 29853 tickRate: 0 29854 }; 29855 const rateInfo = Object.keys(defaultRateInfo).reduce((result, key) => { 29856 result[key] = tt4.getAttribute(`ttp:${key}`) || defaultRateInfo[key]; 29857 return result; 29858 }, {}); 29859 const trim2 = tt4.getAttribute("xml:space") !== "preserve"; 29860 const styleElements = collectionToDictionary(getElementCollection(tt4, "styling", "style")); 29861 const regionElements = collectionToDictionary(getElementCollection(tt4, "layout", "region")); 29862 const cueElements = getElementCollection(tt4, "body", "[begin]"); 29863 return [].map.call(cueElements, (cueElement) => { 29864 const cueText = getTextContent(cueElement, trim2); 29865 if (!cueText || !cueElement.hasAttribute("begin")) { 29866 return null; 29867 } 29868 const startTime = parseTtmlTime(cueElement.getAttribute("begin"), rateInfo); 29869 const duration = parseTtmlTime(cueElement.getAttribute("dur"), rateInfo); 29870 let endTime = parseTtmlTime(cueElement.getAttribute("end"), rateInfo); 29871 if (startTime === null) { 29872 throw timestampParsingError(cueElement); 29873 } 29874 if (endTime === null) { 29875 if (duration === null) { 29876 throw timestampParsingError(cueElement); 29877 } 29878 endTime = startTime + duration; 29879 } 29880 const cue = new VTTCue2(startTime - syncTime, endTime - syncTime, cueText); 29881 cue.id = generateCueId(cue.startTime, cue.endTime, cue.text); 29882 const region = regionElements[cueElement.getAttribute("region")]; 29883 const style = styleElements[cueElement.getAttribute("style")]; 29884 const styles = getTtmlStyles(region, style, styleElements); 29885 const { 29886 textAlign 29887 } = styles; 29888 if (textAlign) { 29889 const lineAlign = textAlignToLineAlign[textAlign]; 29890 if (lineAlign) { 29891 cue.lineAlign = lineAlign; 29892 } 29893 cue.align = textAlign; 29894 } 29895 _extends2(cue, styles); 29896 return cue; 29897 }).filter((cue) => cue !== null); 29898} 29899function getElementCollection(fromElement, parentName, childName) { 29900 const parent = fromElement.getElementsByTagName(parentName)[0]; 29901 if (parent) { 29902 return [].slice.call(parent.querySelectorAll(childName)); 29903 } 29904 return []; 29905} 29906function collectionToDictionary(elementsWithId) { 29907 return elementsWithId.reduce((dict, element) => { 29908 const id = element.getAttribute("xml:id"); 29909 if (id) { 29910 dict[id] = element; 29911 } 29912 return dict; 29913 }, {}); 29914} 29915function getTextContent(element, trim2) { 29916 return [].slice.call(element.childNodes).reduce((str, node2, i3) => { 29917 var _node$childNodes; 29918 if (node2.nodeName === "br" && i3) { 29919 return str + "\n"; 29920 } 29921 if ((_node$childNodes = node2.childNodes) != null && _node$childNodes.length) { 29922 return getTextContent(node2, trim2); 29923 } else if (trim2) { 29924 return str + node2.textContent.trim().replace(/\s+/g, " "); 29925 } 29926 return str + node2.textContent; 29927 }, ""); 29928} 29929function getTtmlStyles(region, style, styleElements) { 29930 const ttsNs = "http://www.w3.org/ns/ttml#styling"; 29931 let regionStyle = null; 29932 const styleAttributes = [ 29933 "displayAlign", 29934 "textAlign", 29935 "color", 29936 "backgroundColor", 29937 "fontSize", 29938 "fontFamily" 29939 // 'fontWeight', 29940 // 'lineHeight', 29941 // 'wrapOption', 29942 // 'fontStyle', 29943 // 'direction', 29944 // 'writingMode' 29945 ]; 29946 const regionStyleName = region != null && region.hasAttribute("style") ? region.getAttribute("style") : null; 29947 if (regionStyleName && styleElements.hasOwnProperty(regionStyleName)) { 29948 regionStyle = styleElements[regionStyleName]; 29949 } 29950 return styleAttributes.reduce((styles, name) => { 29951 const value = getAttributeNS(style, ttsNs, name) || getAttributeNS(region, ttsNs, name) || getAttributeNS(regionStyle, ttsNs, name); 29952 if (value) { 29953 styles[name] = value; 29954 } 29955 return styles; 29956 }, {}); 29957} 29958function getAttributeNS(element, ns, name) { 29959 if (!element) { 29960 return null; 29961 } 29962 return element.hasAttributeNS(ns, name) ? element.getAttributeNS(ns, name) : null; 29963} 29964function timestampParsingError(node2) { 29965 return new Error(`Could not parse ttml timestamp ${node2}`); 29966} 29967function parseTtmlTime(timeAttributeValue, rateInfo) { 29968 if (!timeAttributeValue) { 29969 return null; 29970 } 29971 let seconds = parseTimeStamp(timeAttributeValue); 29972 if (seconds === null) { 29973 if (HMSF_REGEX.test(timeAttributeValue)) { 29974 seconds = parseHoursMinutesSecondsFrames(timeAttributeValue, rateInfo); 29975 } else if (TIME_UNIT_REGEX.test(timeAttributeValue)) { 29976 seconds = parseTimeUnits(timeAttributeValue, rateInfo); 29977 } 29978 } 29979 return seconds; 29980} 29981function parseHoursMinutesSecondsFrames(timeAttributeValue, rateInfo) { 29982 const m2 = HMSF_REGEX.exec(timeAttributeValue); 29983 const frames = (m2[4] | 0) + (m2[5] | 0) / rateInfo.subFrameRate; 29984 return (m2[1] | 0) * 3600 + (m2[2] | 0) * 60 + (m2[3] | 0) + frames / rateInfo.frameRate; 29985} 29986function parseTimeUnits(timeAttributeValue, rateInfo) { 29987 const m2 = TIME_UNIT_REGEX.exec(timeAttributeValue); 29988 const value = Number(m2[1]); 29989 const unit = m2[2]; 29990 switch (unit) { 29991 case "h": 29992 return value * 3600; 29993 case "m": 29994 return value * 60; 29995 case "ms": 29996 return value * 1e3; 29997 case "f": 29998 return value / rateInfo.frameRate; 29999 case "t": 30000 return value / rateInfo.tickRate; 30001 } 30002 return value; 30003} 30004var TimelineController = class { 30005 constructor(hls) { 30006 this.hls = void 0; 30007 this.media = null; 30008 this.config = void 0; 30009 this.enabled = true; 30010 this.Cues = void 0; 30011 this.textTracks = []; 30012 this.tracks = []; 30013 this.initPTS = []; 30014 this.unparsedVttFrags = []; 30015 this.captionsTracks = {}; 30016 this.nonNativeCaptionsTracks = {}; 30017 this.cea608Parser1 = void 0; 30018 this.cea608Parser2 = void 0;
vendor: 4,490 bytes, lines 30019-30134
30019 this.lastCc = -1; 30020 this.lastSn = -1; 30021 this.lastPartIndex = -1; 30022 this.prevCC = -1; 30023 this.vttCCs = newVTTCCs(); 30024 this.captionsProperties = void 0; 30025 this.hls = hls; 30026 this.config = hls.config; 30027 this.Cues = hls.config.cueHandler; 30028 this.captionsProperties = { 30029 textTrack1: { 30030 label: this.config.captionsTextTrack1Label, 30031 languageCode: this.config.captionsTextTrack1LanguageCode 30032 }, 30033 textTrack2: { 30034 label: this.config.captionsTextTrack2Label, 30035 languageCode: this.config.captionsTextTrack2LanguageCode 30036 }, 30037 textTrack3: { 30038 label: this.config.captionsTextTrack3Label, 30039 languageCode: this.config.captionsTextTrack3LanguageCode 30040 }, 30041 textTrack4: { 30042 label: this.config.captionsTextTrack4Label, 30043 languageCode: this.config.captionsTextTrack4LanguageCode 30044 } 30045 }; 30046 hls.on(Events.MEDIA_ATTACHING, this.onMediaAttaching, this); 30047 hls.on(Events.MEDIA_DETACHING, this.onMediaDetaching, this); 30048 hls.on(Events.MANIFEST_LOADING, this.onManifestLoading, this); 30049 hls.on(Events.MANIFEST_LOADED, this.onManifestLoaded, this); 30050 hls.on(Events.SUBTITLE_TRACKS_UPDATED, this.onSubtitleTracksUpdated, this); 30051 hls.on(Events.FRAG_LOADING, this.onFragLoading, this); 30052 hls.on(Events.FRAG_LOADED, this.onFragLoaded, this); 30053 hls.on(Events.FRAG_PARSING_USERDATA, this.onFragParsingUserdata, this); 30054 hls.on(Events.FRAG_DECRYPTED, this.onFragDecrypted, this); 30055 hls.on(Events.INIT_PTS_FOUND, this.onInitPtsFound, this); 30056 hls.on(Events.SUBTITLE_TRACKS_CLEARED, this.onSubtitleTracksCleared, this); 30057 hls.on(Events.BUFFER_FLUSHING, this.onBufferFlushing, this); 30058 } 30059 destroy() { 30060 const { 30061 hls 30062 } = this; 30063 hls.off(Events.MEDIA_ATTACHING, this.onMediaAttaching, this); 30064 hls.off(Events.MEDIA_DETACHING, this.onMediaDetaching, this); 30065 hls.off(Events.MANIFEST_LOADING, this.onManifestLoading, this); 30066 hls.off(Events.MANIFEST_LOADED, this.onManifestLoaded, this); 30067 hls.off(Events.SUBTITLE_TRACKS_UPDATED, this.onSubtitleTracksUpdated, this); 30068 hls.off(Events.FRAG_LOADING, this.onFragLoading, this); 30069 hls.off(Events.FRAG_LOADED, this.onFragLoaded, this); 30070 hls.off(Events.FRAG_PARSING_USERDATA, this.onFragParsingUserdata, this); 30071 hls.off(Events.FRAG_DECRYPTED, this.onFragDecrypted, this); 30072 hls.off(Events.INIT_PTS_FOUND, this.onInitPtsFound, this); 30073 hls.off(Events.SUBTITLE_TRACKS_CLEARED, this.onSubtitleTracksCleared, this); 30074 hls.off(Events.BUFFER_FLUSHING, this.onBufferFlushing, this); 30075 this.hls = this.config = null; 30076 this.cea608Parser1 = this.cea608Parser2 = void 0; 30077 } 30078 initCea608Parsers() { 30079 if (this.config.enableCEA708Captions && (!this.cea608Parser1 || !this.cea608Parser2)) { 30080 const channel1 = new OutputFilter(this, "textTrack1"); 30081 const channel2 = new OutputFilter(this, "textTrack2"); 30082 const channel3 = new OutputFilter(this, "textTrack3"); 30083 const channel4 = new OutputFilter(this, "textTrack4"); 30084 this.cea608Parser1 = new Cea608Parser(1, channel1, channel2); 30085 this.cea608Parser2 = new Cea608Parser(3, channel3, channel4); 30086 } 30087 } 30088 addCues(trackName, startTime, endTime, screen, cueRanges) { 30089 let merged = false; 30090 for (let i3 = cueRanges.length; i3--; ) { 30091 const cueRange = cueRanges[i3]; 30092 const overlap = intersection(cueRange[0], cueRange[1], startTime, endTime); 30093 if (overlap >= 0) { 30094 cueRange[0] = Math.min(cueRange[0], startTime); 30095 cueRange[1] = Math.max(cueRange[1], endTime); 30096 merged = true; 30097 if (overlap / (endTime - startTime) > 0.5) { 30098 return; 30099 } 30100 } 30101 } 30102 if (!merged) { 30103 cueRanges.push([startTime, endTime]); 30104 } 30105 if (this.config.renderTextTracksNatively) { 30106 const track = this.captionsTracks[trackName]; 30107 this.Cues.newCue(track, startTime, endTime, screen); 30108 } else { 30109 const cues = this.Cues.newCue(null, startTime, endTime, screen); 30110 this.hls.trigger(Events.CUES_PARSED, { 30111 type: "captions", 30112 cues, 30113 track: trackName 30114 }); 30115 } 30116 } 30117 // Triggered when an initial PTS is found; used for synchronisation of WebVTT. 30118 onInitPtsFound(event, { 30119 frag, 30120 id, 30121 initPTS, 30122 timescale 30123 }) { 30124 const { 30125 unparsedVttFrags 30126 } = this; 30127 if (id === "main") { 30128 this.initPTS[frag.cc] = { 30129 baseTime: initPTS, 30130 timescale 30131 }; 30132 } 30133 if (unparsedVttFrags.length) { 30134 this.unparsedVttFrags = [];
vendor: 7,258 bytes, lines 30135-30370
30135 unparsedVttFrags.forEach((frag2) => { 30136 this.onFragLoaded(Events.FRAG_LOADED, frag2); 30137 }); 30138 } 30139 } 30140 getExistingTrack(label, language) { 30141 const { 30142 media 30143 } = this; 30144 if (media) { 30145 for (let i3 = 0; i3 < media.textTracks.length; i3++) { 30146 const textTrack = media.textTracks[i3]; 30147 if (canReuseVttTextTrack(textTrack, { 30148 name: label, 30149 lang: language, 30150 attrs: {} 30151 })) { 30152 return textTrack; 30153 } 30154 } 30155 } 30156 return null; 30157 } 30158 createCaptionsTrack(trackName) { 30159 if (this.config.renderTextTracksNatively) { 30160 this.createNativeTrack(trackName); 30161 } else { 30162 this.createNonNativeTrack(trackName); 30163 } 30164 } 30165 createNativeTrack(trackName) { 30166 if (this.captionsTracks[trackName]) { 30167 return; 30168 } 30169 const { 30170 captionsProperties, 30171 captionsTracks, 30172 media 30173 } = this; 30174 const { 30175 label, 30176 languageCode 30177 } = captionsProperties[trackName]; 30178 const existingTrack = this.getExistingTrack(label, languageCode); 30179 if (!existingTrack) { 30180 const textTrack = this.createTextTrack("captions", label, languageCode); 30181 if (textTrack) { 30182 textTrack[trackName] = true; 30183 captionsTracks[trackName] = textTrack; 30184 } 30185 } else { 30186 captionsTracks[trackName] = existingTrack; 30187 clearCurrentCues(captionsTracks[trackName]); 30188 sendAddTrackEvent(captionsTracks[trackName], media); 30189 } 30190 } 30191 createNonNativeTrack(trackName) { 30192 if (this.nonNativeCaptionsTracks[trackName]) { 30193 return; 30194 } 30195 const trackProperties = this.captionsProperties[trackName]; 30196 if (!trackProperties) { 30197 return; 30198 } 30199 const label = trackProperties.label; 30200 const track = { 30201 _id: trackName, 30202 label, 30203 kind: "captions", 30204 default: trackProperties.media ? !!trackProperties.media.default : false, 30205 closedCaptions: trackProperties.media 30206 }; 30207 this.nonNativeCaptionsTracks[trackName] = track; 30208 this.hls.trigger(Events.NON_NATIVE_TEXT_TRACKS_FOUND, { 30209 tracks: [track] 30210 }); 30211 } 30212 createTextTrack(kind, label, lang) { 30213 const media = this.media; 30214 if (!media) { 30215 return; 30216 } 30217 return media.addTextTrack(kind, label, lang); 30218 } 30219 onMediaAttaching(event, data) { 30220 this.media = data.media; 30221 this._cleanTracks(); 30222 } 30223 onMediaDetaching() { 30224 const { 30225 captionsTracks 30226 } = this; 30227 Object.keys(captionsTracks).forEach((trackName) => { 30228 clearCurrentCues(captionsTracks[trackName]); 30229 delete captionsTracks[trackName]; 30230 }); 30231 this.nonNativeCaptionsTracks = {}; 30232 } 30233 onManifestLoading() { 30234 this.lastCc = -1; 30235 this.lastSn = -1; 30236 this.lastPartIndex = -1; 30237 this.prevCC = -1; 30238 this.vttCCs = newVTTCCs(); 30239 this._cleanTracks(); 30240 this.tracks = []; 30241 this.captionsTracks = {}; 30242 this.nonNativeCaptionsTracks = {}; 30243 this.textTracks = []; 30244 this.unparsedVttFrags = []; 30245 this.initPTS = []; 30246 if (this.cea608Parser1 && this.cea608Parser2) { 30247 this.cea608Parser1.reset(); 30248 this.cea608Parser2.reset(); 30249 } 30250 } 30251 _cleanTracks() { 30252 const { 30253 media 30254 } = this; 30255 if (!media) { 30256 return; 30257 } 30258 const textTracks = media.textTracks; 30259 if (textTracks) { 30260 for (let i3 = 0; i3 < textTracks.length; i3++) { 30261 clearCurrentCues(textTracks[i3]); 30262 } 30263 } 30264 } 30265 onSubtitleTracksUpdated(event, data) { 30266 const tracks = data.subtitleTracks || []; 30267 const hasIMSC1 = tracks.some((track) => track.textCodec === IMSC1_CODEC); 30268 if (this.config.enableWebVTT || hasIMSC1 && this.config.enableIMSC1) { 30269 const listIsIdentical = subtitleOptionsIdentical(this.tracks, tracks); 30270 if (listIsIdentical) { 30271 this.tracks = tracks; 30272 return; 30273 } 30274 this.textTracks = []; 30275 this.tracks = tracks; 30276 if (this.config.renderTextTracksNatively) { 30277 const media = this.media; 30278 const inUseTracks = media ? filterSubtitleTracks(media.textTracks) : null; 30279 this.tracks.forEach((track, index2) => { 30280 let textTrack; 30281 if (inUseTracks) { 30282 let inUseTrack = null; 30283 for (let i3 = 0; i3 < inUseTracks.length; i3++) { 30284 if (inUseTracks[i3] && canReuseVttTextTrack(inUseTracks[i3], track)) { 30285 inUseTrack = inUseTracks[i3]; 30286 inUseTracks[i3] = null; 30287 break; 30288 } 30289 } 30290 if (inUseTrack) { 30291 textTrack = inUseTrack; 30292 } 30293 } 30294 if (textTrack) { 30295 clearCurrentCues(textTrack); 30296 } else { 30297 const textTrackKind = captionsOrSubtitlesFromCharacteristics(track); 30298 textTrack = this.createTextTrack(textTrackKind, track.name, track.lang); 30299 if (textTrack) { 30300 textTrack.mode = "disabled"; 30301 } 30302 } 30303 if (textTrack) { 30304 this.textTracks.push(textTrack); 30305 } 30306 }); 30307 if (inUseTracks != null && inUseTracks.length) { 30308 const unusedTextTracks = inUseTracks.filter((t2) => t2 !== null).map((t2) => t2.label); 30309 if (unusedTextTracks.length) { 30310 logger.warn(`Media element contains unused subtitle tracks: ${unusedTextTracks.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`); 30311 } 30312 } 30313 } else if (this.tracks.length) { 30314 const tracksList = this.tracks.map((track) => { 30315 return { 30316 label: track.name, 30317 kind: track.type.toLowerCase(), 30318 default: track.default, 30319 subtitleTrack: track 30320 }; 30321 }); 30322 this.hls.trigger(Events.NON_NATIVE_TEXT_TRACKS_FOUND, { 30323 tracks: tracksList 30324 }); 30325 } 30326 } 30327 } 30328 onManifestLoaded(event, data) { 30329 if (this.config.enableCEA708Captions && data.captions) { 30330 data.captions.forEach((captionsTrack) => { 30331 const instreamIdMatch = /(?:CC|SERVICE)([1-4])/.exec(captionsTrack.instreamId); 30332 if (!instreamIdMatch) { 30333 return; 30334 } 30335 const trackName = `textTrack${instreamIdMatch[1]}`; 30336 const trackProperties = this.captionsProperties[trackName]; 30337 if (!trackProperties) { 30338 return; 30339 } 30340 trackProperties.label = captionsTrack.name; 30341 if (captionsTrack.lang) { 30342 trackProperties.languageCode = captionsTrack.lang; 30343 } 30344 trackProperties.media = captionsTrack; 30345 }); 30346 } 30347 } 30348 closedCaptionsForLevel(frag) { 30349 const level = this.hls.levels[frag.level]; 30350 return level == null ? void 0 : level.attrs["CLOSED-CAPTIONS"]; 30351 } 30352 onFragLoading(event, data) { 30353 if (this.enabled && data.frag.type === PlaylistLevelType.MAIN) { 30354 var _data$part$index, _data$part; 30355 const { 30356 cea608Parser1, 30357 cea608Parser2, 30358 lastSn 30359 } = this; 30360 const { 30361 cc, 30362 sn 30363 } = data.frag; 30364 const partIndex = (_data$part$index = (_data$part = data.part) == null ? void 0 : _data$part.index) != null ? _data$part$index : -1; 30365 if (cea608Parser1 && cea608Parser2) { 30366 if (sn !== lastSn + 1 || sn === lastSn && partIndex !== this.lastPartIndex + 1 || cc !== this.lastCc) { 30367 cea608Parser1.reset(); 30368 cea608Parser2.reset(); 30369 } 30370 }
vendor: 12,696 bytes, lines 30371-30789
30371 this.lastCc = cc; 30372 this.lastSn = sn; 30373 this.lastPartIndex = partIndex; 30374 } 30375 } 30376 onFragLoaded(event, data) { 30377 const { 30378 frag, 30379 payload 30380 } = data; 30381 if (frag.type === PlaylistLevelType.SUBTITLE) { 30382 if (payload.byteLength) { 30383 const decryptData = frag.decryptdata; 30384 const decrypted = "stats" in data; 30385 if (decryptData == null || !decryptData.encrypted || decrypted) { 30386 const trackPlaylistMedia = this.tracks[frag.level]; 30387 const vttCCs = this.vttCCs; 30388 if (!vttCCs[frag.cc]) { 30389 vttCCs[frag.cc] = { 30390 start: frag.start, 30391 prevCC: this.prevCC, 30392 new: true 30393 }; 30394 this.prevCC = frag.cc; 30395 } 30396 if (trackPlaylistMedia && trackPlaylistMedia.textCodec === IMSC1_CODEC) { 30397 this._parseIMSC1(frag, payload); 30398 } else { 30399 this._parseVTTs(data); 30400 } 30401 } 30402 } else { 30403 this.hls.trigger(Events.SUBTITLE_FRAG_PROCESSED, { 30404 success: false, 30405 frag, 30406 error: new Error("Empty subtitle payload") 30407 }); 30408 } 30409 } 30410 } 30411 _parseIMSC1(frag, payload) { 30412 const hls = this.hls; 30413 parseIMSC1(payload, this.initPTS[frag.cc], (cues) => { 30414 this._appendCues(cues, frag.level); 30415 hls.trigger(Events.SUBTITLE_FRAG_PROCESSED, { 30416 success: true, 30417 frag 30418 }); 30419 }, (error) => { 30420 logger.log(`Failed to parse IMSC1: ${error}`); 30421 hls.trigger(Events.SUBTITLE_FRAG_PROCESSED, { 30422 success: false, 30423 frag, 30424 error 30425 }); 30426 }); 30427 } 30428 _parseVTTs(data) { 30429 var _frag$initSegment; 30430 const { 30431 frag, 30432 payload 30433 } = data; 30434 const { 30435 initPTS, 30436 unparsedVttFrags 30437 } = this; 30438 const maxAvCC = initPTS.length - 1; 30439 if (!initPTS[frag.cc] && maxAvCC === -1) { 30440 unparsedVttFrags.push(data); 30441 return; 30442 } 30443 const hls = this.hls; 30444 const payloadWebVTT = (_frag$initSegment = frag.initSegment) != null && _frag$initSegment.data ? appendUint8Array(frag.initSegment.data, new Uint8Array(payload)) : payload; 30445 parseWebVTT(payloadWebVTT, this.initPTS[frag.cc], this.vttCCs, frag.cc, frag.start, (cues) => { 30446 this._appendCues(cues, frag.level); 30447 hls.trigger(Events.SUBTITLE_FRAG_PROCESSED, { 30448 success: true, 30449 frag 30450 }); 30451 }, (error) => { 30452 const missingInitPTS = error.message === "Missing initPTS for VTT MPEGTS"; 30453 if (missingInitPTS) { 30454 unparsedVttFrags.push(data); 30455 } else { 30456 this._fallbackToIMSC1(frag, payload); 30457 } 30458 logger.log(`Failed to parse VTT cue: ${error}`); 30459 if (missingInitPTS && maxAvCC > frag.cc) { 30460 return; 30461 } 30462 hls.trigger(Events.SUBTITLE_FRAG_PROCESSED, { 30463 success: false, 30464 frag, 30465 error 30466 }); 30467 }); 30468 } 30469 _fallbackToIMSC1(frag, payload) { 30470 const trackPlaylistMedia = this.tracks[frag.level]; 30471 if (!trackPlaylistMedia.textCodec) { 30472 parseIMSC1(payload, this.initPTS[frag.cc], () => { 30473 trackPlaylistMedia.textCodec = IMSC1_CODEC; 30474 this._parseIMSC1(frag, payload); 30475 }, () => { 30476 trackPlaylistMedia.textCodec = "wvtt"; 30477 }); 30478 } 30479 } 30480 _appendCues(cues, fragLevel) { 30481 const hls = this.hls; 30482 if (this.config.renderTextTracksNatively) { 30483 const textTrack = this.textTracks[fragLevel]; 30484 if (!textTrack || textTrack.mode === "disabled") { 30485 return; 30486 } 30487 cues.forEach((cue) => addCueToTrack(textTrack, cue)); 30488 } else { 30489 const currentTrack = this.tracks[fragLevel]; 30490 if (!currentTrack) { 30491 return; 30492 } 30493 const track = currentTrack.default ? "default" : "subtitles" + fragLevel; 30494 hls.trigger(Events.CUES_PARSED, { 30495 type: "subtitles", 30496 cues, 30497 track 30498 }); 30499 } 30500 } 30501 onFragDecrypted(event, data) { 30502 const { 30503 frag 30504 } = data; 30505 if (frag.type === PlaylistLevelType.SUBTITLE) { 30506 this.onFragLoaded(Events.FRAG_LOADED, data); 30507 } 30508 } 30509 onSubtitleTracksCleared() { 30510 this.tracks = []; 30511 this.captionsTracks = {}; 30512 } 30513 onFragParsingUserdata(event, data) { 30514 this.initCea608Parsers(); 30515 const { 30516 cea608Parser1, 30517 cea608Parser2 30518 } = this; 30519 if (!this.enabled || !cea608Parser1 || !cea608Parser2) { 30520 return; 30521 } 30522 const { 30523 frag, 30524 samples 30525 } = data; 30526 if (frag.type === PlaylistLevelType.MAIN && this.closedCaptionsForLevel(frag) === "NONE") { 30527 return; 30528 } 30529 for (let i3 = 0; i3 < samples.length; i3++) { 30530 const ccBytes = samples[i3].bytes; 30531 if (ccBytes) { 30532 const ccdatas = this.extractCea608Data(ccBytes); 30533 cea608Parser1.addData(samples[i3].pts, ccdatas[0]); 30534 cea608Parser2.addData(samples[i3].pts, ccdatas[1]); 30535 } 30536 } 30537 } 30538 onBufferFlushing(event, { 30539 startOffset, 30540 endOffset, 30541 endOffsetSubtitles, 30542 type 30543 }) { 30544 const { 30545 media 30546 } = this; 30547 if (!media || media.currentTime < endOffset) { 30548 return; 30549 } 30550 if (!type || type === "video") { 30551 const { 30552 captionsTracks 30553 } = this; 30554 Object.keys(captionsTracks).forEach((trackName) => removeCuesInRange(captionsTracks[trackName], startOffset, endOffset)); 30555 } 30556 if (this.config.renderTextTracksNatively) { 30557 if (startOffset === 0 && endOffsetSubtitles !== void 0) { 30558 const { 30559 textTracks 30560 } = this; 30561 Object.keys(textTracks).forEach((trackName) => removeCuesInRange(textTracks[trackName], startOffset, endOffsetSubtitles)); 30562 } 30563 } 30564 } 30565 extractCea608Data(byteArray) { 30566 const actualCCBytes = [[], []]; 30567 const count = byteArray[0] & 31; 30568 let position2 = 2; 30569 for (let j3 = 0; j3 < count; j3++) { 30570 const tmpByte = byteArray[position2++]; 30571 const ccbyte1 = 127 & byteArray[position2++]; 30572 const ccbyte2 = 127 & byteArray[position2++]; 30573 if (ccbyte1 === 0 && ccbyte2 === 0) { 30574 continue; 30575 } 30576 const ccValid = (4 & tmpByte) !== 0; 30577 if (ccValid) { 30578 const ccType = 3 & tmpByte; 30579 if (0 === ccType || 1 === ccType) { 30580 actualCCBytes[ccType].push(ccbyte1); 30581 actualCCBytes[ccType].push(ccbyte2); 30582 } 30583 } 30584 } 30585 return actualCCBytes; 30586 } 30587}; 30588function captionsOrSubtitlesFromCharacteristics(track) { 30589 if (track.characteristics) { 30590 if (/transcribes-spoken-dialog/gi.test(track.characteristics) && /describes-music-and-sound/gi.test(track.characteristics)) { 30591 return "captions"; 30592 } 30593 } 30594 return "subtitles"; 30595} 30596function canReuseVttTextTrack(inUseTrack, manifestTrack) { 30597 return !!inUseTrack && inUseTrack.kind === captionsOrSubtitlesFromCharacteristics(manifestTrack) && subtitleTrackMatchesTextTrack(manifestTrack, inUseTrack); 30598} 30599function intersection(x1, x2, y1, y22) { 30600 return Math.min(x2, y22) - Math.max(x1, y1); 30601} 30602function newVTTCCs() { 30603 return { 30604 ccOffset: 0, 30605 presentationOffset: 0, 30606 0: { 30607 start: 0, 30608 prevCC: -1, 30609 new: true 30610 } 30611 }; 30612} 30613var CapLevelController = class _CapLevelController { 30614 constructor(hls) { 30615 this.hls = void 0; 30616 this.autoLevelCapping = void 0; 30617 this.firstLevel = void 0; 30618 this.media = void 0; 30619 this.restrictedLevels = void 0; 30620 this.timer = void 0; 30621 this.clientRect = void 0; 30622 this.streamController = void 0; 30623 this.hls = hls; 30624 this.autoLevelCapping = Number.POSITIVE_INFINITY; 30625 this.firstLevel = -1; 30626 this.media = null; 30627 this.restrictedLevels = []; 30628 this.timer = void 0; 30629 this.clientRect = null; 30630 this.registerListeners(); 30631 } 30632 setStreamController(streamController) { 30633 this.streamController = streamController; 30634 } 30635 destroy() { 30636 if (this.hls) { 30637 this.unregisterListener(); 30638 } 30639 if (this.timer) { 30640 this.stopCapping(); 30641 } 30642 this.media = null; 30643 this.clientRect = null; 30644 this.hls = this.streamController = null; 30645 } 30646 registerListeners() { 30647 const { 30648 hls 30649 } = this; 30650 hls.on(Events.FPS_DROP_LEVEL_CAPPING, this.onFpsDropLevelCapping, this); 30651 hls.on(Events.MEDIA_ATTACHING, this.onMediaAttaching, this); 30652 hls.on(Events.MANIFEST_PARSED, this.onManifestParsed, this); 30653 hls.on(Events.LEVELS_UPDATED, this.onLevelsUpdated, this); 30654 hls.on(Events.BUFFER_CODECS, this.onBufferCodecs, this); 30655 hls.on(Events.MEDIA_DETACHING, this.onMediaDetaching, this); 30656 } 30657 unregisterListener() { 30658 const { 30659 hls 30660 } = this; 30661 hls.off(Events.FPS_DROP_LEVEL_CAPPING, this.onFpsDropLevelCapping, this); 30662 hls.off(Events.MEDIA_ATTACHING, this.onMediaAttaching, this); 30663 hls.off(Events.MANIFEST_PARSED, this.onManifestParsed, this); 30664 hls.off(Events.LEVELS_UPDATED, this.onLevelsUpdated, this); 30665 hls.off(Events.BUFFER_CODECS, this.onBufferCodecs, this); 30666 hls.off(Events.MEDIA_DETACHING, this.onMediaDetaching, this); 30667 } 30668 onFpsDropLevelCapping(event, data) { 30669 const level = this.hls.levels[data.droppedLevel]; 30670 if (this.isLevelAllowed(level)) { 30671 this.restrictedLevels.push({ 30672 bitrate: level.bitrate, 30673 height: level.height, 30674 width: level.width 30675 }); 30676 } 30677 } 30678 onMediaAttaching(event, data) { 30679 this.media = data.media instanceof HTMLVideoElement ? data.media : null; 30680 this.clientRect = null; 30681 if (this.timer && this.hls.levels.length) { 30682 this.detectPlayerSize(); 30683 } 30684 } 30685 onManifestParsed(event, data) { 30686 const hls = this.hls; 30687 this.restrictedLevels = []; 30688 this.firstLevel = data.firstLevel; 30689 if (hls.config.capLevelToPlayerSize && data.video) { 30690 this.startCapping(); 30691 } 30692 } 30693 onLevelsUpdated(event, data) { 30694 if (this.timer && isFiniteNumber(this.autoLevelCapping)) { 30695 this.detectPlayerSize(); 30696 } 30697 } 30698 // Only activate capping when playing a video stream; otherwise, multi-bitrate audio-only streams will be restricted 30699 // to the first level 30700 onBufferCodecs(event, data) { 30701 const hls = this.hls; 30702 if (hls.config.capLevelToPlayerSize && data.video) { 30703 this.startCapping(); 30704 } 30705 } 30706 onMediaDetaching() { 30707 this.stopCapping(); 30708 } 30709 detectPlayerSize() { 30710 if (this.media) { 30711 if (this.mediaHeight <= 0 || this.mediaWidth <= 0) { 30712 this.clientRect = null; 30713 return; 30714 } 30715 const levels = this.hls.levels; 30716 if (levels.length) { 30717 const hls = this.hls; 30718 const maxLevel = this.getMaxLevel(levels.length - 1); 30719 if (maxLevel !== this.autoLevelCapping) { 30720 logger.log(`Setting autoLevelCapping to ${maxLevel}: ${levels[maxLevel].height}p@${levels[maxLevel].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`); 30721 } 30722 hls.autoLevelCapping = maxLevel; 30723 if (hls.autoLevelCapping > this.autoLevelCapping && this.streamController) { 30724 this.streamController.nextLevelSwitch(); 30725 } 30726 this.autoLevelCapping = hls.autoLevelCapping; 30727 } 30728 } 30729 } 30730 /* 30731 * returns level should be the one with the dimensions equal or greater than the media (player) dimensions (so the video will be downscaled) 30732 */ 30733 getMaxLevel(capLevelIndex) { 30734 const levels = this.hls.levels; 30735 if (!levels.length) { 30736 return -1; 30737 } 30738 const validLevels = levels.filter((level, index2) => this.isLevelAllowed(level) && index2 <= capLevelIndex); 30739 this.clientRect = null; 30740 return _CapLevelController.getMaxLevelByMediaSize(validLevels, this.mediaWidth, this.mediaHeight); 30741 } 30742 startCapping() { 30743 if (this.timer) { 30744 return; 30745 } 30746 this.autoLevelCapping = Number.POSITIVE_INFINITY; 30747 self.clearInterval(this.timer); 30748 this.timer = self.setInterval(this.detectPlayerSize.bind(this), 1e3); 30749 this.detectPlayerSize(); 30750 } 30751 stopCapping() { 30752 this.restrictedLevels = []; 30753 this.firstLevel = -1; 30754 this.autoLevelCapping = Number.POSITIVE_INFINITY; 30755 if (this.timer) { 30756 self.clearInterval(this.timer); 30757 this.timer = void 0; 30758 } 30759 } 30760 getDimensions() { 30761 if (this.clientRect) { 30762 return this.clientRect; 30763 } 30764 const media = this.media; 30765 const boundsRect = { 30766 width: 0, 30767 height: 0 30768 }; 30769 if (media) { 30770 const clientRect = media.getBoundingClientRect(); 30771 boundsRect.width = clientRect.width; 30772 boundsRect.height = clientRect.height; 30773 if (!boundsRect.width && !boundsRect.height) { 30774 boundsRect.width = clientRect.right - clientRect.left || media.width || 0; 30775 boundsRect.height = clientRect.bottom - clientRect.top || media.height || 0; 30776 } 30777 } 30778 this.clientRect = boundsRect; 30779 return boundsRect; 30780 } 30781 get mediaWidth() { 30782 return this.getDimensions().width * this.contentScaleFactor; 30783 } 30784 get mediaHeight() { 30785 return this.getDimensions().height * this.contentScaleFactor; 30786 } 30787 get contentScaleFactor() { 30788 let pixelRatio = 1; 30789 if (!this.hls.config.ignoreDevicePixelRatio) {
vendor: 5,528 bytes, lines 30790-30944
30790 try { 30791 pixelRatio = self.devicePixelRatio; 30792 } catch (e) { 30793 } 30794 } 30795 return pixelRatio; 30796 } 30797 isLevelAllowed(level) { 30798 const restrictedLevels = this.restrictedLevels; 30799 return !restrictedLevels.some((restrictedLevel) => { 30800 return level.bitrate === restrictedLevel.bitrate && level.width === restrictedLevel.width && level.height === restrictedLevel.height; 30801 }); 30802 } 30803 static getMaxLevelByMediaSize(levels, width, height) { 30804 if (!(levels != null && levels.length)) { 30805 return -1; 30806 } 30807 const atGreatestBandwidth = (curLevel, nextLevel) => { 30808 if (!nextLevel) { 30809 return true; 30810 } 30811 return curLevel.width !== nextLevel.width || curLevel.height !== nextLevel.height; 30812 }; 30813 let maxLevelIndex = levels.length - 1; 30814 const squareSize = Math.max(width, height); 30815 for (let i3 = 0; i3 < levels.length; i3 += 1) { 30816 const level = levels[i3]; 30817 if ((level.width >= squareSize || level.height >= squareSize) && atGreatestBandwidth(level, levels[i3 + 1])) { 30818 maxLevelIndex = i3; 30819 break; 30820 } 30821 } 30822 return maxLevelIndex; 30823 } 30824}; 30825var FPSController = class { 30826 constructor(hls) { 30827 this.hls = void 0; 30828 this.isVideoPlaybackQualityAvailable = false; 30829 this.timer = void 0; 30830 this.media = null; 30831 this.lastTime = void 0; 30832 this.lastDroppedFrames = 0; 30833 this.lastDecodedFrames = 0; 30834 this.streamController = void 0; 30835 this.hls = hls; 30836 this.registerListeners(); 30837 } 30838 setStreamController(streamController) { 30839 this.streamController = streamController; 30840 } 30841 registerListeners() { 30842 this.hls.on(Events.MEDIA_ATTACHING, this.onMediaAttaching, this); 30843 } 30844 unregisterListeners() { 30845 this.hls.off(Events.MEDIA_ATTACHING, this.onMediaAttaching, this); 30846 } 30847 destroy() { 30848 if (this.timer) { 30849 clearInterval(this.timer); 30850 } 30851 this.unregisterListeners(); 30852 this.isVideoPlaybackQualityAvailable = false; 30853 this.media = null; 30854 } 30855 onMediaAttaching(event, data) { 30856 const config = this.hls.config; 30857 if (config.capLevelOnFPSDrop) { 30858 const media = data.media instanceof self.HTMLVideoElement ? data.media : null; 30859 this.media = media; 30860 if (media && typeof media.getVideoPlaybackQuality === "function") { 30861 this.isVideoPlaybackQualityAvailable = true; 30862 } 30863 self.clearInterval(this.timer); 30864 this.timer = self.setInterval(this.checkFPSInterval.bind(this), config.fpsDroppedMonitoringPeriod); 30865 } 30866 } 30867 checkFPS(video, decodedFrames, droppedFrames) { 30868 const currentTime = performance.now(); 30869 if (decodedFrames) { 30870 if (this.lastTime) { 30871 const currentPeriod = currentTime - this.lastTime; 30872 const currentDropped = droppedFrames - this.lastDroppedFrames; 30873 const currentDecoded = decodedFrames - this.lastDecodedFrames; 30874 const droppedFPS = 1e3 * currentDropped / currentPeriod; 30875 const hls = this.hls; 30876 hls.trigger(Events.FPS_DROP, { 30877 currentDropped, 30878 currentDecoded, 30879 totalDroppedFrames: droppedFrames 30880 }); 30881 if (droppedFPS > 0) { 30882 if (currentDropped > hls.config.fpsDroppedMonitoringThreshold * currentDecoded) { 30883 let currentLevel = hls.currentLevel; 30884 logger.warn("drop FPS ratio greater than max allowed value for currentLevel: " + currentLevel); 30885 if (currentLevel > 0 && (hls.autoLevelCapping === -1 || hls.autoLevelCapping >= currentLevel)) { 30886 currentLevel = currentLevel - 1; 30887 hls.trigger(Events.FPS_DROP_LEVEL_CAPPING, { 30888 level: currentLevel, 30889 droppedLevel: hls.currentLevel 30890 }); 30891 hls.autoLevelCapping = currentLevel; 30892 this.streamController.nextLevelSwitch(); 30893 } 30894 } 30895 } 30896 } 30897 this.lastTime = currentTime; 30898 this.lastDroppedFrames = droppedFrames; 30899 this.lastDecodedFrames = decodedFrames; 30900 } 30901 } 30902 checkFPSInterval() { 30903 const video = this.media; 30904 if (video) { 30905 if (this.isVideoPlaybackQualityAvailable) { 30906 const videoPlaybackQuality = video.getVideoPlaybackQuality(); 30907 this.checkFPS(video, videoPlaybackQuality.totalVideoFrames, videoPlaybackQuality.droppedVideoFrames); 30908 } else { 30909 this.checkFPS(video, video.webkitDecodedFrameCount, video.webkitDroppedFrameCount); 30910 } 30911 } 30912 } 30913}; 30914var LOGGER_PREFIX = "[eme]"; 30915var EMEController = class _EMEController { 30916 constructor(hls) { 30917 this.hls = void 0; 30918 this.config = void 0; 30919 this.media = null; 30920 this.keyFormatPromise = null; 30921 this.keySystemAccessPromises = {}; 30922 this._requestLicenseFailureCount = 0; 30923 this.mediaKeySessions = []; 30924 this.keyIdToKeySessionPromise = {}; 30925 this.setMediaKeysQueue = _EMEController.CDMCleanupPromise ? [_EMEController.CDMCleanupPromise] : []; 30926 this.debug = logger.debug.bind(logger, LOGGER_PREFIX); 30927 this.log = logger.log.bind(logger, LOGGER_PREFIX); 30928 this.warn = logger.warn.bind(logger, LOGGER_PREFIX); 30929 this.error = logger.error.bind(logger, LOGGER_PREFIX); 30930 this.onMediaEncrypted = (event) => { 30931 const { 30932 initDataType, 30933 initData 30934 } = event; 30935 const logMessage = `"${event.type}" event: init data type: "${initDataType}"`; 30936 this.debug(logMessage); 30937 if (initData === null) { 30938 return; 30939 } 30940 if (!this.keyFormatPromise) { 30941 let keySystems = Object.keys(this.keySystemAccessPromises); 30942 if (!keySystems.length) { 30943 keySystems = getKeySystemsForConfig(this.config); 30944 }
30945 const keyFormats = keySystems.map(keySystemDomainToKeySystemFormat).filter((k3) => !!k3); 30946 this.keyFormatPromise = this.getKeyFormatPromise(keyFormats); 30947 } 30948 this.keyFormatPromise.then((keySystemFormat) => { 30949 const keySystem = keySystemFormatToKeySystemDomain(keySystemFormat); 30950 let keyId; 30951 let keySystemDomain; 30952 if (initDataType === "sinf") { 30953 if (keySystem !== KeySystems.FAIRPLAY) { 30954 this.warn(`Ignoring unexpected "${event.type}" event with init data type: "${initDataType}" for selected key-system ${keySystem}`); 30955 return; 30956 } 30957 const json = bin2str(new Uint8Array(initData)); 30958 try { 30959 const sinf = base64Decode(JSON.parse(json).sinf); 30960 const tenc = parseSinf(sinf); 30961 if (!tenc) { 30962 throw new Error(`'schm' box missing or not cbcs/cenc with schi > tenc`); 30963 } 30964 keyId = tenc.subarray(8, 24); 30965 keySystemDomain = KeySystems.FAIRPLAY; 30966 } catch (error) { 30967 this.warn(`${logMessage} Failed to parse sinf: ${error}`); 30968 return; 30969 } 30970 } else { 30971 if (keySystem !== KeySystems.WIDEVINE && keySystem !== KeySystems.PLAYREADY) { 30972 this.warn(`Ignoring unexpected "${event.type}" event with init data type: "${initDataType}" for selected key-system ${keySystem}`); 30973 return; 30974 } 30975 const psshResults = parseMultiPssh(initData); 30976 const psshInfos = psshResults.filter((pssh) => !!pssh.systemId && keySystemIdToKeySystemDomain(pssh.systemId) === keySystem); 30977 if (psshInfos.length > 1) { 30978 this.warn(`${logMessage} Using first of ${psshInfos.length} pssh found for selected key-system ${keySystem}`); 30979 } 30980 const psshInfo = psshInfos[0]; 30981 if (!psshInfo) { 30982 if (psshResults.length === 0 || psshResults.some((pssh) => !pssh.systemId)) { 30983 this.warn(`${logMessage} contains incomplete or invalid pssh data`); 30984 } else { 30985 this.log(`ignoring ${logMessage} for ${psshResults.map((pssh) => keySystemIdToKeySystemDomain(pssh.systemId)).join(",")} pssh data in favor of playlist keys`); 30986 } 30987 return; 30988 } 30989 keySystemDomain = keySystemIdToKeySystemDomain(psshInfo.systemId); 30990 if (psshInfo.version === 0 && psshInfo.data) { 30991 if (keySystemDomain === KeySystems.WIDEVINE) { 30992 const offset = psshInfo.data.length - 22; 30993 keyId = psshInfo.data.subarray(offset, offset + 16); 30994 } else if (keySystemDomain === KeySystems.PLAYREADY) { 30995 keyId = parsePlayReadyWRM(psshInfo.data); 30996 } 30997 } 30998 } 30999 if (!keySystemDomain || !keyId) { 31000 this.log(`Unable to handle ${logMessage} with key-system ${keySystem}`); 31001 return; 31002 } 31003 const keyIdHex = Hex.hexDump(keyId); 31004 const { 31005 keyIdToKeySessionPromise, 31006 mediaKeySessions 31007 } = this; 31008 let keySessionContextPromise = keyIdToKeySessionPromise[keyIdHex]; 31009 for (let i3 = 0; i3 < mediaKeySessions.length; i3++) { 31010 const keyContext = mediaKeySessions[i3]; 31011 const decryptdata = keyContext.decryptdata; 31012 if (!decryptdata.keyId) { 31013 continue; 31014 } 31015 const oldKeyIdHex = Hex.hexDump(decryptdata.keyId); 31016 if (keyIdHex === oldKeyIdHex || decryptdata.uri.replace(/-/g, "").indexOf(keyIdHex) !== -1) { 31017 keySessionContextPromise = keyIdToKeySessionPromise[oldKeyIdHex]; 31018 if (decryptdata.pssh) { 31019 break; 31020 } 31021 delete keyIdToKeySessionPromise[oldKeyIdHex]; 31022 decryptdata.pssh = new Uint8Array(initData); 31023 decryptdata.keyId = keyId; 31024 keySessionContextPromise = keyIdToKeySessionPromise[keyIdHex] = keySessionContextPromise.then(() => { 31025 return this.generateRequestWithPreferredKeySession(keyContext, initDataType, initData, "encrypted-event-key-match"); 31026 }); 31027 keySessionContextPromise.catch((error) => this.handleError(error)); 31028 break; 31029 } 31030 } 31031 if (!keySessionContextPromise) { 31032 if (keySystemDomain !== keySystem) { 31033 this.log(`Ignoring "${logMessage}" with ${keySystemDomain} init data for selected key-system ${keySystem}`); 31034 return; 31035 } 31036 keySessionContextPromise = keyIdToKeySessionPromise[keyIdHex] = this.getKeySystemSelectionPromise([keySystemDomain]).then(({ 31037 keySystem: keySystem2, 31038 mediaKeys 31039 }) => { 31040 var _keySystemToKeySystem; 31041 this.throwIfDestroyed(); 31042 const decryptdata = new LevelKey("ISO-23001-7", keyIdHex, (_keySystemToKeySystem = keySystemDomainToKeySystemFormat(keySystem2)) != null ? _keySystemToKeySystem : ""); 31043 decryptdata.pssh = new Uint8Array(initData); 31044 decryptdata.keyId = keyId; 31045 return this.attemptSetMediaKeys(keySystem2, mediaKeys).then(() => { 31046 this.throwIfDestroyed();
vendor: 4,560 bytes, lines 31047-31164
31047 const keySessionContext = this.createMediaKeySessionContext({ 31048 decryptdata, 31049 keySystem: keySystem2, 31050 mediaKeys 31051 }); 31052 return this.generateRequestWithPreferredKeySession(keySessionContext, initDataType, initData, "encrypted-event-no-match"); 31053 }); 31054 }); 31055 keySessionContextPromise.catch((error) => this.handleError(error)); 31056 } 31057 }); 31058 }; 31059 this.onWaitingForKey = (event) => { 31060 this.log(`"${event.type}" event`); 31061 }; 31062 this.hls = hls; 31063 this.config = hls.config; 31064 this.registerListeners(); 31065 } 31066 destroy() { 31067 this.unregisterListeners(); 31068 this.onMediaDetached(); 31069 const config = this.config; 31070 config.requestMediaKeySystemAccessFunc = null; 31071 config.licenseXhrSetup = config.licenseResponseCallback = void 0; 31072 config.drmSystems = config.drmSystemOptions = {}; 31073 this.hls = this.config = this.keyIdToKeySessionPromise = null; 31074 this.onMediaEncrypted = this.onWaitingForKey = null; 31075 } 31076 registerListeners() { 31077 this.hls.on(Events.MEDIA_ATTACHED, this.onMediaAttached, this); 31078 this.hls.on(Events.MEDIA_DETACHED, this.onMediaDetached, this); 31079 this.hls.on(Events.MANIFEST_LOADING, this.onManifestLoading, this); 31080 this.hls.on(Events.MANIFEST_LOADED, this.onManifestLoaded, this); 31081 } 31082 unregisterListeners() { 31083 this.hls.off(Events.MEDIA_ATTACHED, this.onMediaAttached, this); 31084 this.hls.off(Events.MEDIA_DETACHED, this.onMediaDetached, this); 31085 this.hls.off(Events.MANIFEST_LOADING, this.onManifestLoading, this); 31086 this.hls.off(Events.MANIFEST_LOADED, this.onManifestLoaded, this); 31087 } 31088 getLicenseServerUrl(keySystem) { 31089 const { 31090 drmSystems, 31091 widevineLicenseUrl 31092 } = this.config; 31093 const keySystemConfiguration = drmSystems[keySystem]; 31094 if (keySystemConfiguration) { 31095 return keySystemConfiguration.licenseUrl; 31096 } 31097 if (keySystem === KeySystems.WIDEVINE && widevineLicenseUrl) { 31098 return widevineLicenseUrl; 31099 } 31100 } 31101 getLicenseServerUrlOrThrow(keySystem) { 31102 const url = this.getLicenseServerUrl(keySystem); 31103 if (url === void 0) { 31104 throw new Error(`no license server URL configured for key-system "${keySystem}"`); 31105 } 31106 return url; 31107 } 31108 getServerCertificateUrl(keySystem) { 31109 const { 31110 drmSystems 31111 } = this.config; 31112 const keySystemConfiguration = drmSystems[keySystem]; 31113 if (keySystemConfiguration) { 31114 return keySystemConfiguration.serverCertificateUrl; 31115 } else { 31116 this.log(`No Server Certificate in config.drmSystems["${keySystem}"]`); 31117 } 31118 } 31119 attemptKeySystemAccess(keySystemsToAttempt) { 31120 const levels = this.hls.levels; 31121 const uniqueCodec = (value, i3, a2) => !!value && a2.indexOf(value) === i3; 31122 const audioCodecs = levels.map((level) => level.audioCodec).filter(uniqueCodec); 31123 const videoCodecs = levels.map((level) => level.videoCodec).filter(uniqueCodec); 31124 if (audioCodecs.length + videoCodecs.length === 0) { 31125 videoCodecs.push("avc1.42e01e"); 31126 } 31127 return new Promise((resolve, reject) => { 31128 const attempt = (keySystems) => { 31129 const keySystem = keySystems.shift(); 31130 this.getMediaKeysPromise(keySystem, audioCodecs, videoCodecs).then((mediaKeys) => resolve({ 31131 keySystem, 31132 mediaKeys 31133 })).catch((error) => { 31134 if (keySystems.length) { 31135 attempt(keySystems); 31136 } else if (error instanceof EMEKeyError) { 31137 reject(error); 31138 } else { 31139 reject(new EMEKeyError({ 31140 type: ErrorTypes.KEY_SYSTEM_ERROR, 31141 details: ErrorDetails.KEY_SYSTEM_NO_ACCESS, 31142 error, 31143 fatal: true 31144 }, error.message)); 31145 } 31146 }); 31147 }; 31148 attempt(keySystemsToAttempt); 31149 }); 31150 } 31151 requestMediaKeySystemAccess(keySystem, supportedConfigurations) { 31152 const { 31153 requestMediaKeySystemAccessFunc 31154 } = this.config; 31155 if (!(typeof requestMediaKeySystemAccessFunc === "function")) { 31156 let errMessage = `Configured requestMediaKeySystemAccess is not a function ${requestMediaKeySystemAccessFunc}`; 31157 if (requestMediaKeySystemAccess === null && self.location.protocol === "http:") { 31158 errMessage = `navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`; 31159 } 31160 return Promise.reject(new Error(errMessage)); 31161 } 31162 return requestMediaKeySystemAccessFunc(keySystem, supportedConfigurations); 31163 } 31164 getMediaKeysPromise(keySystem, audioCodecs, videoCodecs) {
31165 const mediaKeySystemConfigs = getSupportedMediaKeySystemConfigurations(keySystem, audioCodecs, videoCodecs, this.config.drmSystemOptions); 31166 const keySystemAccessPromises = this.keySystemAccessPromises[keySystem]; 31167 let keySystemAccess = keySystemAccessPromises == null ? void 0 : keySystemAccessPromises.keySystemAccess; 31168 if (!keySystemAccess) { 31169 this.log(`Requesting encrypted media "${keySystem}" key-system access with config: ${JSON.stringify(mediaKeySystemConfigs)}`); 31170 keySystemAccess = this.requestMediaKeySystemAccess(keySystem, mediaKeySystemConfigs); 31171 const _keySystemAccessPromises = this.keySystemAccessPromises[keySystem] = { 31172 keySystemAccess 31173 }; 31174 keySystemAccess.catch((error) => { 31175 this.log(`Failed to obtain access to key-system "${keySystem}": ${error}`); 31176 }); 31177 return keySystemAccess.then((mediaKeySystemAccess) => { 31178 this.log(`Access for key-system "${mediaKeySystemAccess.keySystem}" obtained`); 31179 const certificateRequest = this.fetchServerCertificate(keySystem); 31180 this.log(`Create media-keys for "${keySystem}"`); 31181 _keySystemAccessPromises.mediaKeys = mediaKeySystemAccess.createMediaKeys().then((mediaKeys) => { 31182 this.log(`Media-keys created for "${keySystem}"`); 31183 return certificateRequest.then((certificate) => { 31184 if (certificate) { 31185 return this.setMediaKeysServerCertificate(mediaKeys, keySystem, certificate); 31186 } 31187 return mediaKeys; 31188 }); 31189 }); 31190 _keySystemAccessPromises.mediaKeys.catch((error) => { 31191 this.error(`Failed to create media-keys for "${keySystem}"}: ${error}`); 31192 }); 31193 return _keySystemAccessPromises.mediaKeys; 31194 }); 31195 } 31196 return keySystemAccess.then(() => keySystemAccessPromises.mediaKeys); 31197 } 31198 createMediaKeySessionContext({ 31199 decryptdata, 31200 keySystem, 31201 mediaKeys 31202 }) { 31203 this.log(`Creating key-system session "${keySystem}" keyId: ${Hex.hexDump(decryptdata.keyId || [])}`); 31204 const mediaKeysSession = mediaKeys.createSession(); 31205 const mediaKeySessionContext = { 31206 decryptdata, 31207 keySystem, 31208 mediaKeys, 31209 mediaKeysSession, 31210 keyStatus: "status-pending" 31211 }; 31212 this.mediaKeySessions.push(mediaKeySessionContext); 31213 return mediaKeySessionContext; 31214 } 31215 renewKeySession(mediaKeySessionContext) { 31216 const decryptdata = mediaKeySessionContext.decryptdata; 31217 if (decryptdata.pssh) { 31218 const keySessionContext = this.createMediaKeySessionContext(mediaKeySessionContext); 31219 const keyId = this.getKeyIdString(decryptdata); 31220 const scheme = "cenc"; 31221 this.keyIdToKeySessionPromise[keyId] = this.generateRequestWithPreferredKeySession(keySessionContext, scheme, decryptdata.pssh, "expired"); 31222 } else { 31223 this.warn(`Could not renew expired session. Missing pssh initData.`); 31224 } 31225 this.removeSession(mediaKeySessionContext); 31226 } 31227 getKeyIdString(decryptdata) { 31228 if (!decryptdata) { 31229 throw new Error("Could not read keyId of undefined decryptdata"); 31230 } 31231 if (decryptdata.keyId === null) { 31232 throw new Error("keyId is null"); 31233 } 31234 return Hex.hexDump(decryptdata.keyId); 31235 } 31236 updateKeySession(mediaKeySessionContext, data) { 31237 var _mediaKeySessionConte; 31238 const keySession = mediaKeySessionContext.mediaKeysSession; 31239 this.log(`Updating key-session "${keySession.sessionId}" for keyID ${Hex.hexDump(((_mediaKeySessionConte = mediaKeySessionContext.decryptdata) == null ? void 0 : _mediaKeySessionConte.keyId) || [])} 31240 } (data length: ${data ? data.byteLength : data})`); 31241 return keySession.update(data); 31242 } 31243 selectKeySystemFormat(frag) { 31244 const keyFormats = Object.keys(frag.levelkeys || {}); 31245 if (!this.keyFormatPromise) { 31246 this.log(`Selecting key-system from fragment (sn: ${frag.sn} ${frag.type}: ${frag.level}) key formats ${keyFormats.join(", ")}`); 31247 this.keyFormatPromise = this.getKeyFormatPromise(keyFormats); 31248 } 31249 return this.keyFormatPromise; 31250 } 31251 getKeyFormatPromise(keyFormats) { 31252 return new Promise((resolve, reject) => {
31253 const keySystemsInConfig = getKeySystemsForConfig(this.config); 31254 const keySystemsToAttempt = keyFormats.map(keySystemFormatToKeySystemDomain).filter((value) => !!value && keySystemsInConfig.indexOf(value) !== -1); 31255 return this.getKeySystemSelectionPromise(keySystemsToAttempt).then(({ 31256 keySystem 31257 }) => { 31258 const keySystemFormat = keySystemDomainToKeySystemFormat(keySystem); 31259 if (keySystemFormat) { 31260 resolve(keySystemFormat); 31261 } else { 31262 reject(new Error(`Unable to find format for key-system "${keySystem}"`)); 31263 } 31264 }).catch(reject); 31265 }); 31266 } 31267 loadKey(data) { 31268 const decryptdata = data.keyInfo.decryptdata; 31269 const keyId = this.getKeyIdString(decryptdata); 31270 const keyDetails = `(keyId: ${keyId} format: "${decryptdata.keyFormat}" method: ${decryptdata.method} uri: ${decryptdata.uri})`; 31271 this.log(`Starting session for key ${keyDetails}`); 31272 let keySessionContextPromise = this.keyIdToKeySessionPromise[keyId]; 31273 if (!keySessionContextPromise) { 31274 keySessionContextPromise = this.keyIdToKeySessionPromise[keyId] = this.getKeySystemForKeyPromise(decryptdata).then(({ 31275 keySystem, 31276 mediaKeys 31277 }) => { 31278 this.throwIfDestroyed(); 31279 this.log(`Handle encrypted media sn: ${data.frag.sn} ${data.frag.type}: ${data.frag.level} using key ${keyDetails}`); 31280 return this.attemptSetMediaKeys(keySystem, mediaKeys).then(() => { 31281 this.throwIfDestroyed(); 31282 const keySessionContext = this.createMediaKeySessionContext({ 31283 keySystem, 31284 mediaKeys, 31285 decryptdata 31286 }); 31287 const scheme = "cenc"; 31288 return this.generateRequestWithPreferredKeySession(keySessionContext, scheme, decryptdata.pssh, "playlist-key"); 31289 }); 31290 }); 31291 keySessionContextPromise.catch((error) => this.handleError(error)); 31292 } 31293 return keySessionContextPromise; 31294 } 31295 throwIfDestroyed(message = "Invalid state") { 31296 if (!this.hls) { 31297 throw new Error("invalid state"); 31298 } 31299 } 31300 handleError(error) { 31301 if (!this.hls) { 31302 return; 31303 } 31304 this.error(error.message); 31305 if (error instanceof EMEKeyError) { 31306 this.hls.trigger(Events.ERROR, error.data); 31307 } else { 31308 this.hls.trigger(Events.ERROR, { 31309 type: ErrorTypes.KEY_SYSTEM_ERROR, 31310 details: ErrorDetails.KEY_SYSTEM_NO_KEYS, 31311 error, 31312 fatal: true 31313 }); 31314 } 31315 } 31316 getKeySystemForKeyPromise(decryptdata) { 31317 const keyId = this.getKeyIdString(decryptdata); 31318 const mediaKeySessionContext = this.keyIdToKeySessionPromise[keyId]; 31319 if (!mediaKeySessionContext) { 31320 const keySystem = keySystemFormatToKeySystemDomain(decryptdata.keyFormat); 31321 const keySystemsToAttempt = keySystem ? [keySystem] : getKeySystemsForConfig(this.config); 31322 return this.attemptKeySystemAccess(keySystemsToAttempt); 31323 } 31324 return mediaKeySessionContext; 31325 } 31326 getKeySystemSelectionPromise(keySystemsToAttempt) { 31327 if (!keySystemsToAttempt.length) { 31328 keySystemsToAttempt = getKeySystemsForConfig(this.config); 31329 } 31330 if (keySystemsToAttempt.length === 0) { 31331 throw new EMEKeyError({ 31332 type: ErrorTypes.KEY_SYSTEM_ERROR, 31333 details: ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE, 31334 fatal: true 31335 }, `Missing key-system license configuration options ${JSON.stringify({ 31336 drmSystems: this.config.drmSystems 31337 })}`); 31338 } 31339 return this.attemptKeySystemAccess(keySystemsToAttempt); 31340 } 31341 attemptSetMediaKeys(keySystem, mediaKeys) { 31342 const queue = this.setMediaKeysQueue.slice(); 31343 this.log(`Setting media-keys for "${keySystem}"`); 31344 const setMediaKeysPromise = Promise.all(queue).then(() => { 31345 if (!this.media) { 31346 throw new Error("Attempted to set mediaKeys without media element attached"); 31347 } 31348 return this.media.setMediaKeys(mediaKeys); 31349 }); 31350 this.setMediaKeysQueue.push(setMediaKeysPromise); 31351 return setMediaKeysPromise.then(() => { 31352 this.log(`Media-keys set for "${keySystem}"`); 31353 queue.push(setMediaKeysPromise); 31354 this.setMediaKeysQueue = this.setMediaKeysQueue.filter((p3) => queue.indexOf(p3) === -1); 31355 }); 31356 } 31357 generateRequestWithPreferredKeySession(context, initDataType, initData, reason) { 31358 var _this$config$drmSyste, _this$config$drmSyste2; 31359 const generateRequestFilter = (_this$config$drmSyste = this.config.drmSystems) == null ? void 0 : (_this$config$drmSyste2 = _this$config$drmSyste[context.keySystem]) == null ? void 0 : _this$config$drmSyste2.generateRequest; 31360 if (generateRequestFilter) {
31361 try { 31362 const mappedInitData = generateRequestFilter.call(this.hls, initDataType, initData, context); 31363 if (!mappedInitData) { 31364 throw new Error("Invalid response from configured generateRequest filter"); 31365 } 31366 initDataType = mappedInitData.initDataType; 31367 initData = context.decryptdata.pssh = mappedInitData.initData ? new Uint8Array(mappedInitData.initData) : null; 31368 } catch (error) { 31369 var _this$hls; 31370 this.warn(error.message); 31371 if ((_this$hls = this.hls) != null && _this$hls.config.debug) { 31372 throw error; 31373 } 31374 } 31375 } 31376 if (initData === null) { 31377 this.log(`Skipping key-session request for "${reason}" (no initData)`); 31378 return Promise.resolve(context); 31379 } 31380 const keyId = this.getKeyIdString(context.decryptdata); 31381 this.log(`Generating key-session request for "${reason}": ${keyId} (init data type: ${initDataType} length: ${initData ? initData.byteLength : null})`); 31382 const licenseStatus = new EventEmitter(); 31383 const onmessage = context._onmessage = (event) => { 31384 const keySession = context.mediaKeysSession; 31385 if (!keySession) { 31386 licenseStatus.emit("error", new Error("invalid state")); 31387 return; 31388 } 31389 const { 31390 messageType, 31391 message 31392 } = event; 31393 this.log(`"${messageType}" message event for session "${keySession.sessionId}" message size: ${message.byteLength}`); 31394 if (messageType === "license-request" || messageType === "license-renewal") { 31395 this.renewLicense(context, message).catch((error) => { 31396 this.handleError(error); 31397 licenseStatus.emit("error", error); 31398 }); 31399 } else if (messageType === "license-release") { 31400 if (context.keySystem === KeySystems.FAIRPLAY) { 31401 this.updateKeySession(context, strToUtf8array("acknowledged")); 31402 this.removeSession(context); 31403 } 31404 } else { 31405 this.warn(`unhandled media key message type "${messageType}"`); 31406 } 31407 }; 31408 const onkeystatuseschange = context._onkeystatuseschange = (event) => { 31409 const keySession = context.mediaKeysSession; 31410 if (!keySession) { 31411 licenseStatus.emit("error", new Error("invalid state")); 31412 return; 31413 } 31414 this.onKeyStatusChange(context); 31415 const keyStatus = context.keyStatus; 31416 licenseStatus.emit("keyStatus", keyStatus); 31417 if (keyStatus === "expired") { 31418 this.warn(`${context.keySystem} expired for key ${keyId}`); 31419 this.renewKeySession(context); 31420 } 31421 }; 31422 context.mediaKeysSession.addEventListener("message", onmessage); 31423 context.mediaKeysSession.addEventListener("keystatuseschange", onkeystatuseschange); 31424 const keyUsablePromise = new Promise((resolve, reject) => { 31425 licenseStatus.on("error", reject); 31426 licenseStatus.on("keyStatus", (keyStatus) => { 31427 if (keyStatus.startsWith("usable")) { 31428 resolve(); 31429 } else if (keyStatus === "output-restricted") { 31430 reject(new EMEKeyError({ 31431 type: ErrorTypes.KEY_SYSTEM_ERROR, 31432 details: ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED, 31433 fatal: false 31434 }, "HDCP level output restricted")); 31435 } else if (keyStatus === "internal-error") { 31436 reject(new EMEKeyError({ 31437 type: ErrorTypes.KEY_SYSTEM_ERROR, 31438 details: ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR, 31439 fatal: true 31440 }, `key status changed to "${keyStatus}"`)); 31441 } else if (keyStatus === "expired") { 31442 reject(new Error("key expired while generating request")); 31443 } else { 31444 this.warn(`unhandled key status change "${keyStatus}"`); 31445 } 31446 }); 31447 }); 31448 return context.mediaKeysSession.generateRequest(initDataType, initData).then(() => { 31449 var _context$mediaKeysSes; 31450 this.log(`Request generated for key-session "${(_context$mediaKeysSes = context.mediaKeysSession) == null ? void 0 : _context$mediaKeysSes.sessionId}" keyId: ${keyId}`); 31451 }).catch((error) => { 31452 throw new EMEKeyError({ 31453 type: ErrorTypes.KEY_SYSTEM_ERROR, 31454 details: ErrorDetails.KEY_SYSTEM_NO_SESSION, 31455 error, 31456 fatal: false 31457 }, `Error generating key-session request: ${error}`); 31458 }).then(() => keyUsablePromise).catch((error) => { 31459 licenseStatus.removeAllListeners(); 31460 this.removeSession(context); 31461 throw error; 31462 }).then(() => { 31463 licenseStatus.removeAllListeners(); 31464 return context; 31465 }); 31466 } 31467 onKeyStatusChange(mediaKeySessionContext) {
vendor: 4,783 bytes, lines 31468-31579
31468 mediaKeySessionContext.mediaKeysSession.keyStatuses.forEach((status2, keyId) => { 31469 this.log(`key status change "${status2}" for keyStatuses keyId: ${Hex.hexDump("buffer" in keyId ? new Uint8Array(keyId.buffer, keyId.byteOffset, keyId.byteLength) : new Uint8Array(keyId))} session keyId: ${Hex.hexDump(new Uint8Array(mediaKeySessionContext.decryptdata.keyId || []))} uri: ${mediaKeySessionContext.decryptdata.uri}`); 31470 mediaKeySessionContext.keyStatus = status2; 31471 }); 31472 } 31473 fetchServerCertificate(keySystem) { 31474 const config = this.config; 31475 const Loader2 = config.loader; 31476 const certLoader = new Loader2(config); 31477 const url = this.getServerCertificateUrl(keySystem); 31478 if (!url) { 31479 return Promise.resolve(); 31480 } 31481 this.log(`Fetching server certificate for "${keySystem}"`); 31482 return new Promise((resolve, reject) => { 31483 const loaderContext = { 31484 responseType: "arraybuffer", 31485 url 31486 }; 31487 const loadPolicy = config.certLoadPolicy.default; 31488 const loaderConfig = { 31489 loadPolicy, 31490 timeout: loadPolicy.maxLoadTimeMs, 31491 maxRetry: 0, 31492 retryDelay: 0, 31493 maxRetryDelay: 0 31494 }; 31495 const loaderCallbacks = { 31496 onSuccess: (response, stats, context, networkDetails) => { 31497 resolve(response.data); 31498 }, 31499 onError: (response, contex, networkDetails, stats) => { 31500 reject(new EMEKeyError({ 31501 type: ErrorTypes.KEY_SYSTEM_ERROR, 31502 details: ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED, 31503 fatal: true, 31504 networkDetails, 31505 response: _objectSpread23({ 31506 url: loaderContext.url, 31507 data: void 0 31508 }, response) 31509 }, `"${keySystem}" certificate request failed (${url}). Status: ${response.code} (${response.text})`)); 31510 }, 31511 onTimeout: (stats, context, networkDetails) => { 31512 reject(new EMEKeyError({ 31513 type: ErrorTypes.KEY_SYSTEM_ERROR, 31514 details: ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED, 31515 fatal: true, 31516 networkDetails, 31517 response: { 31518 url: loaderContext.url, 31519 data: void 0 31520 } 31521 }, `"${keySystem}" certificate request timed out (${url})`)); 31522 }, 31523 onAbort: (stats, context, networkDetails) => { 31524 reject(new Error("aborted")); 31525 } 31526 }; 31527 certLoader.load(loaderContext, loaderConfig, loaderCallbacks); 31528 }); 31529 } 31530 setMediaKeysServerCertificate(mediaKeys, keySystem, cert) { 31531 return new Promise((resolve, reject) => { 31532 mediaKeys.setServerCertificate(cert).then((success) => { 31533 this.log(`setServerCertificate ${success ? "success" : "not supported by CDM"} (${cert == null ? void 0 : cert.byteLength}) on "${keySystem}"`); 31534 resolve(mediaKeys); 31535 }).catch((error) => { 31536 reject(new EMEKeyError({ 31537 type: ErrorTypes.KEY_SYSTEM_ERROR, 31538 details: ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED, 31539 error, 31540 fatal: true 31541 }, error.message)); 31542 }); 31543 }); 31544 } 31545 renewLicense(context, keyMessage) { 31546 return this.requestLicense(context, new Uint8Array(keyMessage)).then((data) => { 31547 return this.updateKeySession(context, new Uint8Array(data)).catch((error) => { 31548 throw new EMEKeyError({ 31549 type: ErrorTypes.KEY_SYSTEM_ERROR, 31550 details: ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED, 31551 error, 31552 fatal: true 31553 }, error.message); 31554 }); 31555 }); 31556 } 31557 unpackPlayReadyKeyMessage(xhr, licenseChallenge) { 31558 const xmlString = String.fromCharCode.apply(null, new Uint16Array(licenseChallenge.buffer)); 31559 if (!xmlString.includes("PlayReadyKeyMessage")) { 31560 xhr.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); 31561 return licenseChallenge; 31562 } 31563 const keyMessageXml = new DOMParser().parseFromString(xmlString, "application/xml"); 31564 const headers = keyMessageXml.querySelectorAll("HttpHeader"); 31565 if (headers.length > 0) { 31566 let header; 31567 for (let i3 = 0, len = headers.length; i3 < len; i3++) { 31568 var _header$querySelector, _header$querySelector2; 31569 header = headers[i3]; 31570 const name = (_header$querySelector = header.querySelector("name")) == null ? void 0 : _header$querySelector.textContent; 31571 const value = (_header$querySelector2 = header.querySelector("value")) == null ? void 0 : _header$querySelector2.textContent; 31572 if (name && value) { 31573 xhr.setRequestHeader(name, value); 31574 } 31575 } 31576 } 31577 const challengeElement = keyMessageXml.querySelector("Challenge"); 31578 const challengeText = challengeElement == null ? void 0 : challengeElement.textContent; 31579 if (!challengeText) {
vendor: 4,921 bytes, lines 31580-31703
31580 throw new Error(`Cannot find <Challenge> in key message`); 31581 } 31582 return strToUtf8array(atob(challengeText)); 31583 } 31584 setupLicenseXHR(xhr, url, keysListItem, licenseChallenge) { 31585 const licenseXhrSetup = this.config.licenseXhrSetup; 31586 if (!licenseXhrSetup) { 31587 xhr.open("POST", url, true); 31588 return Promise.resolve({ 31589 xhr, 31590 licenseChallenge 31591 }); 31592 } 31593 return Promise.resolve().then(() => { 31594 if (!keysListItem.decryptdata) { 31595 throw new Error("Key removed"); 31596 } 31597 return licenseXhrSetup.call(this.hls, xhr, url, keysListItem, licenseChallenge); 31598 }).catch((error) => { 31599 if (!keysListItem.decryptdata) { 31600 throw error; 31601 } 31602 xhr.open("POST", url, true); 31603 return licenseXhrSetup.call(this.hls, xhr, url, keysListItem, licenseChallenge); 31604 }).then((licenseXhrSetupResult) => { 31605 if (!xhr.readyState) { 31606 xhr.open("POST", url, true); 31607 } 31608 const finalLicenseChallenge = licenseXhrSetupResult ? licenseXhrSetupResult : licenseChallenge; 31609 return { 31610 xhr, 31611 licenseChallenge: finalLicenseChallenge 31612 }; 31613 }); 31614 } 31615 requestLicense(keySessionContext, licenseChallenge) { 31616 const keyLoadPolicy = this.config.keyLoadPolicy.default; 31617 return new Promise((resolve, reject) => { 31618 const url = this.getLicenseServerUrlOrThrow(keySessionContext.keySystem); 31619 this.log(`Sending license request to URL: ${url}`); 31620 const xhr = new XMLHttpRequest(); 31621 xhr.responseType = "arraybuffer"; 31622 xhr.onreadystatechange = () => { 31623 if (!this.hls || !keySessionContext.mediaKeysSession) { 31624 return reject(new Error("invalid state")); 31625 } 31626 if (xhr.readyState === 4) { 31627 if (xhr.status === 200) { 31628 this._requestLicenseFailureCount = 0; 31629 let data = xhr.response; 31630 this.log(`License received ${data instanceof ArrayBuffer ? data.byteLength : data}`); 31631 const licenseResponseCallback = this.config.licenseResponseCallback; 31632 if (licenseResponseCallback) { 31633 try { 31634 data = licenseResponseCallback.call(this.hls, xhr, url, keySessionContext); 31635 } catch (error) { 31636 this.error(error); 31637 } 31638 } 31639 resolve(data); 31640 } else { 31641 const retryConfig = keyLoadPolicy.errorRetry; 31642 const maxNumRetry = retryConfig ? retryConfig.maxNumRetry : 0; 31643 this._requestLicenseFailureCount++; 31644 if (this._requestLicenseFailureCount > maxNumRetry || xhr.status >= 400 && xhr.status < 500) { 31645 reject(new EMEKeyError({ 31646 type: ErrorTypes.KEY_SYSTEM_ERROR, 31647 details: ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED, 31648 fatal: true, 31649 networkDetails: xhr, 31650 response: { 31651 url, 31652 data: void 0, 31653 code: xhr.status, 31654 text: xhr.statusText 31655 } 31656 }, `License Request XHR failed (${url}). Status: ${xhr.status} (${xhr.statusText})`)); 31657 } else { 31658 const attemptsLeft = maxNumRetry - this._requestLicenseFailureCount + 1; 31659 this.warn(`Retrying license request, ${attemptsLeft} attempts left`); 31660 this.requestLicense(keySessionContext, licenseChallenge).then(resolve, reject); 31661 } 31662 } 31663 } 31664 }; 31665 if (keySessionContext.licenseXhr && keySessionContext.licenseXhr.readyState !== XMLHttpRequest.DONE) { 31666 keySessionContext.licenseXhr.abort(); 31667 } 31668 keySessionContext.licenseXhr = xhr; 31669 this.setupLicenseXHR(xhr, url, keySessionContext, licenseChallenge).then(({ 31670 xhr: xhr2, 31671 licenseChallenge: licenseChallenge2 31672 }) => { 31673 if (keySessionContext.keySystem == KeySystems.PLAYREADY) { 31674 licenseChallenge2 = this.unpackPlayReadyKeyMessage(xhr2, licenseChallenge2); 31675 } 31676 xhr2.send(licenseChallenge2); 31677 }); 31678 }); 31679 } 31680 onMediaAttached(event, data) { 31681 if (!this.config.emeEnabled) { 31682 return; 31683 } 31684 const media = data.media; 31685 this.media = media; 31686 media.removeEventListener("encrypted", this.onMediaEncrypted); 31687 media.removeEventListener("waitingforkey", this.onWaitingForKey); 31688 media.addEventListener("encrypted", this.onMediaEncrypted); 31689 media.addEventListener("waitingforkey", this.onWaitingForKey); 31690 } 31691 onMediaDetached() { 31692 const media = this.media; 31693 const mediaKeysList = this.mediaKeySessions; 31694 if (media) { 31695 media.removeEventListener("encrypted", this.onMediaEncrypted); 31696 media.removeEventListener("waitingforkey", this.onWaitingForKey); 31697 this.media = null; 31698 } 31699 this._requestLicenseFailureCount = 0; 31700 this.setMediaKeysQueue = []; 31701 this.mediaKeySessions = []; 31702 this.keyIdToKeySessionPromise = {}; 31703 LevelKey.clearKeyUriToKeyIdMap();
31704 const keySessionCount = mediaKeysList.length; 31705 _EMEController.CDMCleanupPromise = Promise.all(mediaKeysList.map((mediaKeySessionContext) => this.removeSession(mediaKeySessionContext)).concat(media == null ? void 0 : media.setMediaKeys(null).catch((error) => { 31706 this.log(`Could not clear media keys: ${error}`); 31707 }))).then(() => { 31708 if (keySessionCount) { 31709 this.log("finished closing key sessions and clearing media keys"); 31710 mediaKeysList.length = 0; 31711 } 31712 }).catch((error) => { 31713 this.log(`Could not close sessions and clear media keys: ${error}`); 31714 }); 31715 } 31716 onManifestLoading() { 31717 this.keyFormatPromise = null; 31718 } 31719 onManifestLoaded(event, { 31720 sessionKeys 31721 }) { 31722 if (!sessionKeys || !this.config.emeEnabled) { 31723 return; 31724 } 31725 if (!this.keyFormatPromise) { 31726 const keyFormats = sessionKeys.reduce((formats, sessionKey) => { 31727 if (formats.indexOf(sessionKey.keyFormat) === -1) { 31728 formats.push(sessionKey.keyFormat); 31729 } 31730 return formats; 31731 }, []); 31732 this.log(`Selecting key-system from session-keys ${keyFormats.join(", ")}`); 31733 this.keyFormatPromise = this.getKeyFormatPromise(keyFormats); 31734 } 31735 } 31736 removeSession(mediaKeySessionContext) { 31737 const { 31738 mediaKeysSession, 31739 licenseXhr 31740 } = mediaKeySessionContext; 31741 if (mediaKeysSession) { 31742 this.log(`Remove licenses and keys and close session ${mediaKeysSession.sessionId}`); 31743 if (mediaKeySessionContext._onmessage) { 31744 mediaKeysSession.removeEventListener("message", mediaKeySessionContext._onmessage); 31745 mediaKeySessionContext._onmessage = void 0; 31746 } 31747 if (mediaKeySessionContext._onkeystatuseschange) { 31748 mediaKeysSession.removeEventListener("keystatuseschange", mediaKeySessionContext._onkeystatuseschange); 31749 mediaKeySessionContext._onkeystatuseschange = void 0; 31750 } 31751 if (licenseXhr && licenseXhr.readyState !== XMLHttpRequest.DONE) { 31752 licenseXhr.abort(); 31753 } 31754 mediaKeySessionContext.mediaKeysSession = mediaKeySessionContext.decryptdata = mediaKeySessionContext.licenseXhr = void 0; 31755 const index2 = this.mediaKeySessions.indexOf(mediaKeySessionContext); 31756 if (index2 > -1) { 31757 this.mediaKeySessions.splice(index2, 1); 31758 } 31759 return mediaKeysSession.remove().catch((error) => { 31760 this.log(`Could not remove session: ${error}`); 31761 }).then(() => { 31762 return mediaKeysSession.close(); 31763 }).catch((error) => { 31764 this.log(`Could not close session: ${error}`); 31765 }); 31766 } 31767 } 31768}; 31769EMEController.CDMCleanupPromise = void 0; 31770var EMEKeyError = class extends Error { 31771 constructor(data, message) { 31772 super(message); 31773 this.data = void 0; 31774 data.error || (data.error = new Error(message)); 31775 this.data = data; 31776 data.err = data.error; 31777 } 31778}; 31779var CmObjectType; 31780(function(CmObjectType2) { 31781 CmObjectType2["MANIFEST"] = "m"; 31782 CmObjectType2["AUDIO"] = "a"; 31783 CmObjectType2["VIDEO"] = "v"; 31784 CmObjectType2["MUXED"] = "av"; 31785 CmObjectType2["INIT"] = "i"; 31786 CmObjectType2["CAPTION"] = "c"; 31787 CmObjectType2["TIMED_TEXT"] = "tt"; 31788 CmObjectType2["KEY"] = "k"; 31789 CmObjectType2["OTHER"] = "o"; 31790})(CmObjectType || (CmObjectType = {})); 31791var CmStreamingFormat; 31792(function(CmStreamingFormat2) { 31793 CmStreamingFormat2["DASH"] = "d"; 31794 CmStreamingFormat2["HLS"] = "h"; 31795 CmStreamingFormat2["SMOOTH"] = "s"; 31796 CmStreamingFormat2["OTHER"] = "o"; 31797})(CmStreamingFormat || (CmStreamingFormat = {})); 31798var CmcdHeaderField; 31799(function(CmcdHeaderField2) { 31800 CmcdHeaderField2["OBJECT"] = "CMCD-Object"; 31801 CmcdHeaderField2["REQUEST"] = "CMCD-Request";
31802 CmcdHeaderField2["SESSION"] = "CMCD-Session"; 31803 CmcdHeaderField2["STATUS"] = "CMCD-Status"; 31804})(CmcdHeaderField || (CmcdHeaderField = {})); 31805var CmcdHeaderMap = { 31806 [CmcdHeaderField.OBJECT]: ["br", "d", "ot", "tb"], 31807 [CmcdHeaderField.REQUEST]: ["bl", "dl", "mtp", "nor", "nrr", "su"], 31808 [CmcdHeaderField.SESSION]: ["cid", "pr", "sf", "sid", "st", "v"], 31809 [CmcdHeaderField.STATUS]: ["bs", "rtp"] 31810}; 31811var SfItem = class _SfItem { 31812 constructor(value, params) { 31813 this.value = void 0; 31814 this.params = void 0; 31815 if (Array.isArray(value)) { 31816 value = value.map((v2) => v2 instanceof _SfItem ? v2 : new _SfItem(v2)); 31817 } 31818 this.value = value; 31819 this.params = params; 31820 } 31821}; 31822var SfToken = class { 31823 constructor(description) { 31824 this.description = void 0; 31825 this.description = description; 31826 } 31827}; 31828var DICT = "Dict"; 31829function format(value) { 31830 if (Array.isArray(value)) { 31831 return JSON.stringify(value); 31832 } 31833 if (value instanceof Map) { 31834 return "Map{}"; 31835 } 31836 if (value instanceof Set) { 31837 return "Set{}"; 31838 } 31839 if (typeof value === "object") { 31840 return JSON.stringify(value); 31841 } 31842 return String(value); 31843} 31844function throwError(action, src, type, cause) { 31845 return new Error(`failed to ${action} "${format(src)}" as ${type}`, { 31846 cause 31847 }); 31848} 31849var BARE_ITEM = "Bare Item"; 31850var BOOLEAN = "Boolean"; 31851var BYTES = "Byte Sequence"; 31852var DECIMAL = "Decimal"; 31853var INTEGER = "Integer"; 31854function isInvalidInt(value) { 31855 return value < -999999999999999 || 999999999999999 < value; 31856} 31857var STRING_REGEX = /[\x00-\x1f\x7f]+/; 31858var TOKEN = "Token"; 31859var KEY = "Key"; 31860function serializeError(src, type, cause) { 31861 return throwError("serialize", src, type, cause); 31862} 31863function serializeBoolean(value) { 31864 if (typeof value !== "boolean") { 31865 throw serializeError(value, BOOLEAN); 31866 } 31867 return value ? "?1" : "?0"; 31868} 31869function base64encode(binary) { 31870 return btoa(String.fromCharCode(...binary)); 31871} 31872function serializeByteSequence(value) { 31873 if (ArrayBuffer.isView(value) === false) { 31874 throw serializeError(value, BYTES); 31875 } 31876 return `:${base64encode(value)}:`; 31877} 31878function serializeInteger(value) { 31879 if (isInvalidInt(value)) { 31880 throw serializeError(value, INTEGER); 31881 } 31882 return value.toString(); 31883} 31884function serializeDate(value) { 31885 return `@${serializeInteger(value.getTime() / 1e3)}`; 31886} 31887function roundToEven(value, precision) { 31888 if (value < 0) { 31889 return -roundToEven(-value, precision); 31890 } 31891 const decimalShift = Math.pow(10, precision); 31892 const isEquidistant = Math.abs(value * decimalShift % 1 - 0.5) < Number.EPSILON; 31893 if (isEquidistant) { 31894 const flooredValue = Math.floor(value * decimalShift); 31895 return (flooredValue % 2 === 0 ? flooredValue : flooredValue + 1) / decimalShift; 31896 } else { 31897 return Math.round(value * decimalShift) / decimalShift; 31898 } 31899} 31900function serializeDecimal(value) { 31901 const roundedValue = roundToEven(value, 3); 31902 if (Math.floor(Math.abs(roundedValue)).toString().length > 12) { 31903 throw serializeError(value, DECIMAL); 31904 } 31905 const stringValue = roundedValue.toString(); 31906 return stringValue.includes(".") ? stringValue : `${stringValue}.0`; 31907} 31908var STRING = "String"; 31909function serializeString(value) { 31910 if (STRING_REGEX.test(value)) { 31911 throw serializeError(value, STRING); 31912 } 31913 return `"${value.replace(/\\/g, `\\\\`).replace(/"/g, `\\"`)}"`; 31914} 31915function symbolToStr(symbol) { 31916 return symbol.description || symbol.toString().slice(7, -1); 31917} 31918function serializeToken(token2) { 31919 const value = symbolToStr(token2); 31920 if (/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(value) === false) { 31921 throw serializeError(value, TOKEN); 31922 } 31923 return value; 31924} 31925function serializeBareItem(value) { 31926 switch (typeof value) { 31927 case "number": 31928 if (!isFiniteNumber(value)) { 31929 throw serializeError(value, BARE_ITEM); 31930 } 31931 if (Number.isInteger(value)) { 31932 return serializeInteger(value); 31933 } 31934 return serializeDecimal(value); 31935 case "string": 31936 return serializeString(value); 31937 case "symbol": 31938 return serializeToken(value); 31939 case "boolean": 31940 return serializeBoolean(value); 31941 case "object": 31942 if (value instanceof Date) { 31943 return serializeDate(value); 31944 } 31945 if (value instanceof Uint8Array) { 31946 return serializeByteSequence(value); 31947 } 31948 if (value instanceof SfToken) { 31949 return serializeToken(value); 31950 } 31951 default: 31952 throw serializeError(value, BARE_ITEM); 31953 } 31954} 31955function serializeKey(value) { 31956 if (/^[a-z*][a-z0-9\-_.*]*$/.test(value) === false) { 31957 throw serializeError(value, KEY); 31958 } 31959 return value; 31960} 31961function serializeParams(params) { 31962 if (params == null) { 31963 return ""; 31964 } 31965 return Object.entries(params).map(([key, value]) => { 31966 if (value === true) { 31967 return `;${serializeKey(key)}`; 31968 } 31969 return `;${serializeKey(key)}=${serializeBareItem(value)}`; 31970 }).join(""); 31971} 31972function serializeItem(value) { 31973 if (value instanceof SfItem) { 31974 return `${serializeBareItem(value.value)}${serializeParams(value.params)}`; 31975 } else { 31976 return serializeBareItem(value); 31977 } 31978} 31979function serializeInnerList(value) { 31980 return `(${value.value.map(serializeItem).join(" ")})${serializeParams(value.params)}`; 31981} 31982function serializeDict(dict, options2 = { 31983 whitespace: true 31984}) { 31985 if (typeof dict !== "object") { 31986 throw serializeError(dict, DICT); 31987 } 31988 const entries = dict instanceof Map ? dict.entries() : Object.entries(dict); 31989 const optionalWhiteSpace = options2 != null && options2.whitespace ? " " : ""; 31990 return Array.from(entries).map(([key, item]) => { 31991 if (item instanceof SfItem === false) { 31992 item = new SfItem(item); 31993 } 31994 let output2 = serializeKey(key); 31995 if (item.value === true) { 31996 output2 += serializeParams(item.params); 31997 } else { 31998 output2 += "="; 31999 if (Array.isArray(item.value)) { 32000 output2 += serializeInnerList(item); 32001 } else { 32002 output2 += serializeItem(item); 32003 } 32004 } 32005 return output2; 32006 }).join(`,${optionalWhiteSpace}`); 32007} 32008function encodeSfDict(value, options2) { 32009 return serializeDict(value, options2); 32010} 32011var isTokenField = (key) => key === "ot" || key === "sf" || key === "st"; 32012var isValid = (value) => { 32013 if (typeof value === "number") { 32014 return isFiniteNumber(value); 32015 } 32016 return value != null && value !== "" && value !== false; 32017}; 32018function urlToRelativePath(url, base) { 32019 const to = new URL(url); 32020 const from2 = new URL(base); 32021 if (to.origin !== from2.origin) { 32022 return url; 32023 } 32024 const toPath = to.pathname.split("/").slice(1); 32025 const fromPath = from2.pathname.split("/").slice(1, -1); 32026 while (toPath[0] === fromPath[0]) { 32027 toPath.shift(); 32028 fromPath.shift(); 32029 } 32030 while (fromPath.length) { 32031 fromPath.shift(); 32032 toPath.unshift(".."); 32033 } 32034 return toPath.join("/"); 32035} 32036function uuid() { 32037 try { 32038 return crypto.randomUUID(); 32039 } catch (error) { 32040 try { 32041 const url = URL.createObjectURL(new Blob()); 32042 const uuid2 = url.toString(); 32043 URL.revokeObjectURL(url); 32044 return uuid2.slice(uuid2.lastIndexOf("/") + 1); 32045 } catch (error2) { 32046 let dt5 = (/* @__PURE__ */ new Date()).getTime(); 32047 const uuid2 = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c3) => { 32048 const r10 = (dt5 + Math.random() * 16) % 16 | 0; 32049 dt5 = Math.floor(dt5 / 16); 32050 return (c3 == "x" ? r10 : r10 & 3 | 8).toString(16); 32051 }); 32052 return uuid2; 32053 } 32054 } 32055} 32056var toRounded = (value) => Math.round(value); 32057var toUrlSafe = (value, options2) => { 32058 if (options2 != null && options2.baseUrl) { 32059 value = urlToRelativePath(value, options2.baseUrl); 32060 } 32061 return encodeURIComponent(value); 32062}; 32063var toHundred = (value) => toRounded(value / 100) * 100; 32064var CmcdFormatters = { 32065 /** 32066 * Bitrate (kbps) rounded integer 32067 */ 32068 br: toRounded, 32069 /** 32070 * Duration (milliseconds) rounded integer 32071 */ 32072 d: toRounded, 32073 /** 32074 * Buffer Length (milliseconds) rounded nearest 100ms 32075 */ 32076 bl: toHundred, 32077 /** 32078 * Deadline (milliseconds) rounded nearest 100ms 32079 */ 32080 dl: toHundred, 32081 /** 32082 * Measured Throughput (kbps) rounded nearest 100kbps 32083 */ 32084 mtp: toHundred, 32085 /** 32086 * Next Object Request URL encoded 32087 */ 32088 nor: toUrlSafe, 32089 /** 32090 * Requested maximum throughput (kbps) rounded nearest 100kbps 32091 */ 32092 rtp: toHundred, 32093 /** 32094 * Top Bitrate (kbps) rounded integer 32095 */ 32096 tb: toRounded 32097}; 32098function processCmcd(obj, options2) { 32099 const results = {}; 32100 if (obj == null || typeof obj !== "object") { 32101 return results; 32102 } 32103 const keys = Object.keys(obj).sort(); 32104 const formatters = _extends2({}, CmcdFormatters, options2 == null ? void 0 : options2.formatters); 32105 const filter = options2 == null ? void 0 : options2.filter; 32106 keys.forEach((key) => { 32107 if (filter != null && filter(key)) { 32108 return; 32109 } 32110 let value = obj[key]; 32111 const formatter = formatters[key]; 32112 if (formatter) { 32113 value = formatter(value, options2); 32114 } 32115 if (key === "v" && value === 1) { 32116 return; 32117 } 32118 if (key == "pr" && value === 1) { 32119 return; 32120 } 32121 if (!isValid(value)) { 32122 return; 32123 } 32124 if (isTokenField(key) && typeof value === "string") { 32125 value = new SfToken(value); 32126 } 32127 results[key] = value; 32128 }); 32129 return results; 32130} 32131function encodeCmcd(cmcd, options2 = {}) { 32132 if (!cmcd) { 32133 return ""; 32134 } 32135 return encodeSfDict(processCmcd(cmcd, options2), _extends2({ 32136 whitespace: false 32137 }, options2)); 32138} 32139function toCmcdHeaders(cmcd, options2 = {}) { 32140 if (!cmcd) { 32141 return {}; 32142 } 32143 const entries = Object.entries(cmcd); 32144 const headerMap = Object.entries(CmcdHeaderMap).concat(Object.entries((options2 == null ? void 0 : options2.customHeaderMap) || {})); 32145 const shards = entries.reduce((acc, entry) => { 32146 var _headerMap$find, _acc$field; 32147 const [key, value] = entry; 32148 const field = ((_headerMap$find = headerMap.find((entry2) => entry2[1].includes(key))) == null ? void 0 : _headerMap$find[0]) || CmcdHeaderField.REQUEST; 32149 (_acc$field = acc[field]) != null ? _acc$field : acc[field] = {}; 32150 acc[field][key] = value; 32151 return acc; 32152 }, {}); 32153 return Object.entries(shards).reduce((acc, [field, value]) => { 32154 acc[field] = encodeCmcd(value, options2); 32155 return acc; 32156 }, {}); 32157} 32158function appendCmcdHeaders(headers, cmcd, options2) { 32159 return _extends2(headers, toCmcdHeaders(cmcd, options2)); 32160} 32161var CMCD_PARAM = "CMCD"; 32162function toCmcdQuery(cmcd, options2 = {}) { 32163 if (!cmcd) { 32164 return ""; 32165 } 32166 const params = encodeCmcd(cmcd, options2); 32167 return `${CMCD_PARAM}=${encodeURIComponent(params)}`; 32168} 32169var REGEX = /CMCD=[^&#]+/; 32170function appendCmcdQuery(url, cmcd, options2) { 32171 const query = toCmcdQuery(cmcd, options2); 32172 if (!query) { 32173 return url; 32174 } 32175 if (REGEX.test(url)) { 32176 return url.replace(REGEX, query); 32177 } 32178 const separator = url.includes("?") ? "&" : "?"; 32179 return `${url}${separator}${query}`; 32180} 32181var CMCDController = class { 32182 // eslint-disable-line no-restricted-globals 32183 constructor(hls) { 32184 this.hls = void 0; 32185 this.config = void 0; 32186 this.media = void 0; 32187 this.sid = void 0; 32188 this.cid = void 0; 32189 this.useHeaders = false;
vendor: 4,098 bytes, lines 32190-32320
32190 this.includeKeys = void 0; 32191 this.initialized = false; 32192 this.starved = false; 32193 this.buffering = true; 32194 this.audioBuffer = void 0; 32195 this.videoBuffer = void 0; 32196 this.onWaiting = () => { 32197 if (this.initialized) { 32198 this.starved = true; 32199 } 32200 this.buffering = true; 32201 }; 32202 this.onPlaying = () => { 32203 if (!this.initialized) { 32204 this.initialized = true; 32205 } 32206 this.buffering = false; 32207 }; 32208 this.applyPlaylistData = (context) => { 32209 try { 32210 this.apply(context, { 32211 ot: CmObjectType.MANIFEST, 32212 su: !this.initialized 32213 }); 32214 } catch (error) { 32215 logger.warn("Could not generate manifest CMCD data.", error); 32216 } 32217 }; 32218 this.applyFragmentData = (context) => { 32219 try { 32220 const fragment = context.frag; 32221 const level = this.hls.levels[fragment.level]; 32222 const ot4 = this.getObjectType(fragment); 32223 const data = { 32224 d: fragment.duration * 1e3, 32225 ot: ot4 32226 }; 32227 if (ot4 === CmObjectType.VIDEO || ot4 === CmObjectType.AUDIO || ot4 == CmObjectType.MUXED) { 32228 data.br = level.bitrate / 1e3; 32229 data.tb = this.getTopBandwidth(ot4) / 1e3; 32230 data.bl = this.getBufferLength(ot4); 32231 } 32232 this.apply(context, data); 32233 } catch (error) { 32234 logger.warn("Could not generate segment CMCD data.", error); 32235 } 32236 }; 32237 this.hls = hls; 32238 const config = this.config = hls.config; 32239 const { 32240 cmcd 32241 } = config; 32242 if (cmcd != null) { 32243 config.pLoader = this.createPlaylistLoader(); 32244 config.fLoader = this.createFragmentLoader(); 32245 this.sid = cmcd.sessionId || uuid(); 32246 this.cid = cmcd.contentId; 32247 this.useHeaders = cmcd.useHeaders === true; 32248 this.includeKeys = cmcd.includeKeys; 32249 this.registerListeners(); 32250 } 32251 } 32252 registerListeners() { 32253 const hls = this.hls; 32254 hls.on(Events.MEDIA_ATTACHED, this.onMediaAttached, this); 32255 hls.on(Events.MEDIA_DETACHED, this.onMediaDetached, this); 32256 hls.on(Events.BUFFER_CREATED, this.onBufferCreated, this); 32257 } 32258 unregisterListeners() { 32259 const hls = this.hls; 32260 hls.off(Events.MEDIA_ATTACHED, this.onMediaAttached, this); 32261 hls.off(Events.MEDIA_DETACHED, this.onMediaDetached, this); 32262 hls.off(Events.BUFFER_CREATED, this.onBufferCreated, this); 32263 } 32264 destroy() { 32265 this.unregisterListeners(); 32266 this.onMediaDetached(); 32267 this.hls = this.config = this.audioBuffer = this.videoBuffer = null; 32268 this.onWaiting = this.onPlaying = null; 32269 } 32270 onMediaAttached(event, data) { 32271 this.media = data.media; 32272 this.media.addEventListener("waiting", this.onWaiting); 32273 this.media.addEventListener("playing", this.onPlaying); 32274 } 32275 onMediaDetached() { 32276 if (!this.media) { 32277 return; 32278 } 32279 this.media.removeEventListener("waiting", this.onWaiting); 32280 this.media.removeEventListener("playing", this.onPlaying); 32281 this.media = null; 32282 } 32283 onBufferCreated(event, data) { 32284 var _data$tracks$audio, _data$tracks$video; 32285 this.audioBuffer = (_data$tracks$audio = data.tracks.audio) == null ? void 0 : _data$tracks$audio.buffer; 32286 this.videoBuffer = (_data$tracks$video = data.tracks.video) == null ? void 0 : _data$tracks$video.buffer; 32287 } 32288 /** 32289 * Create baseline CMCD data 32290 */ 32291 createData() { 32292 var _this$media; 32293 return { 32294 v: 1, 32295 sf: CmStreamingFormat.HLS, 32296 sid: this.sid, 32297 cid: this.cid, 32298 pr: (_this$media = this.media) == null ? void 0 : _this$media.playbackRate, 32299 mtp: this.hls.bandwidthEstimate / 1e3 32300 }; 32301 } 32302 /** 32303 * Apply CMCD data to a request. 32304 */ 32305 apply(context, data = {}) { 32306 _extends2(data, this.createData()); 32307 const isVideo = data.ot === CmObjectType.INIT || data.ot === CmObjectType.VIDEO || data.ot === CmObjectType.MUXED; 32308 if (this.starved && isVideo) { 32309 data.bs = true; 32310 data.su = true; 32311 this.starved = false; 32312 } 32313 if (data.su == null) { 32314 data.su = this.buffering; 32315 } 32316 const { 32317 includeKeys 32318 } = this; 32319 if (includeKeys) { 32320 data = Object.keys(data).reduce((acc, key) => {
vendor: 10,629 bytes, lines 32321-32675
32321 includeKeys.includes(key) && (acc[key] = data[key]); 32322 return acc; 32323 }, {}); 32324 } 32325 if (this.useHeaders) { 32326 if (!context.headers) { 32327 context.headers = {}; 32328 } 32329 appendCmcdHeaders(context.headers, data); 32330 } else { 32331 context.url = appendCmcdQuery(context.url, data); 32332 } 32333 } 32334 /** 32335 * The CMCD object type. 32336 */ 32337 getObjectType(fragment) { 32338 const { 32339 type 32340 } = fragment; 32341 if (type === "subtitle") { 32342 return CmObjectType.TIMED_TEXT; 32343 } 32344 if (fragment.sn === "initSegment") { 32345 return CmObjectType.INIT; 32346 } 32347 if (type === "audio") { 32348 return CmObjectType.AUDIO; 32349 } 32350 if (type === "main") { 32351 if (!this.hls.audioTracks.length) { 32352 return CmObjectType.MUXED; 32353 } 32354 return CmObjectType.VIDEO; 32355 } 32356 return void 0; 32357 } 32358 /** 32359 * Get the highest bitrate. 32360 */ 32361 getTopBandwidth(type) { 32362 let bitrate = 0; 32363 let levels; 32364 const hls = this.hls; 32365 if (type === CmObjectType.AUDIO) { 32366 levels = hls.audioTracks; 32367 } else { 32368 const max = hls.maxAutoLevel; 32369 const len = max > -1 ? max + 1 : hls.levels.length; 32370 levels = hls.levels.slice(0, len); 32371 } 32372 for (const level of levels) { 32373 if (level.bitrate > bitrate) { 32374 bitrate = level.bitrate; 32375 } 32376 } 32377 return bitrate > 0 ? bitrate : NaN; 32378 } 32379 /** 32380 * Get the buffer length for a media type in milliseconds 32381 */ 32382 getBufferLength(type) { 32383 const media = this.hls.media; 32384 const buffer = type === CmObjectType.AUDIO ? this.audioBuffer : this.videoBuffer; 32385 if (!buffer || !media) { 32386 return NaN; 32387 } 32388 const info = BufferHelper.bufferInfo(buffer, media.currentTime, this.config.maxBufferHole); 32389 return info.len * 1e3; 32390 } 32391 /** 32392 * Create a playlist loader 32393 */ 32394 createPlaylistLoader() { 32395 const { 32396 pLoader 32397 } = this.config; 32398 const apply = this.applyPlaylistData; 32399 const Ctor = pLoader || this.config.loader; 32400 return class CmcdPlaylistLoader { 32401 constructor(config) { 32402 this.loader = void 0; 32403 this.loader = new Ctor(config); 32404 } 32405 get stats() { 32406 return this.loader.stats; 32407 } 32408 get context() { 32409 return this.loader.context; 32410 } 32411 destroy() { 32412 this.loader.destroy(); 32413 } 32414 abort() { 32415 this.loader.abort(); 32416 } 32417 load(context, config, callbacks) { 32418 apply(context); 32419 this.loader.load(context, config, callbacks); 32420 } 32421 }; 32422 } 32423 /** 32424 * Create a playlist loader 32425 */ 32426 createFragmentLoader() { 32427 const { 32428 fLoader 32429 } = this.config; 32430 const apply = this.applyFragmentData; 32431 const Ctor = fLoader || this.config.loader; 32432 return class CmcdFragmentLoader { 32433 constructor(config) { 32434 this.loader = void 0; 32435 this.loader = new Ctor(config); 32436 } 32437 get stats() { 32438 return this.loader.stats; 32439 } 32440 get context() { 32441 return this.loader.context; 32442 } 32443 destroy() { 32444 this.loader.destroy(); 32445 } 32446 abort() { 32447 this.loader.abort(); 32448 } 32449 load(context, config, callbacks) { 32450 apply(context); 32451 this.loader.load(context, config, callbacks); 32452 } 32453 }; 32454 } 32455}; 32456var PATHWAY_PENALTY_DURATION_MS = 3e5; 32457var ContentSteeringController = class { 32458 constructor(hls) { 32459 this.hls = void 0; 32460 this.log = void 0; 32461 this.loader = null; 32462 this.uri = null; 32463 this.pathwayId = "."; 32464 this.pathwayPriority = null; 32465 this.timeToLoad = 300; 32466 this.reloadTimer = -1; 32467 this.updated = 0; 32468 this.started = false; 32469 this.enabled = true; 32470 this.levels = null; 32471 this.audioTracks = null; 32472 this.subtitleTracks = null; 32473 this.penalizedPathways = {}; 32474 this.hls = hls; 32475 this.log = logger.log.bind(logger, `[content-steering]:`); 32476 this.registerListeners(); 32477 } 32478 registerListeners() { 32479 const hls = this.hls; 32480 hls.on(Events.MANIFEST_LOADING, this.onManifestLoading, this); 32481 hls.on(Events.MANIFEST_LOADED, this.onManifestLoaded, this); 32482 hls.on(Events.MANIFEST_PARSED, this.onManifestParsed, this); 32483 hls.on(Events.ERROR, this.onError, this); 32484 } 32485 unregisterListeners() { 32486 const hls = this.hls; 32487 if (!hls) { 32488 return; 32489 } 32490 hls.off(Events.MANIFEST_LOADING, this.onManifestLoading, this); 32491 hls.off(Events.MANIFEST_LOADED, this.onManifestLoaded, this); 32492 hls.off(Events.MANIFEST_PARSED, this.onManifestParsed, this); 32493 hls.off(Events.ERROR, this.onError, this); 32494 } 32495 startLoad() { 32496 this.started = true; 32497 this.clearTimeout(); 32498 if (this.enabled && this.uri) { 32499 if (this.updated) { 32500 const ttl = this.timeToLoad * 1e3 - (performance.now() - this.updated); 32501 if (ttl > 0) { 32502 this.scheduleRefresh(this.uri, ttl); 32503 return; 32504 } 32505 } 32506 this.loadSteeringManifest(this.uri); 32507 } 32508 } 32509 stopLoad() { 32510 this.started = false; 32511 if (this.loader) { 32512 this.loader.destroy(); 32513 this.loader = null; 32514 } 32515 this.clearTimeout(); 32516 } 32517 clearTimeout() { 32518 if (this.reloadTimer !== -1) { 32519 self.clearTimeout(this.reloadTimer); 32520 this.reloadTimer = -1; 32521 } 32522 } 32523 destroy() { 32524 this.unregisterListeners(); 32525 this.stopLoad(); 32526 this.hls = null; 32527 this.levels = this.audioTracks = this.subtitleTracks = null; 32528 } 32529 removeLevel(levelToRemove) { 32530 const levels = this.levels; 32531 if (levels) { 32532 this.levels = levels.filter((level) => level !== levelToRemove); 32533 } 32534 } 32535 onManifestLoading() { 32536 this.stopLoad(); 32537 this.enabled = true; 32538 this.timeToLoad = 300; 32539 this.updated = 0; 32540 this.uri = null; 32541 this.pathwayId = "."; 32542 this.levels = this.audioTracks = this.subtitleTracks = null; 32543 } 32544 onManifestLoaded(event, data) { 32545 const { 32546 contentSteering 32547 } = data; 32548 if (contentSteering === null) { 32549 return; 32550 } 32551 this.pathwayId = contentSteering.pathwayId; 32552 this.uri = contentSteering.uri; 32553 if (this.started) { 32554 this.startLoad(); 32555 } 32556 } 32557 onManifestParsed(event, data) { 32558 this.audioTracks = data.audioTracks; 32559 this.subtitleTracks = data.subtitleTracks; 32560 } 32561 onError(event, data) { 32562 const { 32563 errorAction 32564 } = data; 32565 if ((errorAction == null ? void 0 : errorAction.action) === NetworkErrorAction.SendAlternateToPenaltyBox && errorAction.flags === ErrorActionFlags.MoveAllAlternatesMatchingHost) { 32566 const levels = this.levels; 32567 let pathwayPriority = this.pathwayPriority; 32568 let errorPathway = this.pathwayId; 32569 if (data.context) { 32570 const { 32571 groupId, 32572 pathwayId, 32573 type 32574 } = data.context; 32575 if (groupId && levels) { 32576 errorPathway = this.getPathwayForGroupId(groupId, type, errorPathway); 32577 } else if (pathwayId) { 32578 errorPathway = pathwayId; 32579 } 32580 } 32581 if (!(errorPathway in this.penalizedPathways)) { 32582 this.penalizedPathways[errorPathway] = performance.now(); 32583 } 32584 if (!pathwayPriority && levels) { 32585 pathwayPriority = levels.reduce((pathways, level) => { 32586 if (pathways.indexOf(level.pathwayId) === -1) { 32587 pathways.push(level.pathwayId); 32588 } 32589 return pathways; 32590 }, []); 32591 } 32592 if (pathwayPriority && pathwayPriority.length > 1) { 32593 this.updatePathwayPriority(pathwayPriority); 32594 errorAction.resolved = this.pathwayId !== errorPathway; 32595 } 32596 if (!errorAction.resolved) { 32597 logger.warn(`Could not resolve ${data.details} ("${data.error.message}") with content-steering for Pathway: ${errorPathway} levels: ${levels ? levels.length : levels} priorities: ${JSON.stringify(pathwayPriority)} penalized: ${JSON.stringify(this.penalizedPathways)}`); 32598 } 32599 } 32600 } 32601 filterParsedLevels(levels) { 32602 this.levels = levels; 32603 let pathwayLevels = this.getLevelsForPathway(this.pathwayId); 32604 if (pathwayLevels.length === 0) { 32605 const pathwayId = levels[0].pathwayId; 32606 this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${pathwayId}"`); 32607 pathwayLevels = this.getLevelsForPathway(pathwayId); 32608 this.pathwayId = pathwayId; 32609 } 32610 if (pathwayLevels.length !== levels.length) { 32611 this.log(`Found ${pathwayLevels.length}/${levels.length} levels in Pathway "${this.pathwayId}"`); 32612 } 32613 return pathwayLevels; 32614 } 32615 getLevelsForPathway(pathwayId) { 32616 if (this.levels === null) { 32617 return []; 32618 } 32619 return this.levels.filter((level) => pathwayId === level.pathwayId); 32620 } 32621 updatePathwayPriority(pathwayPriority) { 32622 this.pathwayPriority = pathwayPriority; 32623 let levels; 32624 const penalizedPathways = this.penalizedPathways; 32625 const now2 = performance.now(); 32626 Object.keys(penalizedPathways).forEach((pathwayId) => { 32627 if (now2 - penalizedPathways[pathwayId] > PATHWAY_PENALTY_DURATION_MS) { 32628 delete penalizedPathways[pathwayId]; 32629 } 32630 }); 32631 for (let i3 = 0; i3 < pathwayPriority.length; i3++) { 32632 const pathwayId = pathwayPriority[i3]; 32633 if (pathwayId in penalizedPathways) { 32634 continue; 32635 } 32636 if (pathwayId === this.pathwayId) { 32637 return; 32638 } 32639 const selectedIndex = this.hls.nextLoadLevel; 32640 const selectedLevel = this.hls.levels[selectedIndex]; 32641 levels = this.getLevelsForPathway(pathwayId); 32642 if (levels.length > 0) { 32643 this.log(`Setting Pathway to "${pathwayId}"`); 32644 this.pathwayId = pathwayId; 32645 reassignFragmentLevelIndexes(levels); 32646 this.hls.trigger(Events.LEVELS_UPDATED, { 32647 levels 32648 }); 32649 const levelAfterChange = this.hls.levels[selectedIndex]; 32650 if (selectedLevel && levelAfterChange && this.levels) { 32651 if (levelAfterChange.attrs["STABLE-VARIANT-ID"] !== selectedLevel.attrs["STABLE-VARIANT-ID"] && levelAfterChange.bitrate !== selectedLevel.bitrate) { 32652 this.log(`Unstable Pathways change from bitrate ${selectedLevel.bitrate} to ${levelAfterChange.bitrate}`); 32653 } 32654 this.hls.nextLoadLevel = selectedIndex; 32655 } 32656 break; 32657 } 32658 } 32659 } 32660 getPathwayForGroupId(groupId, type, defaultPathway) { 32661 const levels = this.getLevelsForPathway(defaultPathway).concat(this.levels || []); 32662 for (let i3 = 0; i3 < levels.length; i3++) { 32663 if (type === PlaylistContextType.AUDIO_TRACK && levels[i3].hasAudioGroup(groupId) || type === PlaylistContextType.SUBTITLE_TRACK && levels[i3].hasSubtitleGroup(groupId)) { 32664 return levels[i3].pathwayId; 32665 } 32666 } 32667 return defaultPathway; 32668 } 32669 clonePathways(pathwayClones) { 32670 const levels = this.levels; 32671 if (!levels) { 32672 return; 32673 } 32674 const audioGroupCloneMap = {}; 32675 const subtitleGroupCloneMap = {};
vendor: 4,909 bytes, lines 32676-32800
32676 pathwayClones.forEach((pathwayClone) => { 32677 const { 32678 ID: cloneId, 32679 "BASE-ID": baseId, 32680 "URI-REPLACEMENT": uriReplacement 32681 } = pathwayClone; 32682 if (levels.some((level) => level.pathwayId === cloneId)) { 32683 return; 32684 } 32685 const clonedVariants = this.getLevelsForPathway(baseId).map((baseLevel) => { 32686 const attributes = new AttrList(baseLevel.attrs); 32687 attributes["PATHWAY-ID"] = cloneId; 32688 const clonedAudioGroupId = attributes.AUDIO && `${attributes.AUDIO}_clone_${cloneId}`; 32689 const clonedSubtitleGroupId = attributes.SUBTITLES && `${attributes.SUBTITLES}_clone_${cloneId}`; 32690 if (clonedAudioGroupId) { 32691 audioGroupCloneMap[attributes.AUDIO] = clonedAudioGroupId; 32692 attributes.AUDIO = clonedAudioGroupId; 32693 } 32694 if (clonedSubtitleGroupId) { 32695 subtitleGroupCloneMap[attributes.SUBTITLES] = clonedSubtitleGroupId; 32696 attributes.SUBTITLES = clonedSubtitleGroupId; 32697 } 32698 const url = performUriReplacement(baseLevel.uri, attributes["STABLE-VARIANT-ID"], "PER-VARIANT-URIS", uriReplacement); 32699 const clonedLevel = new Level({ 32700 attrs: attributes, 32701 audioCodec: baseLevel.audioCodec, 32702 bitrate: baseLevel.bitrate, 32703 height: baseLevel.height, 32704 name: baseLevel.name, 32705 url, 32706 videoCodec: baseLevel.videoCodec, 32707 width: baseLevel.width 32708 }); 32709 if (baseLevel.audioGroups) { 32710 for (let i3 = 1; i3 < baseLevel.audioGroups.length; i3++) { 32711 clonedLevel.addGroupId("audio", `${baseLevel.audioGroups[i3]}_clone_${cloneId}`); 32712 } 32713 } 32714 if (baseLevel.subtitleGroups) { 32715 for (let i3 = 1; i3 < baseLevel.subtitleGroups.length; i3++) { 32716 clonedLevel.addGroupId("text", `${baseLevel.subtitleGroups[i3]}_clone_${cloneId}`); 32717 } 32718 } 32719 return clonedLevel; 32720 }); 32721 levels.push(...clonedVariants); 32722 cloneRenditionGroups(this.audioTracks, audioGroupCloneMap, uriReplacement, cloneId); 32723 cloneRenditionGroups(this.subtitleTracks, subtitleGroupCloneMap, uriReplacement, cloneId); 32724 }); 32725 } 32726 loadSteeringManifest(uri) { 32727 const config = this.hls.config; 32728 const Loader2 = config.loader; 32729 if (this.loader) { 32730 this.loader.destroy(); 32731 } 32732 this.loader = new Loader2(config); 32733 let url; 32734 try { 32735 url = new self.URL(uri); 32736 } catch (error) { 32737 this.enabled = false; 32738 this.log(`Failed to parse Steering Manifest URI: ${uri}`); 32739 return; 32740 } 32741 if (url.protocol !== "data:") { 32742 const throughput = (this.hls.bandwidthEstimate || config.abrEwmaDefaultEstimate) | 0; 32743 url.searchParams.set("_HLS_pathway", this.pathwayId); 32744 url.searchParams.set("_HLS_throughput", "" + throughput); 32745 } 32746 const context = { 32747 responseType: "json", 32748 url: url.href 32749 }; 32750 const loadPolicy = config.steeringManifestLoadPolicy.default; 32751 const legacyRetryCompatibility = loadPolicy.errorRetry || loadPolicy.timeoutRetry || {}; 32752 const loaderConfig = { 32753 loadPolicy, 32754 timeout: loadPolicy.maxLoadTimeMs, 32755 maxRetry: legacyRetryCompatibility.maxNumRetry || 0, 32756 retryDelay: legacyRetryCompatibility.retryDelayMs || 0, 32757 maxRetryDelay: legacyRetryCompatibility.maxRetryDelayMs || 0 32758 }; 32759 const callbacks = { 32760 onSuccess: (response, stats, context2, networkDetails) => { 32761 this.log(`Loaded steering manifest: "${url}"`); 32762 const steeringData = response.data; 32763 if (steeringData.VERSION !== 1) { 32764 this.log(`Steering VERSION ${steeringData.VERSION} not supported!`); 32765 return; 32766 } 32767 this.updated = performance.now(); 32768 this.timeToLoad = steeringData.TTL; 32769 const { 32770 "RELOAD-URI": reloadUri, 32771 "PATHWAY-CLONES": pathwayClones, 32772 "PATHWAY-PRIORITY": pathwayPriority 32773 } = steeringData; 32774 if (reloadUri) { 32775 try { 32776 this.uri = new self.URL(reloadUri, url).href; 32777 } catch (error) { 32778 this.enabled = false; 32779 this.log(`Failed to parse Steering Manifest RELOAD-URI: ${reloadUri}`); 32780 return; 32781 } 32782 } 32783 this.scheduleRefresh(this.uri || context2.url); 32784 if (pathwayClones) { 32785 this.clonePathways(pathwayClones); 32786 } 32787 const loadedSteeringData = { 32788 steeringManifest: steeringData, 32789 url: url.toString() 32790 }; 32791 this.hls.trigger(Events.STEERING_MANIFEST_LOADED, loadedSteeringData); 32792 if (pathwayPriority) { 32793 this.updatePathwayPriority(pathwayPriority); 32794 } 32795 }, 32796 onError: (error, context2, networkDetails, stats) => { 32797 this.log(`Error loading steering manifest: ${error.code} ${error.text} (${context2.url})`); 32798 this.stopLoad(); 32799 if (error.code === 410) { 32800 this.enabled = false;
vendor: 4,580 bytes, lines 32801-32948
32801 this.log(`Steering manifest ${context2.url} no longer available`); 32802 return; 32803 } 32804 let ttl = this.timeToLoad * 1e3; 32805 if (error.code === 429) { 32806 const loader = this.loader; 32807 if (typeof (loader == null ? void 0 : loader.getResponseHeader) === "function") { 32808 const retryAfter = loader.getResponseHeader("Retry-After"); 32809 if (retryAfter) { 32810 ttl = parseFloat(retryAfter) * 1e3; 32811 } 32812 } 32813 this.log(`Steering manifest ${context2.url} rate limited`); 32814 return; 32815 } 32816 this.scheduleRefresh(this.uri || context2.url, ttl); 32817 }, 32818 onTimeout: (stats, context2, networkDetails) => { 32819 this.log(`Timeout loading steering manifest (${context2.url})`); 32820 this.scheduleRefresh(this.uri || context2.url); 32821 } 32822 }; 32823 this.log(`Requesting steering manifest: ${url}`); 32824 this.loader.load(context, loaderConfig, callbacks); 32825 } 32826 scheduleRefresh(uri, ttlMs = this.timeToLoad * 1e3) { 32827 this.clearTimeout(); 32828 this.reloadTimer = self.setTimeout(() => { 32829 var _this$hls; 32830 const media = (_this$hls = this.hls) == null ? void 0 : _this$hls.media; 32831 if (media && !media.ended) { 32832 this.loadSteeringManifest(uri); 32833 return; 32834 } 32835 this.scheduleRefresh(uri, this.timeToLoad * 1e3); 32836 }, ttlMs); 32837 } 32838}; 32839function cloneRenditionGroups(tracks, groupCloneMap, uriReplacement, cloneId) { 32840 if (!tracks) { 32841 return; 32842 } 32843 Object.keys(groupCloneMap).forEach((audioGroupId) => { 32844 const clonedTracks = tracks.filter((track) => track.groupId === audioGroupId).map((track) => { 32845 const clonedTrack = _extends2({}, track); 32846 clonedTrack.details = void 0; 32847 clonedTrack.attrs = new AttrList(clonedTrack.attrs); 32848 clonedTrack.url = clonedTrack.attrs.URI = performUriReplacement(track.url, track.attrs["STABLE-RENDITION-ID"], "PER-RENDITION-URIS", uriReplacement); 32849 clonedTrack.groupId = clonedTrack.attrs["GROUP-ID"] = groupCloneMap[audioGroupId]; 32850 clonedTrack.attrs["PATHWAY-ID"] = cloneId; 32851 return clonedTrack; 32852 }); 32853 tracks.push(...clonedTracks); 32854 }); 32855} 32856function performUriReplacement(uri, stableId, perOptionKey, uriReplacement) { 32857 const { 32858 HOST: host, 32859 PARAMS: params, 32860 [perOptionKey]: perOptionUris 32861 } = uriReplacement; 32862 let perVariantUri; 32863 if (stableId) { 32864 perVariantUri = perOptionUris == null ? void 0 : perOptionUris[stableId]; 32865 if (perVariantUri) { 32866 uri = perVariantUri; 32867 } 32868 } 32869 const url = new self.URL(uri); 32870 if (host && !perVariantUri) { 32871 url.host = host; 32872 } 32873 if (params) { 32874 Object.keys(params).sort().forEach((key) => { 32875 if (key) { 32876 url.searchParams.set(key, params[key]); 32877 } 32878 }); 32879 } 32880 return url.href; 32881} 32882var AGE_HEADER_LINE_REGEX = /^age:\s*[\d.]+\s*$/im; 32883var XhrLoader = class { 32884 constructor(config) { 32885 this.xhrSetup = void 0; 32886 this.requestTimeout = void 0; 32887 this.retryTimeout = void 0; 32888 this.retryDelay = void 0; 32889 this.config = null; 32890 this.callbacks = null; 32891 this.context = null; 32892 this.loader = null; 32893 this.stats = void 0; 32894 this.xhrSetup = config ? config.xhrSetup || null : null; 32895 this.stats = new LoadStats(); 32896 this.retryDelay = 0; 32897 } 32898 destroy() { 32899 this.callbacks = null; 32900 this.abortInternal(); 32901 this.loader = null; 32902 this.config = null; 32903 this.context = null; 32904 this.xhrSetup = null; 32905 } 32906 abortInternal() { 32907 const loader = this.loader; 32908 self.clearTimeout(this.requestTimeout); 32909 self.clearTimeout(this.retryTimeout); 32910 if (loader) { 32911 loader.onreadystatechange = null; 32912 loader.onprogress = null; 32913 if (loader.readyState !== 4) { 32914 this.stats.aborted = true; 32915 loader.abort(); 32916 } 32917 } 32918 } 32919 abort() { 32920 var _this$callbacks; 32921 this.abortInternal(); 32922 if ((_this$callbacks = this.callbacks) != null && _this$callbacks.onAbort) { 32923 this.callbacks.onAbort(this.stats, this.context, this.loader); 32924 } 32925 } 32926 load(context, config, callbacks) { 32927 if (this.stats.loading.start) { 32928 throw new Error("Loader can only be used once."); 32929 } 32930 this.stats.loading.start = self.performance.now(); 32931 this.context = context; 32932 this.config = config; 32933 this.callbacks = callbacks; 32934 this.loadInternal(); 32935 } 32936 loadInternal() { 32937 const { 32938 config, 32939 context 32940 } = this; 32941 if (!config || !context) { 32942 return; 32943 } 32944 const xhr = this.loader = new self.XMLHttpRequest(); 32945 const stats = this.stats; 32946 stats.loading.first = 0; 32947 stats.loaded = 0; 32948 stats.aborted = false;
vendor: 6,321 bytes, lines 32949-33133
32949 const xhrSetup = this.xhrSetup; 32950 if (xhrSetup) { 32951 Promise.resolve().then(() => { 32952 if (this.loader !== xhr || this.stats.aborted) return; 32953 return xhrSetup(xhr, context.url); 32954 }).catch((error) => { 32955 if (this.loader !== xhr || this.stats.aborted) return; 32956 xhr.open("GET", context.url, true); 32957 return xhrSetup(xhr, context.url); 32958 }).then(() => { 32959 if (this.loader !== xhr || this.stats.aborted) return; 32960 this.openAndSendXhr(xhr, context, config); 32961 }).catch((error) => { 32962 this.callbacks.onError({ 32963 code: xhr.status, 32964 text: error.message 32965 }, context, xhr, stats); 32966 return; 32967 }); 32968 } else { 32969 this.openAndSendXhr(xhr, context, config); 32970 } 32971 } 32972 openAndSendXhr(xhr, context, config) { 32973 if (!xhr.readyState) { 32974 xhr.open("GET", context.url, true); 32975 } 32976 const headers = context.headers; 32977 const { 32978 maxTimeToFirstByteMs, 32979 maxLoadTimeMs 32980 } = config.loadPolicy; 32981 if (headers) { 32982 for (const header in headers) { 32983 xhr.setRequestHeader(header, headers[header]); 32984 } 32985 } 32986 if (context.rangeEnd) { 32987 xhr.setRequestHeader("Range", "bytes=" + context.rangeStart + "-" + (context.rangeEnd - 1)); 32988 } 32989 xhr.onreadystatechange = this.readystatechange.bind(this); 32990 xhr.onprogress = this.loadprogress.bind(this); 32991 xhr.responseType = context.responseType; 32992 self.clearTimeout(this.requestTimeout); 32993 config.timeout = maxTimeToFirstByteMs && isFiniteNumber(maxTimeToFirstByteMs) ? maxTimeToFirstByteMs : maxLoadTimeMs; 32994 this.requestTimeout = self.setTimeout(this.loadtimeout.bind(this), config.timeout); 32995 xhr.send(); 32996 } 32997 readystatechange() { 32998 const { 32999 context, 33000 loader: xhr, 33001 stats 33002 } = this; 33003 if (!context || !xhr) { 33004 return; 33005 } 33006 const readyState = xhr.readyState; 33007 const config = this.config; 33008 if (stats.aborted) { 33009 return; 33010 } 33011 if (readyState >= 2) { 33012 if (stats.loading.first === 0) { 33013 stats.loading.first = Math.max(self.performance.now(), stats.loading.start); 33014 if (config.timeout !== config.loadPolicy.maxLoadTimeMs) { 33015 self.clearTimeout(this.requestTimeout); 33016 config.timeout = config.loadPolicy.maxLoadTimeMs; 33017 this.requestTimeout = self.setTimeout(this.loadtimeout.bind(this), config.loadPolicy.maxLoadTimeMs - (stats.loading.first - stats.loading.start)); 33018 } 33019 } 33020 if (readyState === 4) { 33021 self.clearTimeout(this.requestTimeout); 33022 xhr.onreadystatechange = null; 33023 xhr.onprogress = null; 33024 const status2 = xhr.status; 33025 const useResponseText = xhr.responseType === "text" ? xhr.responseText : null; 33026 if (status2 >= 200 && status2 < 300) { 33027 const data = useResponseText != null ? useResponseText : xhr.response; 33028 if (data != null) { 33029 stats.loading.end = Math.max(self.performance.now(), stats.loading.first); 33030 const len = xhr.responseType === "arraybuffer" ? data.byteLength : data.length; 33031 stats.loaded = stats.total = len; 33032 stats.bwEstimate = stats.total * 8e3 / (stats.loading.end - stats.loading.first); 33033 if (!this.callbacks) { 33034 return; 33035 } 33036 const onProgress = this.callbacks.onProgress; 33037 if (onProgress) { 33038 onProgress(stats, context, data, xhr); 33039 } 33040 if (!this.callbacks) { 33041 return; 33042 } 33043 const _response = { 33044 url: xhr.responseURL, 33045 data, 33046 code: status2 33047 }; 33048 this.callbacks.onSuccess(_response, stats, context, xhr); 33049 return; 33050 } 33051 } 33052 const retryConfig = config.loadPolicy.errorRetry; 33053 const retryCount = stats.retry; 33054 const response = { 33055 url: context.url, 33056 data: void 0, 33057 code: status2 33058 }; 33059 if (shouldRetry(retryConfig, retryCount, false, response)) { 33060 this.retry(retryConfig); 33061 } else { 33062 logger.error(`${status2} while loading ${context.url}`); 33063 this.callbacks.onError({ 33064 code: status2, 33065 text: xhr.statusText 33066 }, context, xhr, stats); 33067 } 33068 } 33069 } 33070 } 33071 loadtimeout() { 33072 if (!this.config) return; 33073 const retryConfig = this.config.loadPolicy.timeoutRetry; 33074 const retryCount = this.stats.retry; 33075 if (shouldRetry(retryConfig, retryCount, true)) { 33076 this.retry(retryConfig); 33077 } else { 33078 var _this$context; 33079 logger.warn(`timeout while loading ${(_this$context = this.context) == null ? void 0 : _this$context.url}`); 33080 const callbacks = this.callbacks; 33081 if (callbacks) { 33082 this.abortInternal(); 33083 callbacks.onTimeout(this.stats, this.context, this.loader); 33084 } 33085 } 33086 } 33087 retry(retryConfig) { 33088 const { 33089 context, 33090 stats 33091 } = this; 33092 this.retryDelay = getRetryDelay(retryConfig, stats.retry); 33093 stats.retry++; 33094 logger.warn(`${status ? "HTTP Status " + status : "Timeout"} while loading ${context == null ? void 0 : context.url}, retrying ${stats.retry}/${retryConfig.maxNumRetry} in ${this.retryDelay}ms`); 33095 this.abortInternal(); 33096 this.loader = null; 33097 self.clearTimeout(this.retryTimeout); 33098 this.retryTimeout = self.setTimeout(this.loadInternal.bind(this), this.retryDelay); 33099 } 33100 loadprogress(event) { 33101 const stats = this.stats; 33102 stats.loaded = event.loaded; 33103 if (event.lengthComputable) { 33104 stats.total = event.total; 33105 } 33106 } 33107 getCacheAge() { 33108 let result = null; 33109 if (this.loader && AGE_HEADER_LINE_REGEX.test(this.loader.getAllResponseHeaders())) { 33110 const ageHeader = this.loader.getResponseHeader("age"); 33111 result = ageHeader ? parseFloat(ageHeader) : null; 33112 } 33113 return result; 33114 } 33115 getResponseHeader(name) { 33116 if (this.loader && new RegExp(`^${name}:\\s*[\\d.]+\\s*$`, "im").test(this.loader.getAllResponseHeaders())) { 33117 return this.loader.getResponseHeader(name); 33118 } 33119 return null; 33120 } 33121}; 33122function fetchSupported() { 33123 if ( 33124 // @ts-ignore 33125 self.fetch && self.AbortController && self.ReadableStream && self.Request 33126 ) { 33127 try { 33128 new self.ReadableStream({}); 33129 return true; 33130 } catch (e) { 33131 } 33132 } 33133 return false;
vendor: 6,514 bytes, lines 33134-33328
33134} 33135var BYTERANGE = /(\d+)-(\d+)\/(\d+)/; 33136var FetchLoader = class { 33137 constructor(config) { 33138 this.fetchSetup = void 0; 33139 this.requestTimeout = void 0; 33140 this.request = null; 33141 this.response = null; 33142 this.controller = void 0; 33143 this.context = null; 33144 this.config = null; 33145 this.callbacks = null; 33146 this.stats = void 0; 33147 this.loader = null; 33148 this.fetchSetup = config.fetchSetup || getRequest; 33149 this.controller = new self.AbortController(); 33150 this.stats = new LoadStats(); 33151 } 33152 destroy() { 33153 this.loader = this.callbacks = this.context = this.config = this.request = null; 33154 this.abortInternal(); 33155 this.response = null; 33156 this.fetchSetup = this.controller = this.stats = null; 33157 } 33158 abortInternal() { 33159 if (this.controller && !this.stats.loading.end) { 33160 this.stats.aborted = true; 33161 this.controller.abort(); 33162 } 33163 } 33164 abort() { 33165 var _this$callbacks; 33166 this.abortInternal(); 33167 if ((_this$callbacks = this.callbacks) != null && _this$callbacks.onAbort) { 33168 this.callbacks.onAbort(this.stats, this.context, this.response); 33169 } 33170 } 33171 load(context, config, callbacks) { 33172 const stats = this.stats; 33173 if (stats.loading.start) { 33174 throw new Error("Loader can only be used once."); 33175 } 33176 stats.loading.start = self.performance.now(); 33177 const initParams = getRequestParameters(context, this.controller.signal); 33178 const onProgress = callbacks.onProgress; 33179 const isArrayBuffer = context.responseType === "arraybuffer"; 33180 const LENGTH = isArrayBuffer ? "byteLength" : "length"; 33181 const { 33182 maxTimeToFirstByteMs, 33183 maxLoadTimeMs 33184 } = config.loadPolicy; 33185 this.context = context; 33186 this.config = config; 33187 this.callbacks = callbacks; 33188 this.request = this.fetchSetup(context, initParams); 33189 self.clearTimeout(this.requestTimeout); 33190 config.timeout = maxTimeToFirstByteMs && isFiniteNumber(maxTimeToFirstByteMs) ? maxTimeToFirstByteMs : maxLoadTimeMs; 33191 this.requestTimeout = self.setTimeout(() => { 33192 this.abortInternal(); 33193 callbacks.onTimeout(stats, context, this.response); 33194 }, config.timeout); 33195 self.fetch(this.request).then((response) => { 33196 this.response = this.loader = response; 33197 const first = Math.max(self.performance.now(), stats.loading.start); 33198 self.clearTimeout(this.requestTimeout); 33199 config.timeout = maxLoadTimeMs; 33200 this.requestTimeout = self.setTimeout(() => { 33201 this.abortInternal(); 33202 callbacks.onTimeout(stats, context, this.response); 33203 }, maxLoadTimeMs - (first - stats.loading.start)); 33204 if (!response.ok) { 33205 const { 33206 status: status2, 33207 statusText 33208 } = response; 33209 throw new FetchError(statusText || "fetch, bad network response", status2, response); 33210 } 33211 stats.loading.first = first; 33212 stats.total = getContentLength(response.headers) || stats.total; 33213 if (onProgress && isFiniteNumber(config.highWaterMark)) { 33214 return this.loadProgressively(response, stats, context, config.highWaterMark, onProgress); 33215 } 33216 if (isArrayBuffer) { 33217 return response.arrayBuffer(); 33218 } 33219 if (context.responseType === "json") { 33220 return response.json(); 33221 } 33222 return response.text(); 33223 }).then((responseData) => { 33224 const response = this.response; 33225 if (!response) { 33226 throw new Error("loader destroyed"); 33227 } 33228 self.clearTimeout(this.requestTimeout); 33229 stats.loading.end = Math.max(self.performance.now(), stats.loading.first); 33230 const total = responseData[LENGTH]; 33231 if (total) { 33232 stats.loaded = stats.total = total; 33233 } 33234 const loaderResponse = { 33235 url: response.url, 33236 data: responseData, 33237 code: response.status 33238 }; 33239 if (onProgress && !isFiniteNumber(config.highWaterMark)) { 33240 onProgress(stats, context, responseData, response); 33241 } 33242 callbacks.onSuccess(loaderResponse, stats, context, response); 33243 }).catch((error) => { 33244 self.clearTimeout(this.requestTimeout); 33245 if (stats.aborted) { 33246 return; 33247 } 33248 const code = !error ? 0 : error.code || 0; 33249 const text = !error ? null : error.message; 33250 callbacks.onError({ 33251 code, 33252 text 33253 }, context, error ? error.details : null, stats); 33254 }); 33255 } 33256 getCacheAge() { 33257 let result = null; 33258 if (this.response) { 33259 const ageHeader = this.response.headers.get("age"); 33260 result = ageHeader ? parseFloat(ageHeader) : null; 33261 } 33262 return result; 33263 } 33264 getResponseHeader(name) { 33265 return this.response ? this.response.headers.get(name) : null; 33266 } 33267 loadProgressively(response, stats, context, highWaterMark = 0, onProgress) { 33268 const chunkCache = new ChunkCache(); 33269 const reader = response.body.getReader(); 33270 const pump = () => { 33271 return reader.read().then((data) => { 33272 if (data.done) { 33273 if (chunkCache.dataLength) { 33274 onProgress(stats, context, chunkCache.flush(), response); 33275 } 33276 return Promise.resolve(new ArrayBuffer(0)); 33277 } 33278 const chunk = data.value; 33279 const len = chunk.length; 33280 stats.loaded += len; 33281 if (len < highWaterMark || chunkCache.dataLength) { 33282 chunkCache.push(chunk); 33283 if (chunkCache.dataLength >= highWaterMark) { 33284 onProgress(stats, context, chunkCache.flush(), response); 33285 } 33286 } else { 33287 onProgress(stats, context, chunk, response); 33288 } 33289 return pump(); 33290 }).catch(() => { 33291 return Promise.reject(); 33292 }); 33293 }; 33294 return pump(); 33295 } 33296}; 33297function getRequestParameters(context, signal) { 33298 const initParams = { 33299 method: "GET", 33300 mode: "cors", 33301 credentials: "same-origin", 33302 signal, 33303 headers: new self.Headers(_extends2({}, context.headers)) 33304 }; 33305 if (context.rangeEnd) { 33306 initParams.headers.set("Range", "bytes=" + context.rangeStart + "-" + String(context.rangeEnd - 1)); 33307 } 33308 return initParams; 33309} 33310function getByteRangeLength(byteRangeHeader) { 33311 const result = BYTERANGE.exec(byteRangeHeader); 33312 if (result) { 33313 return parseInt(result[2]) - parseInt(result[1]) + 1; 33314 } 33315} 33316function getContentLength(headers) { 33317 const contentRange = headers.get("Content-Range"); 33318 if (contentRange) { 33319 const byteRangeLength = getByteRangeLength(contentRange); 33320 if (isFiniteNumber(byteRangeLength)) { 33321 return byteRangeLength; 33322 } 33323 } 33324 const contentLength = headers.get("Content-Length"); 33325 if (contentLength) { 33326 return parseInt(contentLength); 33327 } 33328}
33329function getRequest(context, initParams) { 33330 return new self.Request(context.url, initParams); 33331} 33332var FetchError = class extends Error { 33333 constructor(message, code, details) { 33334 super(message); 33335 this.code = void 0; 33336 this.details = void 0; 33337 this.code = code; 33338 this.details = details; 33339 } 33340}; 33341var WHITESPACE_CHAR = /\s/; 33342var Cues = { 33343 newCue(track, startTime, endTime, captionScreen) { 33344 const result = []; 33345 let row; 33346 let cue; 33347 let indenting; 33348 let indent; 33349 let text; 33350 const Cue = self.VTTCue || self.TextTrackCue; 33351 for (let r10 = 0; r10 < captionScreen.rows.length; r10++) { 33352 row = captionScreen.rows[r10]; 33353 indenting = true; 33354 indent = 0; 33355 text = ""; 33356 if (!row.isEmpty()) { 33357 var _track$cues; 33358 for (let c3 = 0; c3 < row.chars.length; c3++) { 33359 if (WHITESPACE_CHAR.test(row.chars[c3].uchar) && indenting) { 33360 indent++; 33361 } else { 33362 text += row.chars[c3].uchar; 33363 indenting = false; 33364 } 33365 } 33366 row.cueStartTime = startTime; 33367 if (startTime === endTime) { 33368 endTime += 1e-4; 33369 } 33370 if (indent >= 16) { 33371 indent--; 33372 } else { 33373 indent++; 33374 } 33375 const cueText = fixLineBreaks(text.trim()); 33376 const id = generateCueId(startTime, endTime, cueText); 33377 if (!(track != null && (_track$cues = track.cues) != null && _track$cues.getCueById(id))) { 33378 cue = new Cue(startTime, endTime, cueText); 33379 cue.id = id; 33380 cue.line = r10 + 1; 33381 cue.align = "left"; 33382 cue.position = 10 + Math.min(80, Math.floor(indent * 8 / 32) * 10); 33383 result.push(cue); 33384 } 33385 } 33386 } 33387 if (track && result.length) { 33388 result.sort((cueA, cueB) => { 33389 if (cueA.line === "auto" || cueB.line === "auto") { 33390 return 0; 33391 } 33392 if (cueA.line > 8 && cueB.line > 8) { 33393 return cueB.line - cueA.line; 33394 } 33395 return cueA.line - cueB.line; 33396 }); 33397 result.forEach((cue2) => addCueToTrack(track, cue2)); 33398 } 33399 return result; 33400 } 33401}; 33402var defaultLoadPolicy = { 33403 maxTimeToFirstByteMs: 8e3, 33404 maxLoadTimeMs: 2e4, 33405 timeoutRetry: null, 33406 errorRetry: null 33407}; 33408var hlsDefaultConfig = _objectSpread23(_objectSpread23({ 33409 autoStartLoad: true, 33410 // used by stream-controller 33411 startPosition: -1, 33412 // used by stream-controller 33413 defaultAudioCodec: void 0, 33414 // used by stream-controller 33415 debug: false, 33416 // used by logger 33417 capLevelOnFPSDrop: false, 33418 // used by fps-controller 33419 capLevelToPlayerSize: false, 33420 // used by cap-level-controller 33421 ignoreDevicePixelRatio: false, 33422 // used by cap-level-controller 33423 preferManagedMediaSource: true, 33424 initialLiveManifestSize: 1, 33425 // used by stream-controller 33426 maxBufferLength: 30, 33427 // used by stream-controller 33428 backBufferLength: Infinity, 33429 // used by buffer-controller 33430 frontBufferFlushThreshold: Infinity, 33431 maxBufferSize: 60 * 1e3 * 1e3, 33432 // used by stream-controller 33433 maxBufferHole: 0.1, 33434 // used by stream-controller 33435 highBufferWatchdogPeriod: 2, 33436 // used by stream-controller 33437 nudgeOffset: 0.1, 33438 // used by stream-controller 33439 nudgeMaxRetry: 3, 33440 // used by stream-controller 33441 maxFragLookUpTolerance: 0.25, 33442 // used by stream-controller 33443 liveSyncDurationCount: 3, 33444 // used by latency-controller 33445 liveMaxLatencyDurationCount: Infinity, 33446 // used by latency-controller 33447 liveSyncDuration: void 0, 33448 // used by latency-controller 33449 liveMaxLatencyDuration: void 0, 33450 // used by latency-controller 33451 maxLiveSyncPlaybackRate: 1, 33452 // used by latency-controller 33453 liveDurationInfinity: false, 33454 // used by buffer-controller 33455 /** 33456 * @deprecated use backBufferLength 33457 */ 33458 liveBackBufferLength: null, 33459 // used by buffer-controller 33460 maxMaxBufferLength: 600, 33461 // used by stream-controller 33462 enableWorker: true, 33463 // used by transmuxer 33464 workerPath: null, 33465 // used by transmuxer 33466 enableSoftwareAES: true, 33467 // used by decrypter 33468 startLevel: void 0, 33469 // used by level-controller 33470 startFragPrefetch: false, 33471 // used by stream-controller 33472 fpsDroppedMonitoringPeriod: 5e3, 33473 // used by fps-controller 33474 fpsDroppedMonitoringThreshold: 0.2, 33475 // used by fps-controller 33476 appendErrorMaxRetry: 3, 33477 // used by buffer-controller 33478 loader: XhrLoader, 33479 // loader: FetchLoader, 33480 fLoader: void 0, 33481 // used by fragment-loader 33482 pLoader: void 0, 33483 // used by playlist-loader 33484 xhrSetup: void 0, 33485 // used by xhr-loader 33486 licenseXhrSetup: void 0, 33487 // used by eme-controller 33488 licenseResponseCallback: void 0, 33489 // used by eme-controller 33490 abrController: AbrController, 33491 bufferController: BufferController, 33492 capLevelController: CapLevelController, 33493 errorController: ErrorController, 33494 fpsController: FPSController, 33495 stretchShortVideoTrack: false, 33496 // used by mp4-remuxer 33497 maxAudioFramesDrift: 1, 33498 // used by mp4-remuxer 33499 forceKeyFrameOnDiscontinuity: true, 33500 // used by ts-demuxer 33501 abrEwmaFastLive: 3, 33502 // used by abr-controller 33503 abrEwmaSlowLive: 9, 33504 // used by abr-controller 33505 abrEwmaFastVoD: 3, 33506 // used by abr-controller 33507 abrEwmaSlowVoD: 9, 33508 // used by abr-controller 33509 abrEwmaDefaultEstimate: 5e5, 33510 // 500 kbps // used by abr-controller 33511 abrEwmaDefaultEstimateMax: 5e6, 33512 // 5 mbps 33513 abrBandWidthFactor: 0.95, 33514 // used by abr-controller 33515 abrBandWidthUpFactor: 0.7, 33516 // used by abr-controller
33517 abrMaxWithRealBitrate: false, 33518 // used by abr-controller 33519 maxStarvationDelay: 4, 33520 // used by abr-controller 33521 maxLoadingDelay: 4, 33522 // used by abr-controller 33523 minAutoBitrate: 0, 33524 // used by hls 33525 emeEnabled: false, 33526 // used by eme-controller 33527 widevineLicenseUrl: void 0, 33528 // used by eme-controller 33529 drmSystems: {}, 33530 // used by eme-controller 33531 drmSystemOptions: {}, 33532 // used by eme-controller 33533 requestMediaKeySystemAccessFunc: requestMediaKeySystemAccess, 33534 // used by eme-controller 33535 testBandwidth: true, 33536 progressive: false, 33537 lowLatencyMode: true, 33538 cmcd: void 0, 33539 enableDateRangeMetadataCues: true, 33540 enableEmsgMetadataCues: true, 33541 enableID3MetadataCues: true, 33542 useMediaCapabilities: true, 33543 certLoadPolicy: { 33544 default: defaultLoadPolicy 33545 }, 33546 keyLoadPolicy: { 33547 default: { 33548 maxTimeToFirstByteMs: 8e3, 33549 maxLoadTimeMs: 2e4, 33550 timeoutRetry: { 33551 maxNumRetry: 1, 33552 retryDelayMs: 1e3, 33553 maxRetryDelayMs: 2e4, 33554 backoff: "linear" 33555 }, 33556 errorRetry: { 33557 maxNumRetry: 8, 33558 retryDelayMs: 1e3, 33559 maxRetryDelayMs: 2e4, 33560 backoff: "linear" 33561 } 33562 } 33563 }, 33564 manifestLoadPolicy: { 33565 default: { 33566 maxTimeToFirstByteMs: Infinity, 33567 maxLoadTimeMs: 2e4, 33568 timeoutRetry: { 33569 maxNumRetry: 2, 33570 retryDelayMs: 0, 33571 maxRetryDelayMs: 0 33572 }, 33573 errorRetry: { 33574 maxNumRetry: 1, 33575 retryDelayMs: 1e3, 33576 maxRetryDelayMs: 8e3 33577 } 33578 } 33579 }, 33580 playlistLoadPolicy: { 33581 default: { 33582 maxTimeToFirstByteMs: 1e4, 33583 maxLoadTimeMs: 2e4, 33584 timeoutRetry: { 33585 maxNumRetry: 2, 33586 retryDelayMs: 0, 33587 maxRetryDelayMs: 0 33588 }, 33589 errorRetry: { 33590 maxNumRetry: 2, 33591 retryDelayMs: 1e3, 33592 maxRetryDelayMs: 8e3 33593 } 33594 } 33595 }, 33596 fragLoadPolicy: { 33597 default: { 33598 maxTimeToFirstByteMs: 1e4, 33599 maxLoadTimeMs: 12e4, 33600 timeoutRetry: { 33601 maxNumRetry: 4, 33602 retryDelayMs: 0, 33603 maxRetryDelayMs: 0 33604 }, 33605 errorRetry: { 33606 maxNumRetry: 6, 33607 retryDelayMs: 1e3, 33608 maxRetryDelayMs: 8e3 33609 } 33610 } 33611 }, 33612 steeringManifestLoadPolicy: { 33613 default: { 33614 maxTimeToFirstByteMs: 1e4, 33615 maxLoadTimeMs: 2e4, 33616 timeoutRetry: { 33617 maxNumRetry: 2, 33618 retryDelayMs: 0, 33619 maxRetryDelayMs: 0 33620 }, 33621 errorRetry: { 33622 maxNumRetry: 1, 33623 retryDelayMs: 1e3, 33624 maxRetryDelayMs: 8e3 33625 } 33626 } 33627 },
33628 // These default settings are deprecated in favor of the above policies 33629 // and are maintained for backwards compatibility 33630 manifestLoadingTimeOut: 1e4, 33631 manifestLoadingMaxRetry: 1, 33632 manifestLoadingRetryDelay: 1e3, 33633 manifestLoadingMaxRetryTimeout: 64e3, 33634 levelLoadingTimeOut: 1e4, 33635 levelLoadingMaxRetry: 4, 33636 levelLoadingRetryDelay: 1e3, 33637 levelLoadingMaxRetryTimeout: 64e3, 33638 fragLoadingTimeOut: 2e4, 33639 fragLoadingMaxRetry: 6, 33640 fragLoadingRetryDelay: 1e3, 33641 fragLoadingMaxRetryTimeout: 64e3 33642}, timelineConfig()), {}, { 33643 subtitleStreamController: SubtitleStreamController, 33644 subtitleTrackController: SubtitleTrackController, 33645 timelineController: TimelineController, 33646 audioStreamController: AudioStreamController, 33647 audioTrackController: AudioTrackController, 33648 emeController: EMEController, 33649 cmcdController: CMCDController, 33650 contentSteeringController: ContentSteeringController 33651}); 33652function timelineConfig() { 33653 return { 33654 cueHandler: Cues, 33655 // used by timeline-controller 33656 enableWebVTT: true, 33657 // used by timeline-controller 33658 enableIMSC1: true, 33659 // used by timeline-controller 33660 enableCEA708Captions: true, 33661 // used by timeline-controller 33662 captionsTextTrack1Label: "English", 33663 // used by timeline-controller 33664 captionsTextTrack1LanguageCode: "en", 33665 // used by timeline-controller 33666 captionsTextTrack2Label: "Spanish", 33667 // used by timeline-controller 33668 captionsTextTrack2LanguageCode: "es", 33669 // used by timeline-controller 33670 captionsTextTrack3Label: "Unknown CC", 33671 // used by timeline-controller 33672 captionsTextTrack3LanguageCode: "", 33673 // used by timeline-controller 33674 captionsTextTrack4Label: "Unknown CC", 33675 // used by timeline-controller 33676 captionsTextTrack4LanguageCode: "", 33677 // used by timeline-controller 33678 renderTextTracksNatively: true 33679 }; 33680} 33681function mergeConfig(defaultConfig, userConfig) { 33682 if ((userConfig.liveSyncDurationCount || userConfig.liveMaxLatencyDurationCount) && (userConfig.liveSyncDuration || userConfig.liveMaxLatencyDuration)) { 33683 throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration"); 33684 } 33685 if (userConfig.liveMaxLatencyDurationCount !== void 0 && (userConfig.liveSyncDurationCount === void 0 || userConfig.liveMaxLatencyDurationCount <= userConfig.liveSyncDurationCount)) { 33686 throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"'); 33687 } 33688 if (userConfig.liveMaxLatencyDuration !== void 0 && (userConfig.liveSyncDuration === void 0 || userConfig.liveMaxLatencyDuration <= userConfig.liveSyncDuration)) { 33689 throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"'); 33690 } 33691 const defaultsCopy = deepCpy(defaultConfig); 33692 const deprecatedSettingTypes = ["manifest", "level", "frag"]; 33693 const deprecatedSettings = ["TimeOut", "MaxRetry", "RetryDelay", "MaxRetryTimeout"]; 33694 deprecatedSettingTypes.forEach((type) => { 33695 const policyName = `${type === "level" ? "playlist" : type}LoadPolicy`; 33696 const policyNotSet = userConfig[policyName] === void 0; 33697 const report = []; 33698 deprecatedSettings.forEach((setting) => { 33699 const deprecatedSetting = `${type}Loading${setting}`; 33700 const value = userConfig[deprecatedSetting]; 33701 if (value !== void 0 && policyNotSet) { 33702 report.push(deprecatedSetting); 33703 const settings = defaultsCopy[policyName].default; 33704 userConfig[policyName] = { 33705 default: settings 33706 }; 33707 switch (setting) { 33708 case "TimeOut": 33709 settings.maxLoadTimeMs = value; 33710 settings.maxTimeToFirstByteMs = value; 33711 break; 33712 case "MaxRetry": 33713 settings.errorRetry.maxNumRetry = value; 33714 settings.timeoutRetry.maxNumRetry = value; 33715 break; 33716 case "RetryDelay": 33717 settings.errorRetry.retryDelayMs = value; 33718 settings.timeoutRetry.retryDelayMs = value; 33719 break; 33720 case "MaxRetryTimeout": 33721 settings.errorRetry.maxRetryDelayMs = value; 33722 settings.timeoutRetry.maxRetryDelayMs = value; 33723 break; 33724 } 33725 } 33726 }); 33727 if (report.length) { 33728 logger.warn(`hls.js config: "${report.join('", "')}" setting(s) are deprecated, use "${policyName}": ${JSON.stringify(userConfig[policyName])}`); 33729 } 33730 }); 33731 return _objectSpread23(_objectSpread23({}, defaultsCopy), userConfig); 33732} 33733function deepCpy(obj) { 33734 if (obj && typeof obj === "object") { 33735 if (Array.isArray(obj)) { 33736 return obj.map(deepCpy); 33737 } 33738 return Object.keys(obj).reduce((result, key) => { 33739 result[key] = deepCpy(obj[key]); 33740 return result; 33741 }, {}); 33742 } 33743 return obj; 33744} 33745function enableStreamingMode(config) { 33746 const currentLoader = config.loader; 33747 if (currentLoader !== FetchLoader && currentLoader !== XhrLoader) { 33748 logger.log("[config]: Custom loader detected, cannot enable progressive streaming"); 33749 config.progressive = false;
33750 } else { 33751 const canStreamProgressively = fetchSupported(); 33752 if (canStreamProgressively) { 33753 config.loader = FetchLoader; 33754 config.progressive = true; 33755 config.enableSoftwareAES = true; 33756 logger.log("[config]: Progressive streaming enabled, using FetchLoader"); 33757 } 33758 } 33759} 33760var chromeOrFirefox; 33761var LevelController = class extends BasePlaylistController { 33762 constructor(hls, contentSteeringController) { 33763 super(hls, "[level-controller]"); 33764 this._levels = []; 33765 this._firstLevel = -1; 33766 this._maxAutoLevel = -1; 33767 this._startLevel = void 0; 33768 this.currentLevel = null; 33769 this.currentLevelIndex = -1; 33770 this.manualLevelIndex = -1; 33771 this.steering = void 0; 33772 this.onParsedComplete = void 0; 33773 this.steering = contentSteeringController; 33774 this._registerListeners(); 33775 } 33776 _registerListeners() { 33777 const { 33778 hls 33779 } = this; 33780 hls.on(Events.MANIFEST_LOADING, this.onManifestLoading, this); 33781 hls.on(Events.MANIFEST_LOADED, this.onManifestLoaded, this); 33782 hls.on(Events.LEVEL_LOADED, this.onLevelLoaded, this); 33783 hls.on(Events.LEVELS_UPDATED, this.onLevelsUpdated, this); 33784 hls.on(Events.FRAG_BUFFERED, this.onFragBuffered, this); 33785 hls.on(Events.ERROR, this.onError, this); 33786 } 33787 _unregisterListeners() { 33788 const { 33789 hls 33790 } = this; 33791 hls.off(Events.MANIFEST_LOADING, this.onManifestLoading, this); 33792 hls.off(Events.MANIFEST_LOADED, this.onManifestLoaded, this); 33793 hls.off(Events.LEVEL_LOADED, this.onLevelLoaded, this); 33794 hls.off(Events.LEVELS_UPDATED, this.onLevelsUpdated, this); 33795 hls.off(Events.FRAG_BUFFERED, this.onFragBuffered, this); 33796 hls.off(Events.ERROR, this.onError, this); 33797 } 33798 destroy() { 33799 this._unregisterListeners(); 33800 this.steering = null; 33801 this.resetLevels(); 33802 super.destroy(); 33803 } 33804 stopLoad() { 33805 const levels = this._levels; 33806 levels.forEach((level) => { 33807 level.loadError = 0; 33808 level.fragmentError = 0; 33809 }); 33810 super.stopLoad(); 33811 } 33812 resetLevels() { 33813 this._startLevel = void 0; 33814 this.manualLevelIndex = -1; 33815 this.currentLevelIndex = -1; 33816 this.currentLevel = null; 33817 this._levels = []; 33818 this._maxAutoLevel = -1; 33819 } 33820 onManifestLoading(event, data) { 33821 this.resetLevels(); 33822 } 33823 onManifestLoaded(event, data) { 33824 const preferManagedMediaSource = this.hls.config.preferManagedMediaSource; 33825 const levels = []; 33826 const redundantSet = {}; 33827 const generatePathwaySet = {}; 33828 let resolutionFound = false; 33829 let videoCodecFound = false; 33830 let audioCodecFound = false; 33831 data.levels.forEach((levelParsed) => { 33832 var _audioCodec, _videoCodec; 33833 const attributes = levelParsed.attrs; 33834 let { 33835 audioCodec, 33836 videoCodec 33837 } = levelParsed; 33838 if (((_audioCodec = audioCodec) == null ? void 0 : _audioCodec.indexOf("mp4a.40.34")) !== -1) { 33839 chromeOrFirefox || (chromeOrFirefox = /chrome|firefox/i.test(navigator.userAgent)); 33840 if (chromeOrFirefox) { 33841 levelParsed.audioCodec = audioCodec = void 0; 33842 } 33843 } 33844 if (audioCodec) { 33845 levelParsed.audioCodec = audioCodec = getCodecCompatibleName(audioCodec, preferManagedMediaSource); 33846 } 33847 if (((_videoCodec = videoCodec) == null ? void 0 : _videoCodec.indexOf("avc1")) === 0) { 33848 videoCodec = levelParsed.videoCodec = convertAVC1ToAVCOTI(videoCodec); 33849 } 33850 const { 33851 width, 33852 height, 33853 unknownCodecs 33854 } = levelParsed; 33855 resolutionFound || (resolutionFound = !!(width && height)); 33856 videoCodecFound || (videoCodecFound = !!videoCodec); 33857 audioCodecFound || (audioCodecFound = !!audioCodec); 33858 if (unknownCodecs != null && unknownCodecs.length || audioCodec && !areCodecsMediaSourceSupported(audioCodec, "audio", preferManagedMediaSource) || videoCodec && !areCodecsMediaSourceSupported(videoCodec, "video", preferManagedMediaSource)) { 33859 return; 33860 } 33861 const { 33862 CODECS, 33863 "FRAME-RATE": FRAMERATE, 33864 "HDCP-LEVEL": HDCP, 33865 "PATHWAY-ID": PATHWAY, 33866 RESOLUTION, 33867 "VIDEO-RANGE": VIDEO_RANGE 33868 } = attributes; 33869 const contentSteeringPrefix = `${PATHWAY || "."}-`; 33870 const levelKey = `${contentSteeringPrefix}${levelParsed.bitrate}-${RESOLUTION}-${FRAMERATE}-${CODECS}-${VIDEO_RANGE}-${HDCP}`; 33871 if (!redundantSet[levelKey]) { 33872 const level = new Level(levelParsed); 33873 redundantSet[levelKey] = level; 33874 generatePathwaySet[levelKey] = 1; 33875 levels.push(level); 33876 } else if (redundantSet[levelKey].uri !== levelParsed.url && !levelParsed.attrs["PATHWAY-ID"]) { 33877 const pathwayCount = generatePathwaySet[levelKey] += 1; 33878 levelParsed.attrs["PATHWAY-ID"] = new Array(pathwayCount + 1).join("."); 33879 const level = new Level(levelParsed); 33880 redundantSet[levelKey] = level; 33881 levels.push(level); 33882 } else { 33883 redundantSet[levelKey].addGroupId("audio", attributes.AUDIO); 33884 redundantSet[levelKey].addGroupId("text", attributes.SUBTITLES); 33885 } 33886 }); 33887 this.filterAndSortMediaOptions(levels, data, resolutionFound, videoCodecFound, audioCodecFound); 33888 } 33889 filterAndSortMediaOptions(filteredLevels, data, resolutionFound, videoCodecFound, audioCodecFound) { 33890 let audioTracks = []; 33891 let subtitleTracks = []; 33892 let levels = filteredLevels; 33893 if ((resolutionFound || videoCodecFound) && audioCodecFound) { 33894 levels = levels.filter(({ 33895 videoCodec, 33896 videoRange, 33897 width, 33898 height 33899 }) => (!!videoCodec || !!(width && height)) && isVideoRange(videoRange)); 33900 } 33901 if (levels.length === 0) { 33902 Promise.resolve().then(() => { 33903 if (this.hls) { 33904 if (data.levels.length) { 33905 this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(data.levels[0].attrs)}`); 33906 } 33907 const error = new Error("no level with compatible codecs found in manifest"); 33908 this.hls.trigger(Events.ERROR, { 33909 type: ErrorTypes.MEDIA_ERROR, 33910 details: ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR, 33911 fatal: true, 33912 url: data.url, 33913 error, 33914 reason: error.message 33915 }); 33916 } 33917 }); 33918 return; 33919 } 33920 if (data.audioTracks) { 33921 const { 33922 preferManagedMediaSource 33923 } = this.hls.config; 33924 audioTracks = data.audioTracks.filter((track) =>
vendor: 10,159 bytes, lines 33924-34215
33924 !track.audioCodec || areCodecsMediaSourceSupported(track.audioCodec, "audio", preferManagedMediaSource)); 33925 assignTrackIdsByGroup(audioTracks); 33926 } 33927 if (data.subtitles) { 33928 subtitleTracks = data.subtitles; 33929 assignTrackIdsByGroup(subtitleTracks); 33930 } 33931 const unsortedLevels = levels.slice(0); 33932 levels.sort((a2, b3) => { 33933 if (a2.attrs["HDCP-LEVEL"] !== b3.attrs["HDCP-LEVEL"]) { 33934 return (a2.attrs["HDCP-LEVEL"] || "") > (b3.attrs["HDCP-LEVEL"] || "") ? 1 : -1; 33935 } 33936 if (resolutionFound && a2.height !== b3.height) { 33937 return a2.height - b3.height; 33938 } 33939 if (a2.frameRate !== b3.frameRate) { 33940 return a2.frameRate - b3.frameRate; 33941 } 33942 if (a2.videoRange !== b3.videoRange) { 33943 return VideoRangeValues.indexOf(a2.videoRange) - VideoRangeValues.indexOf(b3.videoRange); 33944 } 33945 if (a2.videoCodec !== b3.videoCodec) { 33946 const valueA = videoCodecPreferenceValue(a2.videoCodec); 33947 const valueB = videoCodecPreferenceValue(b3.videoCodec); 33948 if (valueA !== valueB) { 33949 return valueB - valueA; 33950 } 33951 } 33952 if (a2.uri === b3.uri && a2.codecSet !== b3.codecSet) { 33953 const valueA = codecsSetSelectionPreferenceValue(a2.codecSet); 33954 const valueB = codecsSetSelectionPreferenceValue(b3.codecSet); 33955 if (valueA !== valueB) { 33956 return valueB - valueA; 33957 } 33958 } 33959 if (a2.averageBitrate !== b3.averageBitrate) { 33960 return a2.averageBitrate - b3.averageBitrate; 33961 } 33962 return 0; 33963 }); 33964 let firstLevelInPlaylist = unsortedLevels[0]; 33965 if (this.steering) { 33966 levels = this.steering.filterParsedLevels(levels); 33967 if (levels.length !== unsortedLevels.length) { 33968 for (let i3 = 0; i3 < unsortedLevels.length; i3++) { 33969 if (unsortedLevels[i3].pathwayId === levels[0].pathwayId) { 33970 firstLevelInPlaylist = unsortedLevels[i3]; 33971 break; 33972 } 33973 } 33974 } 33975 } 33976 this._levels = levels; 33977 for (let i3 = 0; i3 < levels.length; i3++) { 33978 if (levels[i3] === firstLevelInPlaylist) { 33979 var _this$hls$userConfig; 33980 this._firstLevel = i3; 33981 const firstLevelBitrate = firstLevelInPlaylist.bitrate; 33982 const bandwidthEstimate = this.hls.bandwidthEstimate; 33983 this.log(`manifest loaded, ${levels.length} level(s) found, first bitrate: ${firstLevelBitrate}`); 33984 if (((_this$hls$userConfig = this.hls.userConfig) == null ? void 0 : _this$hls$userConfig.abrEwmaDefaultEstimate) === void 0) { 33985 const startingBwEstimate = Math.min(firstLevelBitrate, this.hls.config.abrEwmaDefaultEstimateMax); 33986 if (startingBwEstimate > bandwidthEstimate && bandwidthEstimate === hlsDefaultConfig.abrEwmaDefaultEstimate) { 33987 this.hls.bandwidthEstimate = startingBwEstimate; 33988 } 33989 } 33990 break; 33991 } 33992 } 33993 const audioOnly = audioCodecFound && !videoCodecFound; 33994 const edata = { 33995 levels, 33996 audioTracks, 33997 subtitleTracks, 33998 sessionData: data.sessionData, 33999 sessionKeys: data.sessionKeys, 34000 firstLevel: this._firstLevel, 34001 stats: data.stats, 34002 audio: audioCodecFound, 34003 video: videoCodecFound, 34004 altAudio: !audioOnly && audioTracks.some((t2) => !!t2.url) 34005 }; 34006 this.hls.trigger(Events.MANIFEST_PARSED, edata); 34007 if (this.hls.config.autoStartLoad || this.hls.forceStartLoad) { 34008 this.hls.startLoad(this.hls.config.startPosition); 34009 } 34010 } 34011 get levels() { 34012 if (this._levels.length === 0) { 34013 return null; 34014 } 34015 return this._levels; 34016 } 34017 get level() { 34018 return this.currentLevelIndex; 34019 } 34020 set level(newLevel) { 34021 const levels = this._levels; 34022 if (levels.length === 0) { 34023 return; 34024 } 34025 if (newLevel < 0 || newLevel >= levels.length) { 34026 const error = new Error("invalid level idx"); 34027 const fatal = newLevel < 0; 34028 this.hls.trigger(Events.ERROR, { 34029 type: ErrorTypes.OTHER_ERROR, 34030 details: ErrorDetails.LEVEL_SWITCH_ERROR, 34031 level: newLevel, 34032 fatal, 34033 error, 34034 reason: error.message 34035 }); 34036 if (fatal) { 34037 return; 34038 } 34039 newLevel = Math.min(newLevel, levels.length - 1); 34040 } 34041 const lastLevelIndex = this.currentLevelIndex; 34042 const lastLevel = this.currentLevel; 34043 const lastPathwayId = lastLevel ? lastLevel.attrs["PATHWAY-ID"] : void 0; 34044 const level = levels[newLevel]; 34045 const pathwayId = level.attrs["PATHWAY-ID"]; 34046 this.currentLevelIndex = newLevel; 34047 this.currentLevel = level; 34048 if (lastLevelIndex === newLevel && level.details && lastLevel && lastPathwayId === pathwayId) { 34049 return; 34050 } 34051 this.log(`Switching to level ${newLevel} (${level.height ? level.height + "p " : ""}${level.videoRange ? level.videoRange + " " : ""}${level.codecSet ? level.codecSet + " " : ""}@${level.bitrate})${pathwayId ? " with Pathway " + pathwayId : ""} from level ${lastLevelIndex}${lastPathwayId ? " with Pathway " + lastPathwayId : ""}`); 34052 const levelSwitchingData = { 34053 level: newLevel, 34054 attrs: level.attrs, 34055 details: level.details, 34056 bitrate: level.bitrate, 34057 averageBitrate: level.averageBitrate, 34058 maxBitrate: level.maxBitrate, 34059 realBitrate: level.realBitrate, 34060 width: level.width, 34061 height: level.height, 34062 codecSet: level.codecSet, 34063 audioCodec: level.audioCodec, 34064 videoCodec: level.videoCodec, 34065 audioGroups: level.audioGroups, 34066 subtitleGroups: level.subtitleGroups, 34067 loaded: level.loaded, 34068 loadError: level.loadError, 34069 fragmentError: level.fragmentError, 34070 name: level.name, 34071 id: level.id, 34072 uri: level.uri, 34073 url: level.url, 34074 urlId: 0, 34075 audioGroupIds: level.audioGroupIds, 34076 textGroupIds: level.textGroupIds 34077 }; 34078 this.hls.trigger(Events.LEVEL_SWITCHING, levelSwitchingData); 34079 const levelDetails = level.details; 34080 if (!levelDetails || levelDetails.live) { 34081 const hlsUrlParameters = this.switchParams(level.uri, lastLevel == null ? void 0 : lastLevel.details, levelDetails); 34082 this.loadPlaylist(hlsUrlParameters); 34083 } 34084 } 34085 get manualLevel() { 34086 return this.manualLevelIndex; 34087 } 34088 set manualLevel(newLevel) { 34089 this.manualLevelIndex = newLevel; 34090 if (this._startLevel === void 0) { 34091 this._startLevel = newLevel; 34092 } 34093 if (newLevel !== -1) { 34094 this.level = newLevel; 34095 } 34096 } 34097 get firstLevel() { 34098 return this._firstLevel; 34099 } 34100 set firstLevel(newLevel) { 34101 this._firstLevel = newLevel; 34102 } 34103 get startLevel() { 34104 if (this._startLevel === void 0) { 34105 const configStartLevel = this.hls.config.startLevel; 34106 if (configStartLevel !== void 0) { 34107 return configStartLevel; 34108 } 34109 return this.hls.firstAutoLevel; 34110 } 34111 return this._startLevel; 34112 } 34113 set startLevel(newLevel) { 34114 this._startLevel = newLevel; 34115 } 34116 onError(event, data) { 34117 if (data.fatal || !data.context) { 34118 return; 34119 } 34120 if (data.context.type === PlaylistContextType.LEVEL && data.context.level === this.level) { 34121 this.checkRetry(data); 34122 } 34123 } 34124 // reset errors on the successful load of a fragment 34125 onFragBuffered(event, { 34126 frag 34127 }) { 34128 if (frag !== void 0 && frag.type === PlaylistLevelType.MAIN) { 34129 const el = frag.elementaryStreams; 34130 if (!Object.keys(el).some((type) => !!el[type])) { 34131 return; 34132 } 34133 const level = this._levels[frag.level]; 34134 if (level != null && level.loadError) { 34135 this.log(`Resetting level error count of ${level.loadError} on frag buffered`); 34136 level.loadError = 0; 34137 } 34138 } 34139 } 34140 onLevelLoaded(event, data) { 34141 var _data$deliveryDirecti2; 34142 const { 34143 level, 34144 details 34145 } = data; 34146 const curLevel = this._levels[level]; 34147 if (!curLevel) { 34148 var _data$deliveryDirecti; 34149 this.warn(`Invalid level index ${level}`); 34150 if ((_data$deliveryDirecti = data.deliveryDirectives) != null && _data$deliveryDirecti.skip) { 34151 details.deltaUpdateFailed = true; 34152 } 34153 return; 34154 } 34155 if (level === this.currentLevelIndex) { 34156 if (curLevel.fragmentError === 0) { 34157 curLevel.loadError = 0; 34158 } 34159 this.playlistLoaded(level, data, curLevel.details); 34160 } else if ((_data$deliveryDirecti2 = data.deliveryDirectives) != null && _data$deliveryDirecti2.skip) { 34161 details.deltaUpdateFailed = true; 34162 } 34163 } 34164 loadPlaylist(hlsUrlParameters) { 34165 super.loadPlaylist(); 34166 const currentLevelIndex = this.currentLevelIndex; 34167 const currentLevel = this.currentLevel; 34168 if (currentLevel && this.shouldLoadPlaylist(currentLevel)) { 34169 let url = currentLevel.uri; 34170 if (hlsUrlParameters) { 34171 try { 34172 url = hlsUrlParameters.addDirectives(url); 34173 } catch (error) { 34174 this.warn(`Could not construct new URL with HLS Delivery Directives: ${error}`); 34175 } 34176 } 34177 const pathwayId = currentLevel.attrs["PATHWAY-ID"]; 34178 this.log(`Loading level index ${currentLevelIndex}${(hlsUrlParameters == null ? void 0 : hlsUrlParameters.msn) !== void 0 ? " at sn " + hlsUrlParameters.msn + " part " + hlsUrlParameters.part : ""} with${pathwayId ? " Pathway " + pathwayId : ""} ${url}`); 34179 this.clearTimer(); 34180 this.hls.trigger(Events.LEVEL_LOADING, { 34181 url, 34182 level: currentLevelIndex, 34183 pathwayId: currentLevel.attrs["PATHWAY-ID"], 34184 id: 0, 34185 // Deprecated Level urlId 34186 deliveryDirectives: hlsUrlParameters || null 34187 }); 34188 } 34189 } 34190 get nextLoadLevel() { 34191 if (this.manualLevelIndex !== -1) { 34192 return this.manualLevelIndex; 34193 } else { 34194 return this.hls.nextAutoLevel; 34195 } 34196 } 34197 set nextLoadLevel(nextLevel) { 34198 this.level = nextLevel; 34199 if (this.manualLevelIndex === -1) { 34200 this.hls.nextAutoLevel = nextLevel; 34201 } 34202 } 34203 removeLevel(levelIndex) { 34204 var _this$currentLevel; 34205 const levels = this._levels.filter((level, index2) => { 34206 if (index2 !== levelIndex) { 34207 return true; 34208 } 34209 if (this.steering) { 34210 this.steering.removeLevel(level); 34211 } 34212 if (level === this.currentLevel) { 34213 this.currentLevel = null; 34214 this.currentLevelIndex = -1; 34215 if (level.details) {
vendor: 4,249 bytes, lines 34216-34355
34216 level.details.fragments.forEach((f) => f.level = -1); 34217 } 34218 } 34219 return false; 34220 }); 34221 reassignFragmentLevelIndexes(levels); 34222 this._levels = levels; 34223 if (this.currentLevelIndex > -1 && (_this$currentLevel = this.currentLevel) != null && _this$currentLevel.details) { 34224 this.currentLevelIndex = this.currentLevel.details.fragments[0].level; 34225 } 34226 this.hls.trigger(Events.LEVELS_UPDATED, { 34227 levels 34228 }); 34229 } 34230 onLevelsUpdated(event, { 34231 levels 34232 }) { 34233 this._levels = levels; 34234 } 34235 checkMaxAutoUpdated() { 34236 const { 34237 autoLevelCapping, 34238 maxAutoLevel, 34239 maxHdcpLevel 34240 } = this.hls; 34241 if (this._maxAutoLevel !== maxAutoLevel) { 34242 this._maxAutoLevel = maxAutoLevel; 34243 this.hls.trigger(Events.MAX_AUTO_LEVEL_UPDATED, { 34244 autoLevelCapping, 34245 levels: this.levels, 34246 maxAutoLevel, 34247 minAutoLevel: this.hls.minAutoLevel, 34248 maxHdcpLevel 34249 }); 34250 } 34251 } 34252}; 34253function assignTrackIdsByGroup(tracks) { 34254 const groups = {}; 34255 tracks.forEach((track) => { 34256 const groupId = track.groupId || ""; 34257 track.id = groups[groupId] = groups[groupId] || 0; 34258 groups[groupId]++; 34259 }); 34260} 34261var KeyLoader = class { 34262 constructor(config) { 34263 this.config = void 0; 34264 this.keyUriToKeyInfo = {}; 34265 this.emeController = null; 34266 this.config = config; 34267 } 34268 abort(type) { 34269 for (const uri in this.keyUriToKeyInfo) { 34270 const loader = this.keyUriToKeyInfo[uri].loader; 34271 if (loader) { 34272 var _loader$context; 34273 if (type && type !== ((_loader$context = loader.context) == null ? void 0 : _loader$context.frag.type)) { 34274 return; 34275 } 34276 loader.abort(); 34277 } 34278 } 34279 } 34280 detach() { 34281 for (const uri in this.keyUriToKeyInfo) { 34282 const keyInfo = this.keyUriToKeyInfo[uri]; 34283 if (keyInfo.mediaKeySessionContext || keyInfo.decryptdata.isCommonEncryption) { 34284 delete this.keyUriToKeyInfo[uri]; 34285 } 34286 } 34287 } 34288 destroy() { 34289 this.detach(); 34290 for (const uri in this.keyUriToKeyInfo) { 34291 const loader = this.keyUriToKeyInfo[uri].loader; 34292 if (loader) { 34293 loader.destroy(); 34294 } 34295 } 34296 this.keyUriToKeyInfo = {}; 34297 } 34298 createKeyLoadError(frag, details = ErrorDetails.KEY_LOAD_ERROR, error, networkDetails, response) { 34299 return new LoadError({ 34300 type: ErrorTypes.NETWORK_ERROR, 34301 details, 34302 fatal: false, 34303 frag, 34304 response, 34305 error, 34306 networkDetails 34307 }); 34308 } 34309 loadClear(loadingFrag, encryptedFragments) { 34310 if (this.emeController && this.config.emeEnabled) { 34311 const { 34312 sn, 34313 cc 34314 } = loadingFrag; 34315 for (let i3 = 0; i3 < encryptedFragments.length; i3++) { 34316 const frag = encryptedFragments[i3]; 34317 if (cc <= frag.cc && (sn === "initSegment" || frag.sn === "initSegment" || sn < frag.sn)) { 34318 this.emeController.selectKeySystemFormat(frag).then((keySystemFormat) => { 34319 frag.setKeyFormat(keySystemFormat); 34320 }); 34321 break; 34322 } 34323 } 34324 } 34325 } 34326 load(frag) { 34327 if (!frag.decryptdata && frag.encrypted && this.emeController && this.config.emeEnabled) { 34328 return this.emeController.selectKeySystemFormat(frag).then((keySystemFormat) => { 34329 return this.loadInternal(frag, keySystemFormat); 34330 }); 34331 } 34332 return this.loadInternal(frag); 34333 } 34334 loadInternal(frag, keySystemFormat) { 34335 var _keyInfo, _keyInfo2; 34336 if (keySystemFormat) { 34337 frag.setKeyFormat(keySystemFormat); 34338 } 34339 const decryptdata = frag.decryptdata; 34340 if (!decryptdata) { 34341 const error = new Error(keySystemFormat ? `Expected frag.decryptdata to be defined after setting format ${keySystemFormat}` : "Missing decryption data on fragment in onKeyLoading"); 34342 return Promise.reject(this.createKeyLoadError(frag, ErrorDetails.KEY_LOAD_ERROR, error)); 34343 } 34344 const uri = decryptdata.uri; 34345 if (!uri) { 34346 return Promise.reject(this.createKeyLoadError(frag, ErrorDetails.KEY_LOAD_ERROR, new Error(`Invalid key URI: "${uri}"`))); 34347 } 34348 let keyInfo = this.keyUriToKeyInfo[uri]; 34349 if ((_keyInfo = keyInfo) != null && _keyInfo.decryptdata.key) { 34350 decryptdata.key = keyInfo.decryptdata.key; 34351 return Promise.resolve({ 34352 frag, 34353 keyInfo 34354 }); 34355 }
34356 if ((_keyInfo2 = keyInfo) != null && _keyInfo2.keyLoadPromise) { 34357 var _keyInfo$mediaKeySess; 34358 switch ((_keyInfo$mediaKeySess = keyInfo.mediaKeySessionContext) == null ? void 0 : _keyInfo$mediaKeySess.keyStatus) { 34359 case void 0: 34360 case "status-pending": 34361 case "usable": 34362 case "usable-in-future": 34363 return keyInfo.keyLoadPromise.then((keyLoadedData) => { 34364 decryptdata.key = keyLoadedData.keyInfo.decryptdata.key; 34365 return { 34366 frag, 34367 keyInfo 34368 }; 34369 }); 34370 } 34371 } 34372 keyInfo = this.keyUriToKeyInfo[uri] = { 34373 decryptdata, 34374 keyLoadPromise: null, 34375 loader: null, 34376 mediaKeySessionContext: null 34377 }; 34378 switch (decryptdata.method) { 34379 case "ISO-23001-7": 34380 case "SAMPLE-AES": 34381 case "SAMPLE-AES-CENC": 34382 case "SAMPLE-AES-CTR": 34383 if (decryptdata.keyFormat === "identity") { 34384 return this.loadKeyHTTP(keyInfo, frag); 34385 } 34386 return this.loadKeyEME(keyInfo, frag); 34387 case "AES-128": 34388 return this.loadKeyHTTP(keyInfo, frag); 34389 default: 34390 return Promise.reject(this.createKeyLoadError(frag, ErrorDetails.KEY_LOAD_ERROR, new Error(`Key supplied with unsupported METHOD: "${decryptdata.method}"`))); 34391 } 34392 } 34393 loadKeyEME(keyInfo, frag) { 34394 const keyLoadedData = { 34395 frag, 34396 keyInfo 34397 }; 34398 if (this.emeController && this.config.emeEnabled) { 34399 const keySessionContextPromise = this.emeController.loadKey(keyLoadedData); 34400 if (keySessionContextPromise) { 34401 return (keyInfo.keyLoadPromise = keySessionContextPromise.then((keySessionContext) => { 34402 keyInfo.mediaKeySessionContext = keySessionContext; 34403 return keyLoadedData; 34404 })).catch((error) => { 34405 keyInfo.keyLoadPromise = null; 34406 throw error; 34407 }); 34408 } 34409 } 34410 return Promise.resolve(keyLoadedData); 34411 } 34412 loadKeyHTTP(keyInfo, frag) { 34413 const config = this.config; 34414 const Loader2 = config.loader; 34415 const keyLoader = new Loader2(config); 34416 frag.keyLoader = keyInfo.loader = keyLoader; 34417 return keyInfo.keyLoadPromise = new Promise((resolve, reject) => { 34418 const loaderContext = { 34419 keyInfo, 34420 frag, 34421 responseType: "arraybuffer", 34422 url: keyInfo.decryptdata.uri 34423 }; 34424 const loadPolicy = config.keyLoadPolicy.default; 34425 const loaderConfig = { 34426 loadPolicy, 34427 timeout: loadPolicy.maxLoadTimeMs, 34428 maxRetry: 0, 34429 retryDelay: 0, 34430 maxRetryDelay: 0 34431 }; 34432 const loaderCallbacks = { 34433 onSuccess: (response, stats, context, networkDetails) => { 34434 const { 34435 frag: frag2, 34436 keyInfo: keyInfo2, 34437 url: uri 34438 } = context; 34439 if (!frag2.decryptdata || keyInfo2 !== this.keyUriToKeyInfo[uri]) { 34440 return reject(this.createKeyLoadError(frag2, ErrorDetails.KEY_LOAD_ERROR, new Error("after key load, decryptdata unset or changed"), networkDetails)); 34441 } 34442 keyInfo2.decryptdata.key = frag2.decryptdata.key = new Uint8Array(response.data); 34443 frag2.keyLoader = null; 34444 keyInfo2.loader = null; 34445 resolve({ 34446 frag: frag2, 34447 keyInfo: keyInfo2 34448 }); 34449 }, 34450 onError: (response, context, networkDetails, stats) => { 34451 this.resetLoader(context); 34452 reject(this.createKeyLoadError(frag, ErrorDetails.KEY_LOAD_ERROR, new Error(`HTTP Error ${response.code} loading key ${response.text}`), networkDetails, _objectSpread23({ 34453 url: loaderContext.url, 34454 data: void 0 34455 }, response))); 34456 }, 34457 onTimeout: (stats, context, networkDetails) => { 34458 this.resetLoader(context); 34459 reject(this.createKeyLoadError(frag, ErrorDetails.KEY_LOAD_TIMEOUT, new Error("key loading timed out"), networkDetails)); 34460 }, 34461 onAbort: (stats, context, networkDetails) => { 34462 this.resetLoader(context); 34463 reject(this.createKeyLoadError(frag, ErrorDetails.INTERNAL_ABORTED, new Error("key loading aborted"), networkDetails)); 34464 } 34465 }; 34466 keyLoader.load(loaderContext, loaderConfig, loaderCallbacks); 34467 }); 34468 } 34469 resetLoader(context) { 34470 const { 34471 frag, 34472 keyInfo,
34473 url: uri 34474 } = context; 34475 const loader = keyInfo.loader; 34476 if (frag.keyLoader === loader) { 34477 frag.keyLoader = null; 34478 keyInfo.loader = null; 34479 } 34480 delete this.keyUriToKeyInfo[uri]; 34481 if (loader) { 34482 loader.destroy(); 34483 } 34484 } 34485}; 34486function getSourceBuffer() { 34487 return self.SourceBuffer || self.WebKitSourceBuffer; 34488} 34489function isMSESupported() { 34490 const mediaSource = getMediaSource(); 34491 if (!mediaSource) { 34492 return false; 34493 } 34494 const sourceBuffer = getSourceBuffer(); 34495 return !sourceBuffer || sourceBuffer.prototype && typeof sourceBuffer.prototype.appendBuffer === "function" && typeof sourceBuffer.prototype.remove === "function"; 34496} 34497function isSupported() { 34498 if (!isMSESupported()) { 34499 return false; 34500 } 34501 const mediaSource = getMediaSource(); 34502 return typeof (mediaSource == null ? void 0 : mediaSource.isTypeSupported) === "function" && (["avc1.42E01E,mp4a.40.2", "av01.0.01M.08", "vp09.00.50.08"].some((codecsForVideoContainer) => mediaSource.isTypeSupported(mimeTypeForCodec(codecsForVideoContainer, "video"))) || ["mp4a.40.2", "fLaC"].some((codecForAudioContainer) => mediaSource.isTypeSupported(mimeTypeForCodec(codecForAudioContainer, "audio")))); 34503} 34504function changeTypeSupported() { 34505 var _sourceBuffer$prototy; 34506 const sourceBuffer = getSourceBuffer(); 34507 return typeof (sourceBuffer == null ? void 0 : (_sourceBuffer$prototy = sourceBuffer.prototype) == null ? void 0 : _sourceBuffer$prototy.changeType) === "function"; 34508} 34509var STALL_MINIMUM_DURATION_MS = 250; 34510var MAX_START_GAP_JUMP = 2; 34511var SKIP_BUFFER_HOLE_STEP_SECONDS = 0.1; 34512var SKIP_BUFFER_RANGE_START = 0.05; 34513var GapController = class { 34514 constructor(config, media, fragmentTracker, hls) { 34515 this.config = void 0; 34516 this.media = null; 34517 this.fragmentTracker = void 0; 34518 this.hls = void 0; 34519 this.nudgeRetry = 0; 34520 this.stallReported = false; 34521 this.stalled = null; 34522 this.moved = false; 34523 this.seeking = false; 34524 this.config = config; 34525 this.media = media; 34526 this.fragmentTracker = fragmentTracker; 34527 this.hls = hls; 34528 } 34529 destroy() { 34530 this.media = null; 34531 this.hls = this.fragmentTracker = null; 34532 } 34533 /** 34534 * Checks if the playhead is stuck within a gap, and if so, attempts to free it. 34535 * A gap is an unbuffered range between two buffered ranges (or the start and the first buffered range). 34536 * 34537 * @param lastCurrentTime - Previously read playhead position 34538 */ 34539 poll(lastCurrentTime, activeFrag) { 34540 const { 34541 config, 34542 media, 34543 stalled 34544 } = this; 34545 if (media === null) { 34546 return; 34547 } 34548 const { 34549 currentTime, 34550 seeking 34551 } = media; 34552 const seeked = this.seeking && !seeking; 34553 const beginSeek = !this.seeking && seeking; 34554 this.seeking = seeking; 34555 if (currentTime !== lastCurrentTime) { 34556 this.moved = true; 34557 if (!seeking) { 34558 this.nudgeRetry = 0; 34559 } 34560 if (stalled !== null) { 34561 if (this.stallReported) { 34562 const _stalledDuration = self.performance.now() - stalled; 34563 logger.warn(`playback not stuck anymore @${currentTime}, after ${Math.round(_stalledDuration)}ms`); 34564 this.stallReported = false; 34565 } 34566 this.stalled = null; 34567 } 34568 return; 34569 } 34570 if (beginSeek || seeked) { 34571 this.stalled = null; 34572 return; 34573 } 34574 if (media.paused && !seeking || media.ended || media.playbackRate === 0 || !BufferHelper.getBuffered(media).length) { 34575 this.nudgeRetry = 0; 34576 return; 34577 } 34578 const bufferInfo = BufferHelper.bufferInfo(media, currentTime, 0); 34579 const nextStart = bufferInfo.nextStart || 0; 34580 if (seeking) { 34581 const hasEnoughBuffer = bufferInfo.len > MAX_START_GAP_JUMP; 34582 const noBufferGap = !nextStart || activeFrag && activeFrag.start <= currentTime || nextStart - currentTime > MAX_START_GAP_JUMP && !this.fragmentTracker.getPartialFragment(currentTime); 34583 if (hasEnoughBuffer || noBufferGap) { 34584 return; 34585 } 34586 this.moved = false; 34587 } 34588 if (!this.moved && this.stalled !== null) { 34589 var _level$details; 34590 const isBuffered = bufferInfo.len > 0; 34591 if (!isBuffered && !nextStart) { 34592 return; 34593 } 34594 const startJump = Math.max(nextStart, bufferInfo.start || 0) - currentTime; 34595 const level = this.hls.levels ? this.hls.levels[this.hls.currentLevel] : null; 34596 const isLive = level == null ? void 0 : (_level$details = level.details) == null ? void 0 : _level$details.live; 34597 const maxStartGapJump = isLive ? level.details.targetduration * 2 : MAX_START_GAP_JUMP; 34598 const partialOrGap = this.fragmentTracker.getPartialFragment(currentTime); 34599 if (startJump > 0 && (startJump <= maxStartGapJump || partialOrGap)) { 34600 if (!media.paused) { 34601 this._trySkipBufferHole(partialOrGap); 34602 } 34603 return; 34604 } 34605 } 34606 const tnow = self.performance.now(); 34607 if (stalled === null) { 34608 this.stalled = tnow; 34609 return; 34610 } 34611 const stalledDuration = tnow - stalled; 34612 if (!seeking && stalledDuration >= STALL_MINIMUM_DURATION_MS) { 34613 this._reportStall(bufferInfo); 34614 if (!this.media) { 34615 return; 34616 } 34617 } 34618 const bufferedWithHoles = BufferHelper.bufferInfo(media, currentTime, config.maxBufferHole); 34619 this._tryFixBufferStall(bufferedWithHoles, stalledDuration); 34620 } 34621 /** 34622 * Detects and attempts to fix known buffer stalling issues. 34623 * @param bufferInfo - The properties of the current buffer. 34624 * @param stalledDurationMs - The amount of time Hls.js has been stalling for. 34625 * @private 34626 */ 34627 _tryFixBufferStall(bufferInfo, stalledDurationMs) { 34628 const { 34629 config, 34630 fragmentTracker, 34631 media 34632 } = this; 34633 if (media === null) { 34634 return; 34635 } 34636 const currentTime = media.currentTime; 34637 const partial = fragmentTracker.getPartialFragment(currentTime); 34638 if (partial) { 34639 const targetTime = this._trySkipBufferHole(partial); 34640 if (targetTime || !this.media) { 34641 return; 34642 } 34643 } 34644 if ((bufferInfo.len > config.maxBufferHole || bufferInfo.nextStart && bufferInfo.nextStart - currentTime < config.maxBufferHole) && stalledDurationMs > config.highBufferWatchdogPeriod * 1e3) { 34645 logger.warn("Trying to nudge playhead over buffer-hole"); 34646 this.stalled = null; 34647 this._tryNudgeBuffer(); 34648 } 34649 } 34650 /** 34651 * Triggers a BUFFER_STALLED_ERROR event, but only once per stall period. 34652 * @param bufferLen - The playhead distance from the end of the current buffer segment. 34653 * @private 34654 */ 34655 _reportStall(bufferInfo) { 34656 const { 34657 hls, 34658 media, 34659 stallReported 34660 } = this; 34661 if (!stallReported && media) { 34662 this.stallReported = true; 34663 const error = new Error(`Playback stalling at @${media.currentTime} due to low buffer (${JSON.stringify(bufferInfo)})`); 34664 logger.warn(error.message); 34665 hls.trigger(Events.ERROR, { 34666 type: ErrorTypes.MEDIA_ERROR, 34667 details: ErrorDetails.BUFFER_STALLED_ERROR, 34668 fatal: false, 34669 error, 34670 buffer: bufferInfo.len 34671 }); 34672 } 34673 } 34674 /** 34675 * Attempts to fix buffer stalls by jumping over known gaps caused by partial fragments 34676 * @param partial - The partial fragment found at the current time (where playback is stalling). 34677 * @private 34678 */ 34679 _trySkipBufferHole(partial) { 34680 const { 34681 config, 34682 hls, 34683 media 34684 } = this; 34685 if (media === null) { 34686 return 0; 34687 } 34688 const currentTime = media.currentTime; 34689 const bufferInfo = BufferHelper.bufferInfo(media, currentTime, 0); 34690 const startTime = currentTime < bufferInfo.start ? bufferInfo.start : bufferInfo.nextStart; 34691 if (startTime) { 34692 const bufferStarved = bufferInfo.len <= config.maxBufferHole; 34693 const waiting = bufferInfo.len > 0 && bufferInfo.len < 1 && media.readyState < 3; 34694 const gapLength = startTime - currentTime; 34695 if (gapLength > 0 && (bufferStarved || waiting)) { 34696 if (gapLength > config.maxBufferHole) { 34697 const { 34698 fragmentTracker 34699 } = this; 34700 let startGap = false;
34701 if (currentTime === 0) { 34702 const startFrag = fragmentTracker.getAppendedFrag(0, PlaylistLevelType.MAIN); 34703 if (startFrag && startTime < startFrag.end) { 34704 startGap = true; 34705 } 34706 } 34707 if (!startGap) { 34708 const startProvisioned = partial || fragmentTracker.getAppendedFrag(currentTime, PlaylistLevelType.MAIN); 34709 if (startProvisioned) { 34710 let moreToLoad = false; 34711 let pos = startProvisioned.end; 34712 while (pos < startTime) { 34713 const provisioned = fragmentTracker.getPartialFragment(pos); 34714 if (provisioned) { 34715 pos += provisioned.duration; 34716 } else { 34717 moreToLoad = true; 34718 break; 34719 } 34720 } 34721 if (moreToLoad) { 34722 return 0; 34723 } 34724 } 34725 } 34726 } 34727 const targetTime = Math.max(startTime + SKIP_BUFFER_RANGE_START, currentTime + SKIP_BUFFER_HOLE_STEP_SECONDS); 34728 logger.warn(`skipping hole, adjusting currentTime from ${currentTime} to ${targetTime}`); 34729 this.moved = true; 34730 this.stalled = null; 34731 media.currentTime = targetTime; 34732 if (partial && !partial.gap) { 34733 const error = new Error(`fragment loaded with buffer holes, seeking from ${currentTime} to ${targetTime}`); 34734 hls.trigger(Events.ERROR, { 34735 type: ErrorTypes.MEDIA_ERROR, 34736 details: ErrorDetails.BUFFER_SEEK_OVER_HOLE, 34737 fatal: false, 34738 error, 34739 reason: error.message, 34740 frag: partial 34741 }); 34742 } 34743 return targetTime; 34744 } 34745 } 34746 return 0; 34747 } 34748 /** 34749 * Attempts to fix buffer stalls by advancing the mediaElement's current time by a small amount. 34750 * @private 34751 */ 34752 _tryNudgeBuffer() { 34753 const { 34754 config, 34755 hls, 34756 media, 34757 nudgeRetry 34758 } = this; 34759 if (media === null) { 34760 return; 34761 } 34762 const currentTime = media.currentTime; 34763 this.nudgeRetry++; 34764 if (nudgeRetry < config.nudgeMaxRetry) { 34765 const targetTime = currentTime + (nudgeRetry + 1) * config.nudgeOffset; 34766 const error = new Error(`Nudging 'currentTime' from ${currentTime} to ${targetTime}`); 34767 logger.warn(error.message); 34768 media.currentTime = targetTime; 34769 hls.trigger(Events.ERROR, { 34770 type: ErrorTypes.MEDIA_ERROR, 34771 details: ErrorDetails.BUFFER_NUDGE_ON_STALL, 34772 error, 34773 fatal: false 34774 }); 34775 } else { 34776 const error = new Error(`Playhead still not moving while enough data buffered @${currentTime} after ${config.nudgeMaxRetry} nudges`); 34777 logger.error(error.message); 34778 hls.trigger(Events.ERROR, { 34779 type: ErrorTypes.MEDIA_ERROR, 34780 details: ErrorDetails.BUFFER_STALLED_ERROR, 34781 error, 34782 fatal: true 34783 }); 34784 } 34785 } 34786}; 34787var TICK_INTERVAL = 100; 34788var StreamController = class extends BaseStreamController { 34789 constructor(hls, fragmentTracker, keyLoader) { 34790 super(hls, fragmentTracker, keyLoader, "[stream-controller]", PlaylistLevelType.MAIN); 34791 this.audioCodecSwap = false; 34792 this.gapController = null; 34793 this.level = -1; 34794 this._forceStartLoad = false; 34795 this.altAudio = false; 34796 this.audioOnly = false; 34797 this.fragPlaying = null; 34798 this.onvplaying = null; 34799 this.onvseeked = null; 34800 this.fragLastKbps = 0; 34801 this.couldBacktrack = false; 34802 this.backtrackFragment = null; 34803 this.audioCodecSwitch = false; 34804 this.videoBuffer = null; 34805 this._registerListeners(); 34806 } 34807 _registerListeners() { 34808 const { 34809 hls 34810 } = this; 34811 hls.on(Events.MEDIA_ATTACHED, this.onMediaAttached, this); 34812 hls.on(Events.MEDIA_DETACHING, this.onMediaDetaching, this); 34813 hls.on(Events.MANIFEST_LOADING, this.onManifestLoading, this); 34814 hls.on(Events.MANIFEST_PARSED, this.onManifestParsed, this); 34815 hls.on(Events.LEVEL_LOADING, this.onLevelLoading, this); 34816 hls.on(Events.LEVEL_LOADED, this.onLevelLoaded, this); 34817 hls.on(Events.FRAG_LOAD_EMERGENCY_ABORTED, this.onFragLoadEmergencyAborted, this); 34818 hls.on(Events.ERROR, this.onError, this); 34819 hls.on(Events.AUDIO_TRACK_SWITCHING, this.onAudioTrackSwitching, this); 34820 hls.on(Events.AUDIO_TRACK_SWITCHED, this.onAudioTrackSwitched, this); 34821 hls.on(Events.BUFFER_CREATED, this.onBufferCreated, this); 34822 hls.on(Events.BUFFER_FLUSHED, this.onBufferFlushed, this); 34823 hls.on(Events.LEVELS_UPDATED, this.onLevelsUpdated, this); 34824 hls.on(Events.FRAG_BUFFERED, this.onFragBuffered, this); 34825 } 34826 _unregisterListeners() { 34827 const { 34828 hls 34829 } = this;
vendor: 7,877 bytes, lines 34830-35049
34830 hls.off(Events.MEDIA_ATTACHED, this.onMediaAttached, this); 34831 hls.off(Events.MEDIA_DETACHING, this.onMediaDetaching, this); 34832 hls.off(Events.MANIFEST_LOADING, this.onManifestLoading, this); 34833 hls.off(Events.MANIFEST_PARSED, this.onManifestParsed, this); 34834 hls.off(Events.LEVEL_LOADED, this.onLevelLoaded, this); 34835 hls.off(Events.FRAG_LOAD_EMERGENCY_ABORTED, this.onFragLoadEmergencyAborted, this); 34836 hls.off(Events.ERROR, this.onError, this); 34837 hls.off(Events.AUDIO_TRACK_SWITCHING, this.onAudioTrackSwitching, this); 34838 hls.off(Events.AUDIO_TRACK_SWITCHED, this.onAudioTrackSwitched, this); 34839 hls.off(Events.BUFFER_CREATED, this.onBufferCreated, this); 34840 hls.off(Events.BUFFER_FLUSHED, this.onBufferFlushed, this); 34841 hls.off(Events.LEVELS_UPDATED, this.onLevelsUpdated, this); 34842 hls.off(Events.FRAG_BUFFERED, this.onFragBuffered, this); 34843 } 34844 onHandlerDestroying() { 34845 this._unregisterListeners(); 34846 super.onHandlerDestroying(); 34847 } 34848 startLoad(startPosition) { 34849 if (this.levels) { 34850 const { 34851 lastCurrentTime, 34852 hls 34853 } = this; 34854 this.stopLoad(); 34855 this.setInterval(TICK_INTERVAL); 34856 this.level = -1; 34857 if (!this.startFragRequested) { 34858 let startLevel = hls.startLevel; 34859 if (startLevel === -1) { 34860 if (hls.config.testBandwidth && this.levels.length > 1) { 34861 startLevel = 0; 34862 this.bitrateTest = true; 34863 } else { 34864 startLevel = hls.firstAutoLevel; 34865 } 34866 } 34867 hls.nextLoadLevel = startLevel; 34868 this.level = hls.loadLevel; 34869 this.loadedmetadata = false; 34870 } 34871 if (lastCurrentTime > 0 && startPosition === -1) { 34872 this.log(`Override startPosition with lastCurrentTime @${lastCurrentTime.toFixed(3)}`); 34873 startPosition = lastCurrentTime; 34874 } 34875 this.state = State.IDLE; 34876 this.nextLoadPosition = this.startPosition = this.lastCurrentTime = startPosition; 34877 this.tick(); 34878 } else { 34879 this._forceStartLoad = true; 34880 this.state = State.STOPPED; 34881 } 34882 } 34883 stopLoad() { 34884 this._forceStartLoad = false; 34885 super.stopLoad(); 34886 } 34887 doTick() { 34888 switch (this.state) { 34889 case State.WAITING_LEVEL: { 34890 const { 34891 levels, 34892 level 34893 } = this; 34894 const currentLevel = levels == null ? void 0 : levels[level]; 34895 const details = currentLevel == null ? void 0 : currentLevel.details; 34896 if (details && (!details.live || this.levelLastLoaded === currentLevel)) { 34897 if (this.waitForCdnTuneIn(details)) { 34898 break; 34899 } 34900 this.state = State.IDLE; 34901 break; 34902 } else if (this.hls.nextLoadLevel !== this.level) { 34903 this.state = State.IDLE; 34904 break; 34905 } 34906 break; 34907 } 34908 case State.FRAG_LOADING_WAITING_RETRY: 34909 { 34910 var _this$media; 34911 const now2 = self.performance.now(); 34912 const retryDate = this.retryDate; 34913 if (!retryDate || now2 >= retryDate || (_this$media = this.media) != null && _this$media.seeking) { 34914 const { 34915 levels, 34916 level 34917 } = this; 34918 const currentLevel = levels == null ? void 0 : levels[level]; 34919 this.resetStartWhenNotLoaded(currentLevel || null); 34920 this.state = State.IDLE; 34921 } 34922 } 34923 break; 34924 } 34925 if (this.state === State.IDLE) { 34926 this.doTickIdle(); 34927 } 34928 this.onTickEnd(); 34929 } 34930 onTickEnd() { 34931 super.onTickEnd(); 34932 this.checkBuffer(); 34933 this.checkFragmentChanged(); 34934 } 34935 doTickIdle() { 34936 const { 34937 hls, 34938 levelLastLoaded, 34939 levels, 34940 media 34941 } = this; 34942 if (levelLastLoaded === null || !media && (this.startFragRequested || !hls.config.startFragPrefetch)) { 34943 return; 34944 } 34945 if (this.altAudio && this.audioOnly) { 34946 return; 34947 } 34948 const level = this.buffering ? hls.nextLoadLevel : hls.loadLevel; 34949 if (!(levels != null && levels[level])) { 34950 return; 34951 } 34952 const levelInfo = levels[level]; 34953 const bufferInfo = this.getMainFwdBufferInfo(); 34954 if (bufferInfo === null) { 34955 return; 34956 } 34957 const lastDetails = this.getLevelDetails(); 34958 if (lastDetails && this._streamEnded(bufferInfo, lastDetails)) { 34959 const data = {}; 34960 if (this.altAudio) { 34961 data.type = "video"; 34962 } 34963 this.hls.trigger(Events.BUFFER_EOS, data); 34964 this.state = State.ENDED; 34965 return; 34966 } 34967 if (!this.buffering) { 34968 return; 34969 } 34970 if (hls.loadLevel !== level && hls.manualLevel === -1) { 34971 this.log(`Adapting to level ${level} from level ${this.level}`); 34972 } 34973 this.level = hls.nextLoadLevel = level; 34974 const levelDetails = levelInfo.details; 34975 if (!levelDetails || this.state === State.WAITING_LEVEL || levelDetails.live && this.levelLastLoaded !== levelInfo) { 34976 this.level = level; 34977 this.state = State.WAITING_LEVEL; 34978 return; 34979 } 34980 const bufferLen = bufferInfo.len; 34981 const maxBufLen = this.getMaxBufferLength(levelInfo.maxBitrate); 34982 if (bufferLen >= maxBufLen) { 34983 return; 34984 } 34985 if (this.backtrackFragment && this.backtrackFragment.start > bufferInfo.end) { 34986 this.backtrackFragment = null; 34987 } 34988 const targetBufferTime = this.backtrackFragment ? this.backtrackFragment.start : bufferInfo.end; 34989 let frag = this.getNextFragment(targetBufferTime, levelDetails); 34990 if (this.couldBacktrack && !this.fragPrevious && frag && frag.sn !== "initSegment" && this.fragmentTracker.getState(frag) !== FragmentState.OK) { 34991 var _this$backtrackFragme; 34992 const backtrackSn = ((_this$backtrackFragme = this.backtrackFragment) != null ? _this$backtrackFragme : frag).sn; 34993 const fragIdx = backtrackSn - levelDetails.startSN; 34994 const backtrackFrag = levelDetails.fragments[fragIdx - 1]; 34995 if (backtrackFrag && frag.cc === backtrackFrag.cc) { 34996 frag = backtrackFrag; 34997 this.fragmentTracker.removeFragment(backtrackFrag); 34998 } 34999 } else if (this.backtrackFragment && bufferInfo.len) { 35000 this.backtrackFragment = null; 35001 } 35002 if (frag && this.isLoopLoading(frag, targetBufferTime)) { 35003 const gapStart = frag.gap; 35004 if (!gapStart) { 35005 const type = this.audioOnly && !this.altAudio ? ElementaryStreamTypes.AUDIO : ElementaryStreamTypes.VIDEO; 35006 const mediaBuffer = (type === ElementaryStreamTypes.VIDEO ? this.videoBuffer : this.mediaBuffer) || this.media; 35007 if (mediaBuffer) { 35008 this.afterBufferFlushed(mediaBuffer, type, PlaylistLevelType.MAIN); 35009 } 35010 } 35011 frag = this.getNextFragmentLoopLoading(frag, levelDetails, bufferInfo, PlaylistLevelType.MAIN, maxBufLen); 35012 } 35013 if (!frag) { 35014 return; 35015 } 35016 if (frag.initSegment && !frag.initSegment.data && !this.bitrateTest) { 35017 frag = frag.initSegment; 35018 } 35019 this.loadFragment(frag, levelInfo, targetBufferTime); 35020 } 35021 loadFragment(frag, level, targetBufferTime) { 35022 const fragState = this.fragmentTracker.getState(frag); 35023 this.fragCurrent = frag; 35024 if (fragState === FragmentState.NOT_LOADED || fragState === FragmentState.PARTIAL) { 35025 if (frag.sn === "initSegment") { 35026 this._loadInitSegment(frag, level); 35027 } else if (this.bitrateTest) { 35028 this.log(`Fragment ${frag.sn} of level ${frag.level} is being downloaded to test bitrate and will not be buffered`); 35029 this._loadBitrateTestFrag(frag, level); 35030 } else { 35031 this.startFragRequested = true; 35032 super.loadFragment(frag, level, targetBufferTime); 35033 } 35034 } else { 35035 this.clearTrackerIfNeeded(frag); 35036 } 35037 } 35038 getBufferedFrag(position2) { 35039 return this.fragmentTracker.getBufferedFrag(position2, PlaylistLevelType.MAIN); 35040 } 35041 followingBufferedFrag(frag) { 35042 if (frag) { 35043 return this.getBufferedFrag(frag.end + 0.5); 35044 } 35045 return null; 35046 } 35047 /* 35048 on immediate level switch : 35049 - pause playback if playing
vendor: 9,010 bytes, lines 35050-35286
35050 - cancel any pending load request 35051 - and trigger a buffer flush 35052 */ 35053 immediateLevelSwitch() { 35054 this.abortCurrentFrag(); 35055 this.flushMainBuffer(0, Number.POSITIVE_INFINITY); 35056 } 35057 /** 35058 * try to switch ASAP without breaking video playback: 35059 * in order to ensure smooth but quick level switching, 35060 * we need to find the next flushable buffer range 35061 * we should take into account new segment fetch time 35062 */ 35063 nextLevelSwitch() { 35064 const { 35065 levels, 35066 media 35067 } = this; 35068 if (media != null && media.readyState) { 35069 let fetchdelay; 35070 const fragPlayingCurrent = this.getAppendedFrag(media.currentTime); 35071 if (fragPlayingCurrent && fragPlayingCurrent.start > 1) { 35072 this.flushMainBuffer(0, fragPlayingCurrent.start - 1); 35073 } 35074 const levelDetails = this.getLevelDetails(); 35075 if (levelDetails != null && levelDetails.live) { 35076 const bufferInfo = this.getMainFwdBufferInfo(); 35077 if (!bufferInfo || bufferInfo.len < levelDetails.targetduration * 2) { 35078 return; 35079 } 35080 } 35081 if (!media.paused && levels) { 35082 const nextLevelId = this.hls.nextLoadLevel; 35083 const nextLevel = levels[nextLevelId]; 35084 const fragLastKbps = this.fragLastKbps; 35085 if (fragLastKbps && this.fragCurrent) { 35086 fetchdelay = this.fragCurrent.duration * nextLevel.maxBitrate / (1e3 * fragLastKbps) + 1; 35087 } else { 35088 fetchdelay = 0; 35089 } 35090 } else { 35091 fetchdelay = 0; 35092 } 35093 const bufferedFrag = this.getBufferedFrag(media.currentTime + fetchdelay); 35094 if (bufferedFrag) { 35095 const nextBufferedFrag = this.followingBufferedFrag(bufferedFrag); 35096 if (nextBufferedFrag) { 35097 this.abortCurrentFrag(); 35098 const maxStart = nextBufferedFrag.maxStartPTS ? nextBufferedFrag.maxStartPTS : nextBufferedFrag.start; 35099 const fragDuration = nextBufferedFrag.duration; 35100 const startPts = Math.max(bufferedFrag.end, maxStart + Math.min(Math.max(fragDuration - this.config.maxFragLookUpTolerance, fragDuration * (this.couldBacktrack ? 0.5 : 0.125)), fragDuration * (this.couldBacktrack ? 0.75 : 0.25))); 35101 this.flushMainBuffer(startPts, Number.POSITIVE_INFINITY); 35102 } 35103 } 35104 } 35105 } 35106 abortCurrentFrag() { 35107 const fragCurrent = this.fragCurrent; 35108 this.fragCurrent = null; 35109 this.backtrackFragment = null; 35110 if (fragCurrent) { 35111 fragCurrent.abortRequests(); 35112 this.fragmentTracker.removeFragment(fragCurrent); 35113 } 35114 switch (this.state) { 35115 case State.KEY_LOADING: 35116 case State.FRAG_LOADING: 35117 case State.FRAG_LOADING_WAITING_RETRY: 35118 case State.PARSING: 35119 case State.PARSED: 35120 this.state = State.IDLE; 35121 break; 35122 } 35123 this.nextLoadPosition = this.getLoadPosition(); 35124 } 35125 flushMainBuffer(startOffset, endOffset) { 35126 super.flushMainBuffer(startOffset, endOffset, this.altAudio ? "video" : null); 35127 } 35128 onMediaAttached(event, data) { 35129 super.onMediaAttached(event, data); 35130 const media = data.media; 35131 this.onvplaying = this.onMediaPlaying.bind(this); 35132 this.onvseeked = this.onMediaSeeked.bind(this); 35133 media.addEventListener("playing", this.onvplaying); 35134 media.addEventListener("seeked", this.onvseeked); 35135 this.gapController = new GapController(this.config, media, this.fragmentTracker, this.hls); 35136 } 35137 onMediaDetaching() { 35138 const { 35139 media 35140 } = this; 35141 if (media && this.onvplaying && this.onvseeked) { 35142 media.removeEventListener("playing", this.onvplaying); 35143 media.removeEventListener("seeked", this.onvseeked); 35144 this.onvplaying = this.onvseeked = null; 35145 this.videoBuffer = null; 35146 } 35147 this.fragPlaying = null; 35148 if (this.gapController) { 35149 this.gapController.destroy(); 35150 this.gapController = null; 35151 } 35152 super.onMediaDetaching(); 35153 } 35154 onMediaPlaying() { 35155 this.tick(); 35156 } 35157 onMediaSeeked() { 35158 const media = this.media; 35159 const currentTime = media ? media.currentTime : null; 35160 if (isFiniteNumber(currentTime)) { 35161 this.log(`Media seeked to ${currentTime.toFixed(3)}`); 35162 } 35163 const bufferInfo = this.getMainFwdBufferInfo(); 35164 if (bufferInfo === null || bufferInfo.len === 0) { 35165 this.warn(`Main forward buffer length on "seeked" event ${bufferInfo ? bufferInfo.len : "empty"})`); 35166 return; 35167 } 35168 this.tick(); 35169 } 35170 onManifestLoading() { 35171 this.log("Trigger BUFFER_RESET"); 35172 this.hls.trigger(Events.BUFFER_RESET, void 0); 35173 this.fragmentTracker.removeAllFragments(); 35174 this.couldBacktrack = false; 35175 this.startPosition = this.lastCurrentTime = this.fragLastKbps = 0; 35176 this.levels = this.fragPlaying = this.backtrackFragment = this.levelLastLoaded = null; 35177 this.altAudio = this.audioOnly = this.startFragRequested = false; 35178 } 35179 onManifestParsed(event, data) { 35180 let aac = false; 35181 let heaac = false; 35182 data.levels.forEach((level) => { 35183 const codec = level.audioCodec; 35184 if (codec) { 35185 aac = aac || codec.indexOf("mp4a.40.2") !== -1; 35186 heaac = heaac || codec.indexOf("mp4a.40.5") !== -1; 35187 } 35188 }); 35189 this.audioCodecSwitch = aac && heaac && !changeTypeSupported(); 35190 if (this.audioCodecSwitch) { 35191 this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"); 35192 } 35193 this.levels = data.levels; 35194 this.startFragRequested = false; 35195 } 35196 onLevelLoading(event, data) { 35197 const { 35198 levels 35199 } = this; 35200 if (!levels || this.state !== State.IDLE) { 35201 return; 35202 } 35203 const level = levels[data.level]; 35204 if (!level.details || level.details.live && this.levelLastLoaded !== level || this.waitForCdnTuneIn(level.details)) { 35205 this.state = State.WAITING_LEVEL; 35206 } 35207 } 35208 onLevelLoaded(event, data) { 35209 var _curLevel$details; 35210 const { 35211 levels 35212 } = this; 35213 const newLevelId = data.level; 35214 const newDetails = data.details; 35215 const duration = newDetails.totalduration; 35216 if (!levels) { 35217 this.warn(`Levels were reset while loading level ${newLevelId}`); 35218 return; 35219 } 35220 this.log(`Level ${newLevelId} loaded [${newDetails.startSN},${newDetails.endSN}]${newDetails.lastPartSn ? `[part-${newDetails.lastPartSn}-${newDetails.lastPartIndex}]` : ""}, cc [${newDetails.startCC}, ${newDetails.endCC}] duration:${duration}`); 35221 const curLevel = levels[newLevelId]; 35222 const fragCurrent = this.fragCurrent; 35223 if (fragCurrent && (this.state === State.FRAG_LOADING || this.state === State.FRAG_LOADING_WAITING_RETRY)) { 35224 if (fragCurrent.level !== data.level && fragCurrent.loader) { 35225 this.abortCurrentFrag(); 35226 } 35227 } 35228 let sliding = 0; 35229 if (newDetails.live || (_curLevel$details = curLevel.details) != null && _curLevel$details.live) { 35230 var _this$levelLastLoaded; 35231 this.checkLiveUpdate(newDetails); 35232 if (newDetails.deltaUpdateFailed) { 35233 return; 35234 } 35235 sliding = this.alignPlaylists(newDetails, curLevel.details, (_this$levelLastLoaded = this.levelLastLoaded) == null ? void 0 : _this$levelLastLoaded.details); 35236 } 35237 curLevel.details = newDetails; 35238 this.levelLastLoaded = curLevel; 35239 this.hls.trigger(Events.LEVEL_UPDATED, { 35240 details: newDetails, 35241 level: newLevelId 35242 }); 35243 if (this.state === State.WAITING_LEVEL) { 35244 if (this.waitForCdnTuneIn(newDetails)) { 35245 return; 35246 } 35247 this.state = State.IDLE; 35248 } 35249 if (!this.startFragRequested) { 35250 this.setStartPosition(newDetails, sliding); 35251 } else if (newDetails.live) { 35252 this.synchronizeToLiveEdge(newDetails); 35253 } 35254 this.tick(); 35255 } 35256 _handleFragmentLoadProgress(data) { 35257 var _frag$initSegment; 35258 const { 35259 frag, 35260 part, 35261 payload 35262 } = data; 35263 const { 35264 levels 35265 } = this; 35266 if (!levels) { 35267 this.warn(`Levels were reset while fragment load was in progress. Fragment ${frag.sn} of level ${frag.level} will not be buffered`); 35268 return; 35269 } 35270 const currentLevel = levels[frag.level]; 35271 const details = currentLevel.details; 35272 if (!details) { 35273 this.warn(`Dropping fragment ${frag.sn} of level ${frag.level} after level details were reset`); 35274 this.fragmentTracker.removeFragment(frag); 35275 return; 35276 } 35277 const videoCodec = currentLevel.videoCodec; 35278 const accurateTimeOffset = details.PTSKnown || !details.live; 35279 const initSegmentData = (_frag$initSegment = frag.initSegment) == null ? void 0 : _frag$initSegment.data; 35280 const audioCodec = this._getAudioCodec(currentLevel); 35281 const transmuxer = this.transmuxer = this.transmuxer || new TransmuxerInterface(this.hls, PlaylistLevelType.MAIN, this._handleTransmuxComplete.bind(this), this._handleTransmuxerFlush.bind(this)); 35282 const partIndex = part ? part.index : -1; 35283 const partial = partIndex !== -1; 35284 const chunkMeta = new ChunkMetadata(frag.level, frag.sn, frag.stats.chunkCount, payload.byteLength, partIndex, partial); 35285 const initPTS = this.initPTS[frag.cc]; 35286 transmuxer.push(payload, initSegmentData, audioCodec, videoCodec, frag, part, details.totalduration, accurateTimeOff
35286set, chunkMeta, initPTS); 35287 } 35288 onAudioTrackSwitching(event, data) { 35289 const fromAltAudio = this.altAudio; 35290 const altAudio = !!data.url; 35291 if (!altAudio) { 35292 if (this.mediaBuffer !== this.media) { 35293 this.log("Switching on main audio, use media.buffered to schedule main fragment loading"); 35294 this.mediaBuffer = this.media; 35295 const fragCurrent = this.fragCurrent; 35296 if (fragCurrent) { 35297 this.log("Switching to main audio track, cancel main fragment load"); 35298 fragCurrent.abortRequests(); 35299 this.fragmentTracker.removeFragment(fragCurrent); 35300 } 35301 this.resetTransmuxer(); 35302 this.resetLoadingState(); 35303 } else if (this.audioOnly) { 35304 this.resetTransmuxer(); 35305 } 35306 const hls = this.hls; 35307 if (fromAltAudio) { 35308 hls.trigger(Events.BUFFER_FLUSHING, { 35309 startOffset: 0, 35310 endOffset: Number.POSITIVE_INFINITY, 35311 type: null 35312 }); 35313 this.fragmentTracker.removeAllFragments(); 35314 } 35315 hls.trigger(Events.AUDIO_TRACK_SWITCHED, data); 35316 } 35317 } 35318 onAudioTrackSwitched(event, data) { 35319 const trackId = data.id; 35320 const altAudio = !!this.hls.audioTracks[trackId].url; 35321 if (altAudio) { 35322 const videoBuffer = this.videoBuffer; 35323 if (videoBuffer && this.mediaBuffer !== videoBuffer) { 35324 this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"); 35325 this.mediaBuffer = videoBuffer; 35326 } 35327 } 35328 this.altAudio = altAudio; 35329 this.tick(); 35330 } 35331 onBufferCreated(event, data) { 35332 const tracks = data.tracks; 35333 let mediaTrack; 35334 let name; 35335 let alternate = false; 35336 for (const type in tracks) { 35337 const track = tracks[type]; 35338 if (track.id === "main") { 35339 name = type; 35340 mediaTrack = track; 35341 if (type === "video") { 35342 const videoTrack = tracks[type]; 35343 if (videoTrack) { 35344 this.videoBuffer = videoTrack.buffer; 35345 } 35346 } 35347 } else { 35348 alternate = true; 35349 } 35350 } 35351 if (alternate && mediaTrack) { 35352 this.log(`Alternate track found, use ${name}.buffered to schedule main fragment loading`); 35353 this.mediaBuffer = mediaTrack.buffer; 35354 } else { 35355 this.mediaBuffer = this.media; 35356 } 35357 } 35358 onFragBuffered(event, data) { 35359 const { 35360 frag, 35361 part 35362 } = data; 35363 if (frag && frag.type !== PlaylistLevelType.MAIN) { 35364 return; 35365 } 35366 if (this.fragContextChanged(frag)) { 35367 this.warn(`Fragment ${frag.sn}${part ? " p: " + part.index : ""} of level ${frag.level} finished buffering, but was aborted. state: ${this.state}`); 35368 if (this.state === State.PARSED) { 35369 this.state = State.IDLE; 35370 } 35371 return; 35372 } 35373 const stats = part ? part.stats : frag.stats; 35374 this.fragLastKbps = Math.round(8 * stats.total / (stats.buffering.end - stats.loading.first)); 35375 if (frag.sn !== "initSegment") { 35376 this.fragPrevious = frag; 35377 } 35378 this.fragBufferedComplete(frag, part); 35379 } 35380 onError(event, data) { 35381 var _data$context; 35382 if (data.fatal) { 35383 this.state = State.ERROR; 35384 return; 35385 } 35386 switch (data.details) { 35387 case ErrorDetails.FRAG_GAP: 35388 case ErrorDetails.FRAG_PARSING_ERROR: 35389 case ErrorDetails.FRAG_DECRYPT_ERROR: 35390 case ErrorDetails.FRAG_LOAD_ERROR: 35391 case ErrorDetails.FRAG_LOAD_TIMEOUT: 35392 case ErrorDetails.KEY_LOAD_ERROR: 35393 case ErrorDetails.KEY_LOAD_TIMEOUT: 35394 this.onFragmentOrKeyLoadError(PlaylistLevelType.MAIN, data); 35395 break; 35396 case ErrorDetails.LEVEL_LOAD_ERROR: 35397 case ErrorDetails.LEVEL_LOAD_TIMEOUT: 35398 case ErrorDetails.LEVEL_PARSING_ERROR: 35399 if (!data.levelRetry && this.state === State.WAITING_LEVEL && ((_data$context = data.context) == null ? void 0 : _data$context.type) === PlaylistContextType.LEVEL) { 35400 this.state = State.IDLE; 35401 } 35402 break; 35403 case ErrorDetails.BUFFER_APPEND_ERROR: 35404 case ErrorDetails.BUFFER_FULL_ERROR: 35405 if (!data.parent || data.parent !== "main") { 35406 return; 35407 } 35408 if (data.details === ErrorDetails.BUFFER_APPEND_ERROR) { 35409 this.resetLoadingState(); 35410 return; 35411 } 35412 if (this.reduceLengthAndFlushBuffer(data)) { 35413 this.flushMainBuffer(0, Number.POSITIVE_INFINITY); 35414 } 35415 break; 35416 case ErrorDetails.INTERNAL_EXCEPTION: 35417 this.recoverWorkerError(data); 35418 break; 35419 } 35420 } 35421 // Checks the health of the buffer and attempts to resolve playback stalls. 35422 checkBuffer() { 35423 const { 35424 media, 35425 gapController 35426 } = this; 35427 if (!media || !gapController || !media.readyState) { 35428 return; 35429 } 35430 if (this.loadedmetadata || !BufferHelper.getBuffered(media).length) { 35431 const activeFrag = this.state !== State.IDLE ? this.fragCurrent : null; 35432 gapController.poll(this.lastCurrentTime, activeFrag); 35433 } 35434 this.lastCurrentTime = media.currentTime; 35435 } 35436 onFragLoadEmergencyAborted() { 35437 this.state = State.IDLE; 35438 if (!this.loadedmetadata) { 35439 this.startFragRequested = false;
vendor: 9,205 bytes, lines 35440-35716
35440 this.nextLoadPosition = this.startPosition; 35441 } 35442 this.tickImmediate(); 35443 } 35444 onBufferFlushed(event, { 35445 type 35446 }) { 35447 if (type !== ElementaryStreamTypes.AUDIO || this.audioOnly && !this.altAudio) { 35448 const mediaBuffer = (type === ElementaryStreamTypes.VIDEO ? this.videoBuffer : this.mediaBuffer) || this.media; 35449 this.afterBufferFlushed(mediaBuffer, type, PlaylistLevelType.MAIN); 35450 this.tick(); 35451 } 35452 } 35453 onLevelsUpdated(event, data) { 35454 if (this.level > -1 && this.fragCurrent) { 35455 this.level = this.fragCurrent.level; 35456 } 35457 this.levels = data.levels; 35458 } 35459 swapAudioCodec() { 35460 this.audioCodecSwap = !this.audioCodecSwap; 35461 } 35462 /** 35463 * Seeks to the set startPosition if not equal to the mediaElement's current time. 35464 */ 35465 seekToStartPos() { 35466 const { 35467 media 35468 } = this; 35469 if (!media) { 35470 return; 35471 } 35472 const currentTime = media.currentTime; 35473 let startPosition = this.startPosition; 35474 if (startPosition >= 0 && currentTime < startPosition) { 35475 if (media.seeking) { 35476 this.log(`could not seek to ${startPosition}, already seeking at ${currentTime}`); 35477 return; 35478 } 35479 const buffered = BufferHelper.getBuffered(media); 35480 const bufferStart = buffered.length ? buffered.start(0) : 0; 35481 const delta = bufferStart - startPosition; 35482 if (delta > 0 && (delta < this.config.maxBufferHole || delta < this.config.maxFragLookUpTolerance)) { 35483 this.log(`adjusting start position by ${delta} to match buffer start`); 35484 startPosition += delta; 35485 this.startPosition = startPosition; 35486 } 35487 this.log(`seek to target start position ${startPosition} from current time ${currentTime}`); 35488 media.currentTime = startPosition; 35489 } 35490 } 35491 _getAudioCodec(currentLevel) { 35492 let audioCodec = this.config.defaultAudioCodec || currentLevel.audioCodec; 35493 if (this.audioCodecSwap && audioCodec) { 35494 this.log("Swapping audio codec"); 35495 if (audioCodec.indexOf("mp4a.40.5") !== -1) { 35496 audioCodec = "mp4a.40.2"; 35497 } else { 35498 audioCodec = "mp4a.40.5"; 35499 } 35500 } 35501 return audioCodec; 35502 } 35503 _loadBitrateTestFrag(frag, level) { 35504 frag.bitrateTest = true; 35505 this._doFragLoad(frag, level).then((data) => { 35506 const { 35507 hls 35508 } = this; 35509 if (!data || this.fragContextChanged(frag)) { 35510 return; 35511 } 35512 level.fragmentError = 0; 35513 this.state = State.IDLE; 35514 this.startFragRequested = false; 35515 this.bitrateTest = false; 35516 const stats = frag.stats; 35517 stats.parsing.start = stats.parsing.end = stats.buffering.start = stats.buffering.end = self.performance.now(); 35518 hls.trigger(Events.FRAG_LOADED, data); 35519 frag.bitrateTest = false; 35520 }); 35521 } 35522 _handleTransmuxComplete(transmuxResult) { 35523 var _id3$samples; 35524 const id = "main"; 35525 const { 35526 hls 35527 } = this; 35528 const { 35529 remuxResult, 35530 chunkMeta 35531 } = transmuxResult; 35532 const context = this.getCurrentContext(chunkMeta); 35533 if (!context) { 35534 this.resetWhenMissingContext(chunkMeta); 35535 return; 35536 } 35537 const { 35538 frag, 35539 part, 35540 level 35541 } = context; 35542 const { 35543 video, 35544 text, 35545 id3, 35546 initSegment 35547 } = remuxResult; 35548 const { 35549 details 35550 } = level; 35551 const audio = this.altAudio ? void 0 : remuxResult.audio; 35552 if (this.fragContextChanged(frag)) { 35553 this.fragmentTracker.removeFragment(frag); 35554 return; 35555 } 35556 this.state = State.PARSING; 35557 if (initSegment) { 35558 if (initSegment != null && initSegment.tracks) { 35559 const mapFragment = frag.initSegment || frag; 35560 this._bufferInitSegment(level, initSegment.tracks, mapFragment, chunkMeta); 35561 hls.trigger(Events.FRAG_PARSING_INIT_SEGMENT, { 35562 frag: mapFragment, 35563 id, 35564 tracks: initSegment.tracks 35565 }); 35566 } 35567 const initPTS = initSegment.initPTS; 35568 const timescale = initSegment.timescale; 35569 if (isFiniteNumber(initPTS)) { 35570 this.initPTS[frag.cc] = { 35571 baseTime: initPTS, 35572 timescale 35573 }; 35574 hls.trigger(Events.INIT_PTS_FOUND, { 35575 frag, 35576 id, 35577 initPTS, 35578 timescale 35579 }); 35580 } 35581 } 35582 if (video && details && frag.sn !== "initSegment") { 35583 const prevFrag = details.fragments[frag.sn - 1 - details.startSN]; 35584 const isFirstFragment = frag.sn === details.startSN; 35585 const isFirstInDiscontinuity = !prevFrag || frag.cc > prevFrag.cc; 35586 if (remuxResult.independent !== false) { 35587 const { 35588 startPTS, 35589 endPTS, 35590 startDTS, 35591 endDTS 35592 } = video; 35593 if (part) { 35594 part.elementaryStreams[video.type] = { 35595 startPTS, 35596 endPTS, 35597 startDTS, 35598 endDTS 35599 }; 35600 } else { 35601 if (video.firstKeyFrame && video.independent && chunkMeta.id === 1 && !isFirstInDiscontinuity) { 35602 this.couldBacktrack = true; 35603 } 35604 if (video.dropped && video.independent) { 35605 const bufferInfo = this.getMainFwdBufferInfo(); 35606 const targetBufferTime = (bufferInfo ? bufferInfo.end : this.getLoadPosition()) + this.config.maxBufferHole; 35607 const startTime = video.firstKeyFramePTS ? video.firstKeyFramePTS : startPTS; 35608 if (!isFirstFragment && targetBufferTime < startTime - this.config.maxBufferHole && !isFirstInDiscontinuity) { 35609 this.backtrack(frag); 35610 return; 35611 } else if (isFirstInDiscontinuity) { 35612 frag.gap = true; 35613 } 35614 frag.setElementaryStreamInfo(video.type, frag.start, endPTS, frag.start, endDTS, true); 35615 } else if (isFirstFragment && startPTS > MAX_START_GAP_JUMP) { 35616 frag.gap = true; 35617 } 35618 } 35619 frag.setElementaryStreamInfo(video.type, startPTS, endPTS, startDTS, endDTS); 35620 if (this.backtrackFragment) { 35621 this.backtrackFragment = frag; 35622 } 35623 this.bufferFragmentData(video, frag, part, chunkMeta, isFirstFragment || isFirstInDiscontinuity); 35624 } else if (isFirstFragment || isFirstInDiscontinuity) { 35625 frag.gap = true; 35626 } else { 35627 this.backtrack(frag); 35628 return; 35629 } 35630 } 35631 if (audio) { 35632 const { 35633 startPTS, 35634 endPTS, 35635 startDTS, 35636 endDTS 35637 } = audio; 35638 if (part) { 35639 part.elementaryStreams[ElementaryStreamTypes.AUDIO] = { 35640 startPTS, 35641 endPTS, 35642 startDTS, 35643 endDTS 35644 }; 35645 } 35646 frag.setElementaryStreamInfo(ElementaryStreamTypes.AUDIO, startPTS, endPTS, startDTS, endDTS); 35647 this.bufferFragmentData(audio, frag, part, chunkMeta); 35648 } 35649 if (details && id3 != null && (_id3$samples = id3.samples) != null && _id3$samples.length) { 35650 const emittedID3 = { 35651 id, 35652 frag, 35653 details, 35654 samples: id3.samples 35655 }; 35656 hls.trigger(Events.FRAG_PARSING_METADATA, emittedID3); 35657 } 35658 if (details && text) { 35659 const emittedText = { 35660 id, 35661 frag, 35662 details, 35663 samples: text.samples 35664 }; 35665 hls.trigger(Events.FRAG_PARSING_USERDATA, emittedText); 35666 } 35667 } 35668 _bufferInitSegment(currentLevel, tracks, frag, chunkMeta) { 35669 if (this.state !== State.PARSING) { 35670 return; 35671 } 35672 this.audioOnly = !!tracks.audio && !tracks.video; 35673 if (this.altAudio && !this.audioOnly) { 35674 delete tracks.audio; 35675 } 35676 const { 35677 audio, 35678 video, 35679 audiovideo 35680 } = tracks; 35681 if (audio) { 35682 let audioCodec = currentLevel.audioCodec; 35683 const ua3 = navigator.userAgent.toLowerCase(); 35684 if (this.audioCodecSwitch) { 35685 if (audioCodec) { 35686 if (audioCodec.indexOf("mp4a.40.5") !== -1) { 35687 audioCodec = "mp4a.40.2"; 35688 } else { 35689 audioCodec = "mp4a.40.5"; 35690 } 35691 } 35692 const audioMetadata = audio.metadata; 35693 if (audioMetadata && "channelCount" in audioMetadata && (audioMetadata.channelCount || 1) !== 1 && ua3.indexOf("firefox") === -1) { 35694 audioCodec = "mp4a.40.5"; 35695 } 35696 } 35697 if (audioCodec && audioCodec.indexOf("mp4a.40.5") !== -1 && ua3.indexOf("android") !== -1 && audio.container !== "audio/mpeg") { 35698 audioCodec = "mp4a.40.2"; 35699 this.log(`Android: force audio codec to ${audioCodec}`); 35700 } 35701 if (currentLevel.audioCodec && currentLevel.audioCodec !== audioCodec) { 35702 this.log(`Swapping manifest audio codec "${currentLevel.audioCodec}" for "${audioCodec}"`); 35703 } 35704 audio.levelCodec = audioCodec; 35705 audio.id = "main"; 35706 this.log(`Init audio buffer, container:${audio.container}, codecs[selected/level/parsed]=[${audioCodec || ""}/${currentLevel.audioCodec || ""}/${audio.codec}]`); 35707 } 35708 if (video) { 35709 video.levelCodec = currentLevel.videoCodec; 35710 video.id = "main"; 35711 this.log(`Init video buffer, container:${video.container}, codecs[level/parsed]=[${currentLevel.videoCodec || ""}/${video.codec}]`); 35712 } 35713 if (audiovideo) { 35714 this.log(`Init audiovideo buffer, container:${audiovideo.container}, codecs[level/parsed]=[${currentLevel.codecs}/${audiovideo.codec}]`); 35715 } 35716 this.hls.trigger(Events.BUFFER_CODECS, tracks);
35717 Object.keys(tracks).forEach((trackName) => { 35718 const track = tracks[trackName]; 35719 const initSegment = track.initSegment; 35720 if (initSegment != null && initSegment.byteLength) { 35721 this.hls.trigger(Events.BUFFER_APPENDING, { 35722 type: trackName, 35723 data: initSegment, 35724 frag, 35725 part: null, 35726 chunkMeta, 35727 parent: frag.type 35728 }); 35729 } 35730 }); 35731 this.tickImmediate(); 35732 } 35733 getMainFwdBufferInfo() { 35734 return this.getFwdBufferInfo(this.mediaBuffer ? this.mediaBuffer : this.media, PlaylistLevelType.MAIN); 35735 } 35736 backtrack(frag) { 35737 this.couldBacktrack = true; 35738 this.backtrackFragment = frag; 35739 this.resetTransmuxer(); 35740 this.flushBufferGap(frag); 35741 this.fragmentTracker.removeFragment(frag); 35742 this.fragPrevious = null; 35743 this.nextLoadPosition = frag.start; 35744 this.state = State.IDLE; 35745 } 35746 checkFragmentChanged() { 35747 const video = this.media; 35748 let fragPlayingCurrent = null; 35749 if (video && video.readyState > 1 && video.seeking === false) { 35750 const currentTime = video.currentTime; 35751 if (BufferHelper.isBuffered(video, currentTime)) { 35752 fragPlayingCurrent = this.getAppendedFrag(currentTime); 35753 } else if (BufferHelper.isBuffered(video, currentTime + 0.1)) { 35754 fragPlayingCurrent = this.getAppendedFrag(currentTime + 0.1); 35755 } 35756 if (fragPlayingCurrent) { 35757 this.backtrackFragment = null; 35758 const fragPlaying = this.fragPlaying; 35759 const fragCurrentLevel = fragPlayingCurrent.level; 35760 if (!fragPlaying || fragPlayingCurrent.sn !== fragPlaying.sn || fragPlaying.level !== fragCurrentLevel) { 35761 this.fragPlaying = fragPlayingCurrent; 35762 this.hls.trigger(Events.FRAG_CHANGED, { 35763 frag: fragPlayingCurrent 35764 }); 35765 if (!fragPlaying || fragPlaying.level !== fragCurrentLevel) { 35766 this.hls.trigger(Events.LEVEL_SWITCHED, { 35767 level: fragCurrentLevel 35768 }); 35769 } 35770 } 35771 } 35772 } 35773 } 35774 get nextLevel() { 35775 const frag = this.nextBufferedFrag; 35776 if (frag) { 35777 return frag.level; 35778 } 35779 return -1; 35780 } 35781 get currentFrag() { 35782 const media = this.media; 35783 if (media) { 35784 return this.fragPlaying || this.getAppendedFrag(media.currentTime); 35785 } 35786 return null; 35787 } 35788 get currentProgramDateTime() { 35789 const media = this.media; 35790 if (media) { 35791 const currentTime = media.currentTime; 35792 const frag = this.currentFrag; 35793 if (frag && isFiniteNumber(currentTime) && isFiniteNumber(frag.programDateTime)) { 35794 const epocMs = frag.programDateTime + (currentTime - frag.start) * 1e3; 35795 return new Date(epocMs); 35796 } 35797 } 35798 return null; 35799 } 35800 get currentLevel() { 35801 const frag = this.currentFrag; 35802 if (frag) { 35803 return frag.level; 35804 } 35805 return -1; 35806 } 35807 get nextBufferedFrag() { 35808 const frag = this.currentFrag; 35809 if (frag) { 35810 return this.followingBufferedFrag(frag); 35811 } 35812 return null; 35813 } 35814 get forceStartLoad() { 35815 return this._forceStartLoad; 35816 } 35817}; 35818var Hls = class _Hls { 35819 /** 35820 * Get the video-dev/hls.js package version. 35821 */ 35822 static get version() { 35823 return "1.5.20"; 35824 } 35825 /** 35826 * Check if the required MediaSource Extensions are available. 35827 */ 35828 static isMSESupported() { 35829 return isMSESupported(); 35830 } 35831 /** 35832 * Check if MediaSource Extensions are available and isTypeSupported checks pass for any baseline codecs. 35833 */ 35834 static isSupported() { 35835 return isSupported(); 35836 } 35837 /** 35838 * Get the MediaSource global used for MSE playback (ManagedMediaSource, MediaSource, or WebKitMediaSource). 35839 */ 35840 static getMediaSource() { 35841 return getMediaSource(); 35842 } 35843 static get Events() { 35844 return Events; 35845 } 35846 static get ErrorTypes() { 35847 return ErrorTypes; 35848 } 35849 static get ErrorDetails() { 35850 return ErrorDetails; 35851 } 35852 /** 35853 * Get the default configuration applied to new instances. 35854 */ 35855 static get DefaultConfig() { 35856 if (!_Hls.defaultConfig) { 35857 return hlsDefaultConfig; 35858 } 35859 return _Hls.defaultConfig; 35860 } 35861 /** 35862 * Replace the default configuration applied to new instances. 35863 */ 35864 static set DefaultConfig(defaultConfig) {
vendor: 5,126 bytes, lines 35865-35978
35865 _Hls.defaultConfig = defaultConfig; 35866 } 35867 /** 35868 * Creates an instance of an HLS client that can attach to exactly one `HTMLMediaElement`. 35869 * @param userConfig - Configuration options applied over `Hls.DefaultConfig` 35870 */ 35871 constructor(userConfig = {}) { 35872 this.config = void 0; 35873 this.userConfig = void 0; 35874 this.coreComponents = void 0; 35875 this.networkControllers = void 0; 35876 this.started = false; 35877 this._emitter = new EventEmitter(); 35878 this._autoLevelCapping = -1; 35879 this._maxHdcpLevel = null; 35880 this.abrController = void 0; 35881 this.bufferController = void 0; 35882 this.capLevelController = void 0; 35883 this.latencyController = void 0; 35884 this.levelController = void 0; 35885 this.streamController = void 0; 35886 this.audioTrackController = void 0; 35887 this.subtitleTrackController = void 0; 35888 this.emeController = void 0; 35889 this.cmcdController = void 0; 35890 this._media = null; 35891 this.url = null; 35892 this.triggeringException = void 0; 35893 enableLogs(userConfig.debug || false, "Hls instance"); 35894 const config = this.config = mergeConfig(_Hls.DefaultConfig, userConfig); 35895 this.userConfig = userConfig; 35896 if (config.progressive) { 35897 enableStreamingMode(config); 35898 } 35899 const { 35900 abrController: ConfigAbrController, 35901 bufferController: ConfigBufferController, 35902 capLevelController: ConfigCapLevelController, 35903 errorController: ConfigErrorController, 35904 fpsController: ConfigFpsController 35905 } = config; 35906 const errorController = new ConfigErrorController(this); 35907 const abrController = this.abrController = new ConfigAbrController(this); 35908 const bufferController = this.bufferController = new ConfigBufferController(this); 35909 const capLevelController = this.capLevelController = new ConfigCapLevelController(this); 35910 const fpsController = new ConfigFpsController(this); 35911 const playListLoader = new PlaylistLoader(this); 35912 const id3TrackController = new ID3TrackController(this); 35913 const ConfigContentSteeringController = config.contentSteeringController; 35914 const contentSteering = ConfigContentSteeringController ? new ConfigContentSteeringController(this) : null; 35915 const levelController = this.levelController = new LevelController(this, contentSteering); 35916 const fragmentTracker = new FragmentTracker(this); 35917 const keyLoader = new KeyLoader(this.config); 35918 const streamController = this.streamController = new StreamController(this, fragmentTracker, keyLoader); 35919 capLevelController.setStreamController(streamController); 35920 fpsController.setStreamController(streamController); 35921 const networkControllers = [playListLoader, levelController, streamController]; 35922 if (contentSteering) { 35923 networkControllers.splice(1, 0, contentSteering); 35924 } 35925 this.networkControllers = networkControllers; 35926 const coreComponents = [abrController, bufferController, capLevelController, fpsController, id3TrackController, fragmentTracker]; 35927 this.audioTrackController = this.createController(config.audioTrackController, networkControllers); 35928 const AudioStreamControllerClass = config.audioStreamController; 35929 if (AudioStreamControllerClass) { 35930 networkControllers.push(new AudioStreamControllerClass(this, fragmentTracker, keyLoader)); 35931 } 35932 this.subtitleTrackController = this.createController(config.subtitleTrackController, networkControllers); 35933 const SubtitleStreamControllerClass = config.subtitleStreamController; 35934 if (SubtitleStreamControllerClass) { 35935 networkControllers.push(new SubtitleStreamControllerClass(this, fragmentTracker, keyLoader)); 35936 } 35937 this.createController(config.timelineController, coreComponents); 35938 keyLoader.emeController = this.emeController = this.createController(config.emeController, coreComponents); 35939 this.cmcdController = this.createController(config.cmcdController, coreComponents); 35940 this.latencyController = this.createController(LatencyController, coreComponents); 35941 this.coreComponents = coreComponents; 35942 networkControllers.push(errorController); 35943 const onErrorOut = errorController.onErrorOut; 35944 if (typeof onErrorOut === "function") { 35945 this.on(Events.ERROR, onErrorOut, errorController); 35946 } 35947 } 35948 createController(ControllerClass, components2) { 35949 if (ControllerClass) { 35950 const controllerInstance = new ControllerClass(this); 35951 if (components2) { 35952 components2.push(controllerInstance); 35953 } 35954 return controllerInstance; 35955 } 35956 return null; 35957 } 35958 // Delegate the EventEmitter through the public API of Hls.js 35959 on(event, listener, context = this) { 35960 this._emitter.on(event, listener, context); 35961 } 35962 once(event, listener, context = this) { 35963 this._emitter.once(event, listener, context); 35964 } 35965 removeAllListeners(event) { 35966 this._emitter.removeAllListeners(event); 35967 } 35968 off(event, listener, context = this, once) { 35969 this._emitter.off(event, listener, context, once); 35970 } 35971 listeners(event) { 35972 return this._emitter.listeners(event); 35973 } 35974 emit(event, name, eventObject) { 35975 return this._emitter.emit(event, name, eventObject); 35976 } 35977 trigger(event, eventObject) { 35978 if (this.config.debug) {
vendor: 16,384 bytes, lines 35979-36491
35979 return this.emit(event, event, eventObject); 35980 } else { 35981 try { 35982 return this.emit(event, event, eventObject); 35983 } catch (error) { 35984 logger.error("An internal error happened while handling event " + event + '. Error message: "' + error.message + '". Here is a stacktrace:', error); 35985 if (!this.triggeringException) { 35986 this.triggeringException = true; 35987 const fatal = event === Events.ERROR; 35988 this.trigger(Events.ERROR, { 35989 type: ErrorTypes.OTHER_ERROR, 35990 details: ErrorDetails.INTERNAL_EXCEPTION, 35991 fatal, 35992 event, 35993 error 35994 }); 35995 this.triggeringException = false; 35996 } 35997 } 35998 } 35999 return false; 36000 } 36001 listenerCount(event) { 36002 return this._emitter.listenerCount(event); 36003 } 36004 /** 36005 * Dispose of the instance 36006 */ 36007 destroy() { 36008 logger.log("destroy"); 36009 this.trigger(Events.DESTROYING, void 0); 36010 this.detachMedia(); 36011 this.removeAllListeners(); 36012 this._autoLevelCapping = -1; 36013 this.url = null; 36014 this.networkControllers.forEach((component) => component.destroy()); 36015 this.networkControllers.length = 0; 36016 this.coreComponents.forEach((component) => component.destroy()); 36017 this.coreComponents.length = 0; 36018 const config = this.config; 36019 config.xhrSetup = config.fetchSetup = void 0; 36020 this.userConfig = null; 36021 } 36022 /** 36023 * Attaches Hls.js to a media element 36024 */ 36025 attachMedia(media) { 36026 logger.log("attachMedia"); 36027 this._media = media; 36028 this.trigger(Events.MEDIA_ATTACHING, { 36029 media 36030 }); 36031 } 36032 /** 36033 * Detach Hls.js from the media 36034 */ 36035 detachMedia() { 36036 logger.log("detachMedia"); 36037 this.trigger(Events.MEDIA_DETACHING, void 0); 36038 this._media = null; 36039 } 36040 /** 36041 * Set the source URL. Can be relative or absolute. 36042 */ 36043 loadSource(url) { 36044 this.stopLoad(); 36045 const media = this.media; 36046 const loadedSource = this.url; 36047 const loadingSource = this.url = urlToolkitExports.buildAbsoluteURL(self.location.href, url, { 36048 alwaysNormalize: true 36049 }); 36050 this._autoLevelCapping = -1; 36051 this._maxHdcpLevel = null; 36052 logger.log(`loadSource:${loadingSource}`); 36053 if (media && loadedSource && (loadedSource !== loadingSource || this.bufferController.hasSourceTypes())) { 36054 this.detachMedia(); 36055 this.attachMedia(media); 36056 } 36057 this.trigger(Events.MANIFEST_LOADING, { 36058 url 36059 }); 36060 } 36061 /** 36062 * Start loading data from the stream source. 36063 * Depending on default config, client starts loading automatically when a source is set. 36064 * 36065 * @param startPosition - Set the start position to stream from. 36066 * Defaults to -1 (None: starts from earliest point) 36067 */ 36068 startLoad(startPosition = -1) { 36069 logger.log(`startLoad(${startPosition})`); 36070 this.started = true; 36071 this.resumeBuffering(); 36072 for (let i3 = 0; i3 < this.networkControllers.length; i3++) { 36073 this.networkControllers[i3].startLoad(startPosition); 36074 if (!this.started || !this.networkControllers) { 36075 break; 36076 } 36077 } 36078 } 36079 /** 36080 * Stop loading of any stream data. 36081 */ 36082 stopLoad() { 36083 logger.log("stopLoad"); 36084 this.started = false; 36085 for (let i3 = 0; i3 < this.networkControllers.length; i3++) { 36086 this.networkControllers[i3].stopLoad(); 36087 if (this.started || !this.networkControllers) { 36088 break; 36089 } 36090 } 36091 } 36092 /** 36093 * Resumes stream controller segment loading after `pauseBuffering` has been called. 36094 */ 36095 resumeBuffering() { 36096 logger.log(`resume buffering`); 36097 this.networkControllers.forEach((controller) => { 36098 if (controller.resumeBuffering) { 36099 controller.resumeBuffering(); 36100 } 36101 }); 36102 } 36103 /** 36104 * Prevents stream controller from loading new segments until `resumeBuffering` is called. 36105 * This allows for media buffering to be paused without interupting playlist loading. 36106 */ 36107 pauseBuffering() { 36108 logger.log(`pause buffering`); 36109 this.networkControllers.forEach((controller) => { 36110 if (controller.pauseBuffering) { 36111 controller.pauseBuffering(); 36112 } 36113 }); 36114 } 36115 /** 36116 * Swap through possible audio codecs in the stream (for example to switch from stereo to 5.1) 36117 */ 36118 swapAudioCodec() { 36119 logger.log("swapAudioCodec"); 36120 this.streamController.swapAudioCodec(); 36121 } 36122 /** 36123 * When the media-element fails, this allows to detach and then re-attach it 36124 * as one call (convenience method). 36125 * 36126 * Automatic recovery of media-errors by this process is configurable. 36127 */ 36128 recoverMediaError() { 36129 logger.log("recoverMediaError"); 36130 const media = this._media; 36131 this.detachMedia(); 36132 if (media) { 36133 this.attachMedia(media); 36134 } 36135 } 36136 removeLevel(levelIndex) { 36137 this.levelController.removeLevel(levelIndex); 36138 } 36139 /** 36140 * @returns an array of levels (variants) sorted by HDCP-LEVEL, RESOLUTION (height), FRAME-RATE, CODECS, VIDEO-RANGE, and BANDWIDTH 36141 */ 36142 get levels() { 36143 const levels = this.levelController.levels; 36144 return levels ? levels : []; 36145 } 36146 /** 36147 * Index of quality level (variant) currently played 36148 */ 36149 get currentLevel() { 36150 return this.streamController.currentLevel; 36151 } 36152 /** 36153 * Set quality level index immediately. This will flush the current buffer to replace the quality asap. That means playback will interrupt at least shortly to re-buffer and re-sync eventually. Set to -1 for automatic level selection. 36154 */ 36155 set currentLevel(newLevel) { 36156 logger.log(`set currentLevel:${newLevel}`); 36157 this.levelController.manualLevel = newLevel; 36158 this.streamController.immediateLevelSwitch(); 36159 } 36160 /** 36161 * Index of next quality level loaded as scheduled by stream controller. 36162 */ 36163 get nextLevel() { 36164 return this.streamController.nextLevel; 36165 } 36166 /** 36167 * Set quality level index for next loaded data. 36168 * This will switch the video quality asap, without interrupting playback. 36169 * May abort current loading of data, and flush parts of buffer (outside currently played fragment region). 36170 * @param newLevel - Pass -1 for automatic level selection 36171 */ 36172 set nextLevel(newLevel) { 36173 logger.log(`set nextLevel:${newLevel}`); 36174 this.levelController.manualLevel = newLevel; 36175 this.streamController.nextLevelSwitch(); 36176 } 36177 /** 36178 * Return the quality level of the currently or last (of none is loaded currently) segment 36179 */ 36180 get loadLevel() { 36181 return this.levelController.level; 36182 } 36183 /** 36184 * Set quality level index for next loaded data in a conservative way. 36185 * This will switch the quality without flushing, but interrupt current loading. 36186 * Thus the moment when the quality switch will appear in effect will only be after the already existing buffer. 36187 * @param newLevel - Pass -1 for automatic level selection 36188 */ 36189 set loadLevel(newLevel) { 36190 logger.log(`set loadLevel:${newLevel}`); 36191 this.levelController.manualLevel = newLevel; 36192 } 36193 /** 36194 * get next quality level loaded 36195 */ 36196 get nextLoadLevel() { 36197 return this.levelController.nextLoadLevel; 36198 } 36199 /** 36200 * Set quality level of next loaded segment in a fully "non-destructive" way. 36201 * Same as `loadLevel` but will wait for next switch (until current loading is done). 36202 */ 36203 set nextLoadLevel(level) { 36204 this.levelController.nextLoadLevel = level; 36205 } 36206 /** 36207 * Return "first level": like a default level, if not set, 36208 * falls back to index of first level referenced in manifest 36209 */ 36210 get firstLevel() { 36211 return Math.max(this.levelController.firstLevel, this.minAutoLevel); 36212 } 36213 /** 36214 * Sets "first-level", see getter. 36215 */ 36216 set firstLevel(newLevel) { 36217 logger.log(`set firstLevel:${newLevel}`); 36218 this.levelController.firstLevel = newLevel; 36219 } 36220 /** 36221 * Return the desired start level for the first fragment that will be loaded. 36222 * The default value of -1 indicates automatic start level selection. 36223 * Setting hls.nextAutoLevel without setting a startLevel will result in 36224 * the nextAutoLevel value being used for one fragment load. 36225 */ 36226 get startLevel() { 36227 const startLevel = this.levelController.startLevel; 36228 if (startLevel === -1 && this.abrController.forcedAutoLevel > -1) { 36229 return this.abrController.forcedAutoLevel; 36230 } 36231 return startLevel; 36232 } 36233 /** 36234 * set start level (level of first fragment that will be played back) 36235 * if not overrided by user, first level appearing in manifest will be used as start level 36236 * if -1 : automatic start level selection, playback will start from level matching download bandwidth 36237 * (determined from download of first segment) 36238 */ 36239 set startLevel(newLevel) { 36240 logger.log(`set startLevel:${newLevel}`); 36241 if (newLevel !== -1) { 36242 newLevel = Math.max(newLevel, this.minAutoLevel); 36243 } 36244 this.levelController.startLevel = newLevel; 36245 } 36246 /** 36247 * Whether level capping is enabled. 36248 * Default value is set via `config.capLevelToPlayerSize`. 36249 */ 36250 get capLevelToPlayerSize() { 36251 return this.config.capLevelToPlayerSize; 36252 } 36253 /** 36254 * Enables or disables level capping. If disabled after previously enabled, `nextLevelSwitch` will be immediately called. 36255 */ 36256 set capLevelToPlayerSize(shouldStartCapping) { 36257 const newCapLevelToPlayerSize = !!shouldStartCapping; 36258 if (newCapLevelToPlayerSize !== this.config.capLevelToPlayerSize) { 36259 if (newCapLevelToPlayerSize) { 36260 this.capLevelController.startCapping(); 36261 } else { 36262 this.capLevelController.stopCapping(); 36263 this.autoLevelCapping = -1; 36264 this.streamController.nextLevelSwitch(); 36265 } 36266 this.config.capLevelToPlayerSize = newCapLevelToPlayerSize; 36267 } 36268 } 36269 /** 36270 * Capping/max level value that should be used by automatic level selection algorithm (`ABRController`) 36271 */ 36272 get autoLevelCapping() { 36273 return this._autoLevelCapping; 36274 } 36275 /** 36276 * Returns the current bandwidth estimate in bits per second, when available. Otherwise, `NaN` is returned. 36277 */ 36278 get bandwidthEstimate() { 36279 const { 36280 bwEstimator 36281 } = this.abrController; 36282 if (!bwEstimator) { 36283 return NaN; 36284 } 36285 return bwEstimator.getEstimate(); 36286 } 36287 set bandwidthEstimate(abrEwmaDefaultEstimate) { 36288 this.abrController.resetEstimator(abrEwmaDefaultEstimate); 36289 } 36290 /** 36291 * get time to first byte estimate 36292 * @type {number} 36293 */ 36294 get ttfbEstimate() { 36295 const { 36296 bwEstimator 36297 } = this.abrController; 36298 if (!bwEstimator) { 36299 return NaN; 36300 } 36301 return bwEstimator.getEstimateTTFB(); 36302 } 36303 /** 36304 * Capping/max level value that should be used by automatic level selection algorithm (`ABRController`) 36305 */ 36306 set autoLevelCapping(newLevel) { 36307 if (this._autoLevelCapping !== newLevel) { 36308 logger.log(`set autoLevelCapping:${newLevel}`); 36309 this._autoLevelCapping = newLevel; 36310 this.levelController.checkMaxAutoUpdated(); 36311 } 36312 } 36313 get maxHdcpLevel() { 36314 return this._maxHdcpLevel; 36315 } 36316 set maxHdcpLevel(value) { 36317 if (isHdcpLevel(value) && this._maxHdcpLevel !== value) { 36318 this._maxHdcpLevel = value; 36319 this.levelController.checkMaxAutoUpdated(); 36320 } 36321 } 36322 /** 36323 * True when automatic level selection enabled 36324 */ 36325 get autoLevelEnabled() { 36326 return this.levelController.manualLevel === -1; 36327 } 36328 /** 36329 * Level set manually (if any) 36330 */ 36331 get manualLevel() { 36332 return this.levelController.manualLevel; 36333 } 36334 /** 36335 * min level selectable in auto mode according to config.minAutoBitrate 36336 */ 36337 get minAutoLevel() { 36338 const { 36339 levels, 36340 config: { 36341 minAutoBitrate 36342 } 36343 } = this; 36344 if (!levels) return 0; 36345 const len = levels.length; 36346 for (let i3 = 0; i3 < len; i3++) { 36347 if (levels[i3].maxBitrate >= minAutoBitrate) { 36348 return i3; 36349 } 36350 } 36351 return 0; 36352 } 36353 /** 36354 * max level selectable in auto mode according to autoLevelCapping 36355 */ 36356 get maxAutoLevel() { 36357 const { 36358 levels, 36359 autoLevelCapping, 36360 maxHdcpLevel 36361 } = this; 36362 let maxAutoLevel; 36363 if (autoLevelCapping === -1 && levels != null && levels.length) { 36364 maxAutoLevel = levels.length - 1; 36365 } else { 36366 maxAutoLevel = autoLevelCapping; 36367 } 36368 if (maxHdcpLevel) { 36369 for (let i3 = maxAutoLevel; i3--; ) { 36370 const hdcpLevel = levels[i3].attrs["HDCP-LEVEL"]; 36371 if (hdcpLevel && hdcpLevel <= maxHdcpLevel) { 36372 return i3; 36373 } 36374 } 36375 } 36376 return maxAutoLevel; 36377 } 36378 get firstAutoLevel() { 36379 return this.abrController.firstAutoLevel; 36380 } 36381 /** 36382 * next automatically selected quality level 36383 */ 36384 get nextAutoLevel() { 36385 return this.abrController.nextAutoLevel; 36386 } 36387 /** 36388 * this setter is used to force next auto level. 36389 * this is useful to force a switch down in auto mode: 36390 * in case of load error on level N, hls.js can set nextAutoLevel to N-1 for example) 36391 * forced value is valid for one fragment. upon successful frag loading at forced level, 36392 * this value will be resetted to -1 by ABR controller. 36393 */ 36394 set nextAutoLevel(nextLevel) { 36395 this.abrController.nextAutoLevel = nextLevel; 36396 } 36397 /** 36398 * get the datetime value relative to media.currentTime for the active level Program Date Time if present 36399 */ 36400 get playingDate() { 36401 return this.streamController.currentProgramDateTime; 36402 } 36403 get mainForwardBufferInfo() { 36404 return this.streamController.getMainFwdBufferInfo(); 36405 } 36406 /** 36407 * Find and select the best matching audio track, making a level switch when a Group change is necessary. 36408 * Updates `hls.config.audioPreference`. Returns the selected track, or null when no matching track is found. 36409 */ 36410 setAudioOption(audioOption) { 36411 var _this$audioTrackContr; 36412 return (_this$audioTrackContr = this.audioTrackController) == null ? void 0 : _this$audioTrackContr.setAudioOption(audioOption); 36413 } 36414 /** 36415 * Find and select the best matching subtitle track, making a level switch when a Group change is necessary. 36416 * Updates `hls.config.subtitlePreference`. Returns the selected track, or null when no matching track is found. 36417 */ 36418 setSubtitleOption(subtitleOption) { 36419 var _this$subtitleTrackCo; 36420 (_this$subtitleTrackCo = this.subtitleTrackController) == null ? void 0 : _this$subtitleTrackCo.setSubtitleOption(subtitleOption); 36421 return null; 36422 } 36423 /** 36424 * Get the complete list of audio tracks across all media groups 36425 */ 36426 get allAudioTracks() { 36427 const audioTrackController = this.audioTrackController; 36428 return audioTrackController ? audioTrackController.allAudioTracks : []; 36429 } 36430 /** 36431 * Get the list of selectable audio tracks 36432 */ 36433 get audioTracks() { 36434 const audioTrackController = this.audioTrackController; 36435 return audioTrackController ? audioTrackController.audioTracks : []; 36436 } 36437 /** 36438 * index of the selected audio track (index in audio track lists) 36439 */ 36440 get audioTrack() { 36441 const audioTrackController = this.audioTrackController; 36442 return audioTrackController ? audioTrackController.audioTrack : -1; 36443 } 36444 /** 36445 * selects an audio track, based on its index in audio track lists 36446 */ 36447 set audioTrack(audioTrackId) { 36448 const audioTrackController = this.audioTrackController; 36449 if (audioTrackController) { 36450 audioTrackController.audioTrack = audioTrackId; 36451 } 36452 } 36453 /** 36454 * get the complete list of subtitle tracks across all media groups 36455 */ 36456 get allSubtitleTracks() { 36457 const subtitleTrackController = this.subtitleTrackController; 36458 return subtitleTrackController ? subtitleTrackController.allSubtitleTracks : []; 36459 } 36460 /** 36461 * get alternate subtitle tracks list from playlist 36462 */ 36463 get subtitleTracks() { 36464 const subtitleTrackController = this.subtitleTrackController; 36465 return subtitleTrackController ? subtitleTrackController.subtitleTracks : []; 36466 } 36467 /** 36468 * index of the selected subtitle track (index in subtitle track lists) 36469 */ 36470 get subtitleTrack() { 36471 const subtitleTrackController = this.subtitleTrackController; 36472 return subtitleTrackController ? subtitleTrackController.subtitleTrack : -1; 36473 } 36474 get media() { 36475 return this._media; 36476 } 36477 /** 36478 * select an subtitle track, based on its index in subtitle track lists 36479 */ 36480 set subtitleTrack(subtitleTrackId) { 36481 const subtitleTrackController = this.subtitleTrackController; 36482 if (subtitleTrackController) { 36483 subtitleTrackController.subtitleTrack = subtitleTrackId; 36484 } 36485 } 36486 /** 36487 * Whether subtitle display is enabled or not 36488 */ 36489 get subtitleDisplay() { 36490 const subtitleTrackController = this.subtitleTrackController; 36491 return subtitleTrackController ? subtitleTrackCon
36491troller.subtitleDisplay : false; 36492 } 36493 /** 36494 * Enable/disable subtitle display rendering 36495 */ 36496 set subtitleDisplay(value) { 36497 const subtitleTrackController = this.subtitleTrackController; 36498 if (subtitleTrackController) { 36499 subtitleTrackController.subtitleDisplay = value; 36500 } 36501 } 36502 /** 36503 * get mode for Low-Latency HLS loading 36504 */ 36505 get lowLatencyMode() { 36506 return this.config.lowLatencyMode; 36507 } 36508 /** 36509 * Enable/disable Low-Latency HLS part playlist and segment loading, and start live streams at playlist PART-HOLD-BACK rather than HOLD-BACK. 36510 */ 36511 set lowLatencyMode(mode) { 36512 this.config.lowLatencyMode = mode; 36513 } 36514 /** 36515 * Position (in seconds) of live sync point (ie edge of live position minus safety delay defined by ```hls.config.liveSyncDuration```) 36516 * @returns null prior to loading live Playlist 36517 */ 36518 get liveSyncPosition() { 36519 return this.latencyController.liveSyncPosition; 36520 } 36521 /** 36522 * Estimated position (in seconds) of live edge (ie edge of live playlist plus time sync playlist advanced) 36523 * @returns 0 before first playlist is loaded 36524 */ 36525 get latency() { 36526 return this.latencyController.latency; 36527 } 36528 /** 36529 * maximum distance from the edge before the player seeks forward to ```hls.liveSyncPosition``` 36530 * configured using ```liveMaxLatencyDurationCount``` (multiple of target duration) or ```liveMaxLatencyDuration``` 36531 * @returns 0 before first playlist is loaded 36532 */ 36533 get maxLatency() { 36534 return this.latencyController.maxLatency; 36535 } 36536 /** 36537 * target distance from the edge as calculated by the latency controller 36538 */ 36539 get targetLatency() { 36540 return this.latencyController.targetLatency; 36541 } 36542 /** 36543 * the rate at which the edge of the current live playlist is advancing or 1 if there is none 36544 */ 36545 get drift() { 36546 return this.latencyController.drift; 36547 } 36548 /** 36549 * set to true when startLoad is called before MANIFEST_PARSED event 36550 */ 36551 get forceStartLoad() { 36552 return this.streamController.forceStartLoad; 36553 } 36554}; 36555Hls.defaultConfig = void 0; 36556
vendor: 47,587 bytes, lines 36557-37428
36557// node_modules/.pnpm/@[email protected]/node_modules/@mux/playback-core/dist/index.mjs 36558var R2 = Hls; 36559var C2 = { VIDEO: "video", THUMBNAIL: "thumbnail", STORYBOARD: "storyboard", DRM: "drm" }; 36560var M = { NOT_AN_ERROR: 0, NETWORK_OFFLINE: 2000002, NETWORK_UNKNOWN_ERROR: 2e6, NETWORK_NO_STATUS: 2000001, NETWORK_INVALID_URL: 24e5, NETWORK_NOT_FOUND: 2404e3, NETWORK_NOT_READY: 2412e3, NETWORK_GENERIC_SERVER_FAIL: 25e5, NETWORK_TOKEN_MISSING: 2403201, NETWORK_TOKEN_MALFORMED: 2412202, NETWORK_TOKEN_EXPIRED: 2403210, NETWORK_TOKEN_AUD_MISSING: 2403221, NETWORK_TOKEN_AUD_MISMATCH: 2403222, NETWORK_TOKEN_SUB_MISMATCH: 2403232, ENCRYPTED_ERROR: 5e6, ENCRYPTED_UNSUPPORTED_KEY_SYSTEM: 5000001, ENCRYPTED_GENERATE_REQUEST_FAILED: 5000002, ENCRYPTED_UPDATE_LICENSE_FAILED: 5000003, ENCRYPTED_UPDATE_SERVER_CERT_FAILED: 5000004, ENCRYPTED_CDM_ERROR: 5000005, ENCRYPTED_OUTPUT_RESTRICTED: 5000006, ENCRYPTED_MISSING_TOKEN: 5000002 }; 36561var H2 = (e) => e === C2.VIDEO ? "playback" : e; 36562var k = class k2 extends Error { 36563 constructor(t2, r10 = k2.MEDIA_ERR_CUSTOM, n2, o2) { 36564 var a2; 36565 super(t2), this.name = "MediaError", this.code = r10, this.context = o2, this.fatal = n2 != null ? n2 : r10 >= k2.MEDIA_ERR_NETWORK && r10 <= k2.MEDIA_ERR_ENCRYPTED, this.message || (this.message = (a2 = k2.defaultMessages[this.code]) != null ? a2 : ""); 36566 } 36567}; 36568k.MEDIA_ERR_ABORTED = 1, k.MEDIA_ERR_NETWORK = 2, k.MEDIA_ERR_DECODE = 3, k.MEDIA_ERR_SRC_NOT_SUPPORTED = 4, k.MEDIA_ERR_ENCRYPTED = 5, k.MEDIA_ERR_CUSTOM = 100, k.defaultMessages = { 1: "You aborted the media playback", 2: "A network error caused the media download to fail.", 3: "A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.", 4: "An unsupported error occurred. The server or network failed, or your browser does not support this format.", 5: "The media is encrypted and there are no keys to decrypt it." }; 36569var T = k; 36570var je = (e) => e == null; 36571var S = (e, t2) => je(t2) ? false : e in t2; 36572var V2 = { ANY: "any", MUTED: "muted" }; 36573var D2 = { ON_DEMAND: "on-demand", LIVE: "live", UNKNOWN: "unknown" }; 36574var q = { MSE: "mse", NATIVE: "native" }; 36575var w2 = { HEADER: "header", QUERY: "query", NONE: "none" }; 36576var Ut2 = Object.values(w2); 36577var N2 = { M3U8: "application/vnd.apple.mpegurl", MP4: "video/mp4" }; 36578var F2 = { HLS: N2.M3U8 }; 36579var Ht2 = Object.keys(F2); 36580var Vt2 = [...Object.values(N2), "hls", "HLS"]; 36581var ze2 = "en"; 36582var K = { code: ze2 }; 36583var x = (e, t2, r10, n2, o2 = e) => { 36584 o2.addEventListener(t2, r10, n2), e.addEventListener("teardown", () => { 36585 o2.removeEventListener(t2, r10); 36586 }, { once: true }); 36587}; 36588function de2(e, t2, r10) { 36589 t2 && r10 > t2 && (r10 = t2); 36590 for (let n2 = 0; n2 < e.length; n2++) if (e.start(n2) <= r10 && e.end(n2) >= r10) return true; 36591 return false; 36592} 36593var Y2 = (e) => { 36594 let t2 = e.indexOf("?"); 36595 if (t2 < 0) return [e]; 36596 let r10 = e.slice(0, t2), n2 = e.slice(t2); 36597 return [r10, n2]; 36598}; 36599var O = (e) => { 36600 let t2 = e.type; 36601 if (t2) { 36602 let n2 = t2.toUpperCase(); 36603 return S(n2, F2) ? F2[n2] : t2; 36604 } 36605 let { src: r10 } = e; 36606 return r10 ? Xe2(r10) : ""; 36607}; 36608var z = (e) => e === "VOD" ? D2.ON_DEMAND : D2.LIVE; 36609var X2 = (e) => e === "EVENT" ? Number.POSITIVE_INFINITY : e === "VOD" ? Number.NaN : 0; 36610var Xe2 = (e) => { 36611 let t2 = ""; 36612 try { 36613 t2 = new URL(e).pathname; 36614 } catch { 36615 console.error("invalid url"); 36616 } 36617 let r10 = t2.lastIndexOf("."); 36618 if (r10 < 0) return ""; 36619 let o2 = t2.slice(r10 + 1).toUpperCase(); 36620 return S(o2, N2) ? N2[o2] : ""; 36621}; 36622var Q2 = (e) => { 36623 let t2 = (e != null ? e : "").split(".")[1]; 36624 if (t2) try { 36625 let r10 = t2.replace(/-/g, "+").replace(/_/g, "/"), n2 = decodeURIComponent(atob(r10).split("").map(function(o2) { 36626 return "%" + ("00" + o2.charCodeAt(0).toString(16)).slice(-2); 36627 }).join("")); 36628 return JSON.parse(n2); 36629 } catch { 36630 return; 36631 } 36632}; 36633var le2 = ({ exp: e }, t2 = Date.now()) => !e || e * 1e3 < t2; 36634var pe2 = ({ sub: e }, t2) => e !== t2; 36635var fe2 = ({ aud: e }, t2) => !e; 36636var Te = ({ aud: e }, t2) => e !== t2; 36637var ye2 = "en"; 36638function E(e, t2 = true) { 36639 var o2, a2; 36640 let r10 = t2 && (a2 = (o2 = K) == null ? void 0 : o2[e]) != null ? a2 : e, n2 = t2 ? K.code : ye2; 36641 return new j(r10, n2); 36642} 36643var j = class { 36644 constructor(t2, r10 = ((n2) => (n2 = K) != null ? n2 : ye2)()) { 36645 this.message = t2, this.locale = r10; 36646 } 36647 format(t2) { 36648 return this.message.replace(/\{(\w+)\}/g, (r10, n2) => { 36649 var o2; 36650 return (o2 = t2[n2]) != null ? o2 : ""; 36651 }); 36652 } 36653 toString() { 36654 return this.message; 36655 } 36656}; 36657var Qe2 = Object.values(V2); 36658var me2 = (e) => typeof e == "boolean" || typeof e == "string" && Qe2.includes(e); 36659var Ee = (e, t2, r10) => { 36660 let { autoplay: n2 } = e, o2 = false, a2 = false, s = me2(n2) ? n2 : !!n2, u3 = () => { 36661 o2 || x(t2, "playing", () => { 36662 o2 = true; 36663 }, { once: true }); 36664 }; 36665 if (u3(), x(t2, "loadstart", () => { 36666 o2 = false, u3(), Z(t2, s); 36667 }, { once: true }), x(t2, "loadstart", () => { 36668 r10 || (e.streamType && e.streamType !== D2.UNKNOWN ? a2 = e.streamType === D2.LIVE : a2 = !Number.isFinite(t2.duration)), Z(t2, s); 36669 }, { once: true }), r10 && r10.once(R2.Events.LEVEL_LOADED, (c3, i3) => { 36670 var d2; 36671 e.streamType && e.streamType !== D2.UNKNOWN ? a2 = e.streamType === D2.LIVE : a2 = (d2 = i3.details.live) != null ? d2 : false; 36672 }), !s) { 36673 let c3 = () => { 36674 !a2 || Number.isFinite(e.startTime) || (r10 != null && r10.liveSyncPosition ? t2.currentTime = r10.liveSyncPosition : Number.isFinite(t2.seekable.end(0)) && (t2.currentTime = t2.seekable.end(0))); 36675 }; 36676 r10 && x(t2, "play", () => { 36677 t2.preload === "metadata" ? r10.once(R2.Events.LEVEL_UPDATED, c3) : c3(); 36678 }, { once: true }); 36679 } 36680 return (c3) => { 36681 o2 || (s = me2(c3) ? c3 : !!c3, Z(t2, s)); 36682 }; 36683}; 36684var Z = (e, t2) => { 36685 if (!t2) return; 36686 let r10 = e.muted, n2 = () => e.muted = r10; 36687 switch (t2) { 36688 case V2.ANY: 36689 e.play().catch(() => { 36690 e.muted = true, e.play().catch(n2); 36691 }); 36692 break; 36693 case V2.MUTED: 36694 e.muted = true, e.play().catch(n2); 36695 break; 36696 default: 36697 e.play().catch(() => { 36698 }); 36699 break; 36700 } 36701}; 36702var ge2 = ({ preload: e, src: t2 }, r10, n2) => { 36703 let o2 = (d2) => { 36704 d2 != null && ["", "none", "metadata", "auto"].includes(d2) ? r10.setAttribute("preload", d2) : r10.removeAttribute("preload"); 36705 }; 36706 if (!n2) return o2(e), o2; 36707 let a2 = false, s = false, u3 = n2.config.maxBufferLength, l2 = n2.config.maxBufferSize, c3 = (d2) => { 36708 o2(d2); 36709 let p3 = d2 != null ? d2 : r10.preload; 36710 s || p3 === "none" || (p3 === "metadata" ? (n2.config.maxBufferLength = 1, n2.config.maxBufferSize = 1) : (n2.config.maxBufferLength = u3, n2.config.maxBufferSize = l2), i3()); 36711 }, i3 = () => { 36712 !a2 && t2 && (a2 = true, n2.loadSource(t2)); 36713 }; 36714 return x(r10, "play", () => { 36715 s = true, n2.config.maxBufferLength = u3, n2.config.maxBufferSize = l2, i3(); 36716 }, { once: true }), c3(e), c3; 36717}; 36718function Me2(e, t2) { 36719 var l2; 36720 if (!("videoTracks" in e)) return; 36721 let r10 = /* @__PURE__ */ new WeakMap(); 36722 t2.on(R2.Events.MANIFEST_PARSED, function(c3, i3) { 36723 u3(); 36724 let d2 = e.addVideoTrack("main"); 36725 d2.selected = true; 36726 for (let [p3, f] of i3.levels.entries()) { 36727 let y4 = d2.addRendition(f.url[0], f.width, f.height, f.videoCodec, f.bitrate); 36728 r10.set(f, `${p3}`), y4.id = `${p3}`; 36729 } 36730 }), t2.on(R2.Events.AUDIO_TRACKS_UPDATED, function(c3, i3) { 36731 s(); 36732 for (let d2 of i3.audioTracks) { 36733 let p3 = d2.default ? "main" : "alternative", f = e.addAudioTrack(p3, d2.name, d2.lang); 36734 f.id = `${d2.id}`, d2.default && (f.enabled = true); 36735 } 36736 }), e.audioTracks.addEventListener("change", () => { 36737 var d2; 36738 let c3 = +((d2 = [...e.audioTracks].find((p3) => p3.enabled)) == null ? void 0 : d2.id), i3 = t2.audioTracks.map((p3) => p3.id); 36739 c3 != t2.audioTrack && i3.includes(c3) && (t2.audioTrack = c3); 36740 }), t2.on(R2.Events.LEVELS_UPDATED, function(c3, i3) { 36741 var f; 36742 let d2 = e.videoTracks[(f = e.videoTracks.selectedIndex) != null ? f : 0]; 36743 if (!d2) return; 36744 let p3 = i3.levels.map((y4) => r10.get(y4)); 36745 for (let y4 of e.videoRenditions) y4.id && !p3.includes(y4.id) && d2.removeRendition(y4); 36746 }); 36747 let n2 = (c3) => { 36748 let i3 = c3.target.selectedIndex; 36749 i3 != t2.nextLevel && o2(i3); 36750 }, o2 = (c3) => { 36751 let i3 = e.currentTime, d2 = false, p3 = (f, y4) => { 36752 d2 || (d2 = !Number.isFinite(y4.endOffset)); 36753 }; 36754 t2.on(R2.Events.BUFFER_FLUSHING, p3), t2.nextLevel = c3, t2.off(R2.Events.BUFFER_FLUSHING, p3), d2 || t2.trigger(R2.Events.BUFFER_FLUSHING, { startOffset: i3 + 10, endOffset: 1 / 0, type: "video" }); 36755 }; 36756 (l2 = e.videoRenditions) == null || l2.addEventListener("change", n2); 36757 let a2 = () => { 36758 for (let c3 of e.videoTracks) e.removeVideoTrack(c3); 36759 }, s = () => { 36760 for (let c3 of e.audioTracks) e.removeAudioTrack(c3); 36761 }, u3 = () => { 36762 a2(), s(); 36763 }; 36764 t2.once(R2.Events.DESTROYING, u3); 36765} 36766var ee2 = (e) => "time" in e ? e.time : e.startTime; 36767function Re(e, t2) { 36768 t2.on(R2.Events.NON_NATIVE_TEXT_TRACKS_FOUND, (o2, { tracks: a2 }) => { 36769 a2.forEach((s) => { 36770 var i3, d2; 36771 let u3 = (i3 = s.subtitleTrack) != null ? i3 : s.closedCaptions, l2 = t2.subtitleTracks.findIndex(({ lang: p3, name: f, type: y4 }) => p3 == (u3 == null ? void 0 : u3.lang) && f === s.label && y4.toLowerCase() === s.kind), c3 = ((d2 = s._id) != null ? d2 : s.default) ? "default" : `${s.kind}${l2}`; 36772 te2(e, s.kind, s.label, u3 == null ? void 0 : u3.lang, c3, s.default); 36773 }); 36774 }); 36775 let r10 = () => { 36776 if (!t2.subtitleTracks.length) return; 36777 let o2 = Array.from(e.textTracks).find((u3) => u3.id && u3.mode === "showing" && ["subtitles", "captions"].includes(u3.kind)); 36778 if (!o2) return; 36779 let a2 = t2.subtitleTracks[t2.subtitleTrack], s = a2 ? a2.default ? "default" : `${t2.subtitleTracks[t2.subtitleTrack].type.toLowerCase()}${t2.subtitleTrack}` : void 0; 36780 if (t2.subtitleTrack < 0 || (o2 == null ? void 0 : o2.id) !== s) { 36781 let u3 = t2.subtitleTracks.findIndex(({ lang: l2, name: c3, type: i3, default: d2 }) => o2.id === "default" && d2 || l2 == o2.language && c3 === o2.label && i3.toLowerCase() === o2.kind); 36782 t2.subtitleTrack = u3; 36783 } 36784 (o2 == null ? void 0 : o2.id) === s && o2.cues && Array.from(o2.cues).forEach((u3) => { 36785 o2.addCue(u3); 36786 }); 36787 }; 36788 e.textTracks.addEventListener("change", r10), t2.on(R2.Events.CUES_PARSED, (o2, { track: a2, cues: s }) => { 36789 let u3 = e.textTracks.getTrackById(a2); 36790 if (!u3) return; 36791 let l2 = u3.mode === "disabled"; 36792 l2 && (u3.mode = "hidden"), s.forEach((c3) => { 36793 var i3; 36794 (i3 = u3.cues) != null && i3.getCueById(c3.id) || u3.addCue(c3); 36795 }), l2 && (u3.mode = "disabled"); 36796 }), t2.once(R2.Events.DESTROYING, () => { 36797 e.textTracks.removeEventListener("change", r10), e.querySelectorAll("track[data-removeondestroy]").forEach((a2) => { 36798 a2.remove(); 36799 }); 36800 }); 36801 let n2 = () => { 36802 Array.from(e.textTracks).forEach((o2) => { 36803 var a2, s; 36804 if (!["subtitles", "caption"].includes(o2.kind) && (o2.label === "thumbnails" || o2.kind === "chapters")) { 36805 if (!((a2 = o2.cues) != null && a2.length)) { 36806 let u3 = "track"; 36807 o2.kind && (u3 += `[kind="${o2.kind}"]`), o2.label && (u3 += `[label="${o2.label}"]`); 36808 let l2 = e.querySelector(u3), c3 = (s = l2 == null ? void 0 : l2.getAttribute("src")) != null ? s : ""; 36809 l2 == null || l2.removeAttribute("src"), setTimeout(() => { 36810 l2 == null || l2.setAttribute("src", c3); 36811 }, 0); 36812 } 36813 o2.mode !== "hidden" && (o2.mode = "hidden"); 36814 } 36815 }); 36816 }; 36817 t2.once(R2.Events.MANIFEST_LOADED, n2), t2.once(R2.Events.MEDIA_ATTACHED, n2); 36818} 36819function te2(e, t2, r10, n2, o2, a2) { 36820 let s = document.createElement("track"); 36821 return s.kind = t2, s.label = r10, n2 && (s.srclang = n2), o2 && (s.id = o2), a2 && (s.default = true), s.track.mode = ["subtitles", "captions"].includes(t2) ? "disabled" : "hidden", s.setAttribute("data-removeondestroy", ""), e.append(s), s.track; 36822} 36823function Ze(e, t2) { 36824 let r10 = Array.prototype.find.call(e.querySelectorAll("track"), (n2) => n2.track === t2); 36825 r10 == null || r10.remove(); 36826} 36827function A2(e, t2, r10) { 36828 var n2; 36829 return (n2 = Array.from(e.querySelectorAll("track")).find((o2) => o2.track.label === t2 && o2.track.kind === r10)) == null ? void 0 : n2.track; 36830} 36831async function Ce2(e, t2, r10, n2) { 36832 let o2 = A2(e, r10, n2); 36833 return o2 || (o2 = te2(e, n2, r10), o2.mode = "hidden", await new Promise((a2) => setTimeout(() => a2(void 0), 0))), o2.mode !== "hidden" && (o2.mode = "hidden"), [...t2].sort((a2, s) => ee2(s) - ee2(a2)).forEach((a2) => { 36834 var l2, c3; 36835 let s = a2.value, u3 = ee2(a2); 36836 if ("endTime" in a2 && a2.endTime != null) o2 == null || o2.addCue(new VTTCue(u3, a2.endTime, n2 === "chapters" ? s : JSON.stringify(s != null ? s : null))); 36837 else { 36838 let i3 = Array.prototype.findIndex.call(o2 == null ? void 0 : o2.cues, (y4) => y4.startTime >= u3), d2 = (l2 = o2 == null ? void 0 : o2.cues) == null ? void 0 : l2[i3], p3 = d2 ? d2.startTime : Number.isFinite(e.duration) ? e.duration : Number.MAX_SAFE_INTEGER, f = (c3 = o2 == null ? void 0 : o2.cues) == null ? void 0 : c3[i3 - 1]; 36839 f && (f.endTime = u3), o2 == null || o2.addCue(new VTTCue(u3, p3, n2 === "chapters" ? s : JSON.stringify(s != null ? s : null))); 36840 } 36841 }), e.textTracks.dispatchEvent(new Event("change", { bubbles: true, composed: true })), o2; 36842} 36843var re2 = "cuepoints"; 36844var be2 = Object.freeze({ label: re2 }); 36845async function xe(e, t2, r10 = be2) { 36846 return Ce2(e, t2, r10.label, "metadata"); 36847} 36848var W = (e) => ({ time: e.startTime, value: JSON.parse(e.text) }); 36849function et(e, t2 = { label: re2 }) { 36850 let r10 = A2(e, t2.label, "metadata"); 36851 return r10 != null && r10.cues ? Array.from(r10.cues, (n2) => W(n2)) : []; 36852} 36853function ve(e, t2 = { label: re2 }) { 36854 var a2, s; 36855 let r10 = A2(e, t2.label, "metadata"); 36856 if (!((a2 = r10 == null ? void 0 : r10.activeCues) != null && a2.length)) return; 36857 if (r10.activeCues.length === 1) return W(r10.activeCues[0]); 36858 let { currentTime: n2 } = e, o2 = Array.prototype.find.call((s = r10.activeCues) != null ? s : [], ({ startTime: u3, endTime: l2 }) => u3 <= n2 && l2 > n2); 36859 return W(o2 || r10.activeCues[0]); 36860} 36861async function Pe2(e, t2 = be2) { 36862 return new Promise((r10) => { 36863 x(e, "loadstart", async () => { 36864 let n2 = await xe(e, [], t2); 36865 x(e, "cuechange", () => { 36866 let o2 = ve(e); 36867 if (o2) { 36868 let a2 = new CustomEvent("cuepointchange", { composed: true, bubbles: true, detail: o2 }); 36869 e.dispatchEvent(a2); 36870 } 36871 }, {}, n2), r10(n2); 36872 }); 36873 }); 36874} 36875var ne2 = "chapters"; 36876var De2 = Object.freeze({ label: ne2 }); 36877var $2 = (e) => ({ startTime: e.startTime, endTime: e.endTime, value: e.text }); 36878async function _e2(e, t2, r10 = De2) { 36879 return Ce2(e, t2, r10.label, "chapters"); 36880} 36881function tt2(e, t2 = { label: ne2 }) { 36882 var n2; 36883 let r10 = A2(e, t2.label, "chapters"); 36884 return (n2 = r10 == null ? void 0 : r10.cues) != null && n2.length ? Array.from(r10.cues, (o2) => $2(o2)) : []; 36885} 36886function ke2(e, t2 = { label: ne2 }) { 36887 var a2, s; 36888 let r10 = A2(e, t2.label, "chapters"); 36889 if (!((a2 = r10 == null ? void 0 : r10.activeCues) != null && a2.length)) return; 36890 if (r10.activeCues.length === 1) return $2(r10.activeCues[0]); 36891 let { currentTime: n2 } = e, o2 = Array.prototype.find.call((s = r10.activeCues) != null ? s : [], ({ startTime: u3, endTime: l2 }) => u3 <= n2 && l2 > n2); 36892 return $2(o2 || r10.activeCues[0]); 36893} 36894async function he2(e, t2 = De2) { 36895 return new Promise((r10) => { 36896 x(e, "loadstart", async () => { 36897 let n2 = await _e2(e, [], t2); 36898 x(e, "cuechange", () => { 36899 let o2 = ke2(e); 36900 if (o2) { 36901 let a2 = new CustomEvent("chapterchange", { composed: true, bubbles: true, detail: o2 }); 36902 e.dispatchEvent(a2); 36903 } 36904 }, {}, n2), r10(n2); 36905 }); 36906 }); 36907} 36908function rt(e, t2) { 36909 if (t2) { 36910 let r10 = t2.playingDate; 36911 if (r10 != null) return new Date(r10.getTime() - e.currentTime * 1e3); 36912 } 36913 return typeof e.getStartDate == "function" ? e.getStartDate() : /* @__PURE__ */ new Date(NaN); 36914} 36915function nt3(e, t2) { 36916 if (t2 && t2.playingDate) return t2.playingDate; 36917 if (typeof e.getStartDate == "function") { 36918 let r10 = e.getStartDate(); 36919 return new Date(r10.getTime() + e.currentTime * 1e3); 36920 } 36921 return /* @__PURE__ */ new Date(NaN); 36922} 36923var oe = { VIDEO: "v", THUMBNAIL: "t", STORYBOARD: "s", DRM: "d" }; 36924var ot2 = (e) => { 36925 if (e === C2.VIDEO) return oe.VIDEO; 36926 if (e === C2.DRM) return oe.DRM; 36927}; 36928var at = (e, t2) => { 36929 var o2, a2; 36930 let r10 = H2(e), n2 = `${r10}Token`; 36931 return (o2 = t2.tokens) != null && o2[r10] ? (a2 = t2.tokens) == null ? void 0 : a2[r10] : S(n2, t2) ? t2[n2] : void 0; 36932}; 36933var U2 = (e, t2, r10, n2 = false, o2 = !((a2) => (a2 = globalThis.navigator) == null ? void 0 : a2.onLine)()) => { 36934 var v2, P3; 36935 if (o2) { 36936 let g = E("Your device appears to be offline", n2), b3 = void 0, m2 = T.MEDIA_ERR_NETWORK, h3 = new T(g, m2, true, b3); 36937 return h3.errorCategory = t2, h3.muxCode = M.NETWORK_OFFLINE, h3.data = e, h3; 36938 } 36939 let s = "status" in e ? e.status : e.code, u3 = Date.now(), l2 = T.MEDIA_ERR_NETWORK; 36940 if (s === 200) return; 36941 let c3 = H2(t2), i3 = at(t2, r10), d2 = ot2(t2), [p3] = Y2((v2 = r10.playbackId) != null ? v2 : ""); 36942 if (!s || !p3) return; 36943 let f = Q2(i3); 36944 if (i3 && !f) { 36945 let g = E("The {tokenNamePrefix}-token provided is invalid or malformed.", n2).format({ tokenNamePrefix: c3 }), b3 = E("Compact JWT string: {token}", n2).format({ token: i3 }), m2 = new T(g, l2, true, b3); 36946 return m2.errorCategory = t2, m2.muxCode = M.NETWORK_TOKEN_MALFORMED, m2.data = e, m2; 36947 } 36948 if (s >= 500) { 36949 let g = new T("", l2, true); 36950 return g.errorCategory = t2, g.muxCode = M.NETWORK_UNKNOWN_ERROR, g; 36951 } 36952 if (s === 403) if (f) { 36953 if (le2(f, u3)) { 36954 let g = { timeStyle: "medium", dateStyle: "medium" }, b3 = E("The videoâs secured {tokenNamePrefix}-token has expired.", n2).format({ tokenNamePrefix: c3 }), m2 = E("Expired at: {expiredDate}. Current time: {currentDate}.", n2).format({ expiredDate: new Intl.DateTimeFormat("en", g).format((P3 = f.exp) != null ? P3 : 0 * 1e3), currentDate: new Intl.DateTimeFormat("en", g).format(u3) }), h3 = new T(b3, l2, true, m2); 36955 return h3.errorCategory = t2, h3.muxCode = M.NETWORK_TOKEN_EXPIRED, h3.data = e, h3; 36956 } 36957 if (pe2(f, p3)) { 36958 let g = E("The videoâs playback ID does not match the one encoded in the {tokenNamePrefix}-token.", n2).format({ tokenNamePrefix: c3 }), b3 = E("Specified playback ID: {playbackId} and the playback ID encoded in the {tokenNamePrefix}-token: {tokenPlaybackId}", n2).format({ tokenNamePrefix: c3, playbackId: p3, tokenPlaybackId: f.sub }), m2 = new T(g, l2, true, b3); 36959 return m2.errorCategory = t2, m2.muxCode = M.NETWORK_TOKEN_SUB_MISMATCH, m2.data = e, m2; 36960 } 36961 if (fe2(f, d2)) { 36962 let g = E("The {tokenNamePrefix}-token is formatted with incorrect information.", n2).format({ tokenNamePrefix: c3 }), b3 = E("The {tokenNamePrefix}-token has no aud value. aud value should be {expectedAud}.", n2).format({ tokenNamePrefix: c3, expectedAud: d2 }), m2 = new T(g, l2, true, b3); 36963 return m2.errorCategory = t2, m2.muxCode = M.NETWORK_TOKEN_AUD_MISSING, m2.data = e, m2; 36964 } 36965 if (Te(f, d2)) { 36966 let g = E("The {tokenNamePrefix}-token is formatted with incorrect information.", n2).format({ tokenNamePrefix: c3 }), b3 = E("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.", n2).format({ tokenNamePrefix: c3, expectedAud: d2, aud: f.aud }), m2 = new T(g, l2, true, b3); 36967 return m2.errorCategory = t2, m2.muxCode = M.NETWORK_TOKEN_AUD_MISMATCH, m2.data = e, m2; 36968 } 36969 } else { 36970 let g = E("Authorization error trying to access this {category} URL. If this is a signed URL, you might need to provide a {tokenNamePrefix}-token.", n2).format({ tokenNamePrefix: c3, category: t2 }), b3 = E("Specified playback ID: {playbackId}", n2).format({ playbackId: p3 }), m2 = new T(g, l2, true, b3); 36971 return m2.errorCategory = t2, m2.muxCode = M.NETWORK_TOKEN_MISSING, m2.data = e, m2; 36972 } 36973 if (s === 412) { 36974 let g = E("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.", n2), b3 = E("Specified playback ID: {playbackId}", n2).format({ playbackId: p3 }), m2 = new T(g, l2, true, b3); 36975 return m2.errorCategory = t2, m2.muxCode = M.NETWORK_NOT_READY, m2.data = e, m2; 36976 } 36977 if (s === 404) { 36978 let g = E("This URL or playback-id does not exist. You may have used an Asset ID or an ID from a different resource.", n2), b3 = E("Specified playback ID: {playbackId}", n2).format({ playbackId: p3 }), m2 = new T(g, l2, true, b3); 36979 return m2.errorCategory = t2, m2.muxCode = M.NETWORK_NOT_FOUND, m2.data = e, m2; 36980 } 36981 if (s === 400) { 36982 let g = E("The URL or playback-id was invalid. You may have used an invalid value as a playback-id."), b3 = E("Specified playback ID: {playbackId}", n2).format({ playbackId: p3 }), m2 = new T(g, l2, true, b3); 36983 return m2.errorCategory = t2, m2.muxCode = M.NETWORK_INVALID_URL, m2.data = e, m2; 36984 } 36985 let y4 = new T("", l2, true); 36986 return y4.errorCategory = t2, y4.muxCode = M.NETWORK_UNKNOWN_ERROR, y4.data = e, y4; 36987}; 36988var B2 = { FAIRPLAY: "fairplay", PLAYREADY: "playready", WIDEVINE: "widevine" }; 36989var st2 = (e) => { 36990 if (e.includes("fps")) return B2.FAIRPLAY; 36991 if (e.includes("playready")) return B2.PLAYREADY; 36992 if (e.includes("widevine")) return B2.WIDEVINE; 36993}; 36994var it2 = async (e) => fetch(e).then((t2) => t2.status !== 200 ? Promise.reject(t2) : t2.text()).then((t2) => { 36995 let r10 = t2.split(` 36996`).find((n2, o2, a2) => o2 && a2[o2 - 1].startsWith("#EXT-X-STREAM-INF")); 36997 return fetch(r10).then((n2) => n2.status !== 200 ? Promise.reject(n2) : n2.text()).then((n2) => n2.split(` 36998`)); 36999}); 37000var ct2 = (e) => { 37001 var s, u3, l2; 37002 let r10 = (u3 = ((s = e.find((c3) => c3.startsWith("#EXT-X-PLAYLIST-TYPE"))) != null ? s : "").split(":")[1]) == null ? void 0 : u3.trim(), n2 = z(r10), o2 = X2(r10), a2; 37003 if (n2 === D2.LIVE) { 37004 let c3 = e.find((d2) => d2.startsWith("#EXT-X-PART-INF")); 37005 if (!!c3) a2 = +c3.split(":")[1].split("=")[1] * 2; 37006 else { 37007 let d2 = e.find((y4) => y4.startsWith("#EXT-X-TARGETDURATION")), p3 = (l2 = d2 == null ? void 0 : d2.split(":")) == null ? void 0 : l2[1]; 37008 a2 = +(p3 != null ? p3 : 6) * 3; 37009 } 37010 } 37011 return { streamType: n2, targetLiveWindow: o2, liveEdgeStartOffset: a2 }; 37012}; 37013var ut2 = async (e, t2) => { 37014 if (t2 === N2.MP4) return { streamType: D2.ON_DEMAND, targetLiveWindow: Number.NaN, liveEdgeStartOffset: void 0 }; 37015 if (t2 === N2.M3U8) { 37016 let r10 = await it2(e); 37017 return ct2(r10); 37018 } 37019 return console.error(`Media type ${t2} is an unrecognized or unsupported type for src ${e}.`), { streamType: void 0, targetLiveWindow: void 0, liveEdgeStartOffset: void 0 }; 37020}; 37021var dt3 = async (e, t2, r10 = O({ src: e })) => { 37022 var s, u3, l2; 37023 let { streamType: n2, targetLiveWindow: o2, liveEdgeStartOffset: a2 } = await ut2(e, r10); 37024 ((s = _.get(t2)) != null ? s : {}).liveEdgeStartOffset = a2, ((u3 = _.get(t2)) != null ? u3 : {}).targetLiveWindow = o2, t2.dispatchEvent(new CustomEvent("targetlivewindowchange", { composed: true, bubbles: true })), ((l2 = _.get(t2)) != null ? l2 : {}).streamType = n2, t2.dispatchEvent(new CustomEvent("streamtypechange", { composed: true, bubbles: true })); 37025}; 37026var lt2 = (e) => { 37027 var s; 37028 let t2 = e.type, r10 = z(t2), n2 = X2(t2), o2, a2 = !!((s = e.partList) != null && s.length); 37029 return r10 === D2.LIVE && (o2 = a2 ? e.partTarget * 2 : e.targetduration * 3), { streamType: r10, targetLiveWindow: n2, liveEdgeStartOffset: o2, lowLatency: a2 }; 37030}; 37031var pt2 = (e, t2, r10) => { 37032 var u3, l2, c3, i3, d2, p3, f, y4; 37033 let { streamType: n2, targetLiveWindow: o2, liveEdgeStartOffset: a2, lowLatency: s } = lt2(e); 37034 if (n2 === D2.LIVE) { 37035 s ? (r10.config.backBufferLength = (u3 = r10.userConfig.backBufferLength) != null ? u3 : 4, r10.config.maxFragLookUpTolerance = (l2 = r10.userConfig.maxFragLookUpTolerance) != null ? l2 : 1e-3, r10.config.abrBandWidthUpFactor = (c3 = r10.userConfig.abrBandWidthUpFactor) != null ? c3 : r10.config.abrBandWidthFactor) : r10.config.backBufferLength = (i3 = r10.userConfig.backBufferLength) != null ? i3 : 8; 37036 let v2 = Object.freeze({ get length() { 37037 return t2.seekable.length; 37038 }, start(P3) { 37039 return t2.seekable.start(P3); 37040 }, end(P3) { 37041 var g; 37042 return P3 > this.length || P3 < 0 || Number.isFinite(t2.duration) ? t2.seekable.end(P3) : (g = r10.liveSyncPosition) != null ? g : t2.seekable.end(P3); 37043 } }); 37044 ((d2 = _.get(t2)) != null ? d2 : {}).seekable = v2; 37045 } 37046 ((p3 = _.get(t2)) != null ? p3 : {}).liveEdgeStartOffset = a2, ((f = _.get(t2)) != null ? f : {}).targetLiveWindow = o2, t2.dispatchEvent(new CustomEvent("targetlivewindowchange", { composed: true, bubbles: true })), ((y4 = _.get(t2)) != null ? y4 : {}).streamType = n2, t2.dispatchEvent(new CustomEvent("streamtypechange", { composed: true, bubbles: true })); 37047}; 37048var Ie2; 37049var Ae2; 37050var ft3 = (Ae2 = (Ie2 = globalThis == null ? void 0 : globalThis.navigator) == null ? void 0 : Ie2.userAgent) != null ? Ae2 : ""; 37051var Se2; 37052var we; 37053var Oe2; 37054var Tt2 = (Oe2 = (we = (Se2 = globalThis == null ? void 0 : globalThis.navigator) == null ? void 0 : Se2.userAgentData) == null ? void 0 : we.platform) != null ? Oe2 : ""; 37055var yt2 = ft3.toLowerCase().includes("android") || ["x11", "android"].some((e) => Tt2.toLowerCase().includes(e)); 37056var _ = /* @__PURE__ */ new WeakMap(); 37057var I = "mux.com"; 37058var Ue2; 37059var He2; 37060var Ve = (He2 = (Ue2 = R2).isSupported) == null ? void 0 : He2.call(Ue2); 37061var mt2 = yt2; 37062var Nr2 = () => Cd.utils.now(); 37063var Et2 = Cd.utils.generateUUID; 37064var Lr = ({ playbackId: e, customDomain: t2 = I, maxResolution: r10, minResolution: n2, renditionOrder: o2, programStartTime: a2, programEndTime: s, assetStartTime: u3, assetEndTime: l2, playbackToken: c3, tokens: { playback: i3 = c3 } = {}, extraSourceParams: d2 = {} } = {}) => { 37065 if (!e) return; 37066 let [p3, f = ""] = Y2(e), y4 = new URL(`https://stream.${t2}/${p3}.m3u8${f}`); 37067 return i3 || y4.searchParams.has("token") ? (y4.searchParams.forEach((v2, P3) => { 37068 P3 != "token" && y4.searchParams.delete(P3); 37069 }), i3 && y4.searchParams.set("token", i3)) : (r10 && y4.searchParams.set("max_resolution", r10), n2 && (y4.searchParams.set("min_resolution", n2), r10 && +r10.slice(0, -1) < +n2.slice(0, -1) && console.error("minResolution must be <= maxResolution", "minResolution", n2, "maxResolution", r10)), o2 && y4.searchParams.set("rendition_order", o2), a2 && y4.searchParams.set("program_start_time", `${a2}`), s && y4.searchParams.set("program_end_time", `${s}`), u3 && y4.searchParams.set("asset_start_time", `${u3}`), l2 && y4.searchParams.set("asset_end_time", `${l2}`), Object.entries(d2).forEach(([v2, P3]) => { 37070 P3 != null && y4.searchParams.set(v2, P3); 37071 })), y4.toString(); 37072}; 37073var G2 = (e) => { 37074 if (!e) return; 37075 let [t2] = e.split("?"); 37076 return t2 || void 0; 37077}; 37078var gt2 = (e) => { 37079 if (!e || !e.startsWith("https://stream.")) return; 37080 let [t2] = new URL(e).pathname.slice(1).split(".m3u8"); 37081 return t2 || void 0; 37082}; 37083var Mt2 = (e) => { 37084 var t2, r10, n2; 37085 return (t2 = e == null ? void 0 : e.metadata) != null && t2.video_id ? e.metadata.video_id : Be(e) && (n2 = (r10 = G2(e.playbackId)) != null ? r10 : gt2(e.src)) != null ? n2 : e.src; 37086}; 37087var Rt2 = (e) => { 37088 var t2; 37089 return (t2 = _.get(e)) == null ? void 0 : t2.error; 37090}; 37091var Le2 = (e) => { 37092 var t2, r10; 37093 return (r10 = (t2 = _.get(e)) == null ? void 0 : t2.streamType) != null ? r10 : D2.UNKNOWN; 37094}; 37095var Ir = (e) => { 37096 var t2, r10; 37097 return (r10 = (t2 = _.get(e)) == null ? void 0 : t2.targetLiveWindow) != null ? r10 : Number.NaN; 37098}; 37099var Fe2 = (e) => { 37100 var t2, r10; 37101 return (r10 = (t2 = _.get(e)) == null ? void 0 : t2.seekable) != null ? r10 : e.seekable; 37102}; 37103var Ar2 = (e) => { 37104 var n2; 37105 let t2 = (n2 = _.get(e)) == null ? void 0 : n2.liveEdgeStartOffset; 37106 if (typeof t2 != "number") return Number.NaN; 37107 let r10 = Fe2(e); 37108 return r10.length ? r10.end(r10.length - 1) - t2 : Number.NaN; 37109}; 37110var ie2 = 0.034; 37111var Ct2 = (e, t2, r10 = ie2) => Math.abs(e - t2) <= r10; 37112var Ke2 = (e, t2, r10 = ie2) => e > t2 || Ct2(e, t2, r10); 37113var bt2 = (e, t2 = ie2) => e.paused && Ke2(e.currentTime, e.duration, t2); 37114var Ye2 = (e, t2) => { 37115 var c3, i3, d2; 37116 if (!t2 || !e.buffered.length) return; 37117 if (e.readyState > 2) return false; 37118 let r10 = t2.currentLevel >= 0 ? (i3 = (c3 = t2.levels) == null ? void 0 : c3[t2.currentLevel]) == null ? void 0 : i3.details : (d2 = t2.levels.find((p3) => !!p3.details)) == null ? void 0 : d2.details; 37119 if (!r10 || r10.live) return; 37120 let { fragments: n2 } = r10; 37121 if (!(n2 != null && n2.length)) return; 37122 if (e.currentTime < e.duration - (r10.targetduration + 0.5)) return false; 37123 let o2 = n2[n2.length - 1]; 37124 if (e.currentTime <= o2.start) return false; 37125 let a2 = o2.start + o2.duration / 2, s = e.buffered.start(e.buffered.length - 1), u3 = e.buffered.end(e.buffered.length - 1); 37126 return a2 > s && a2 < u3; 37127}; 37128var xt2 = (e, t2) => e.ended || e.loop ? e.ended : t2 && Ye2(e, t2) ? true : bt2(e); 37129var Sr = (e, t2, r10) => { 37130 vt2(t2, r10); 37131 let { metadata: n2 = {} } = e, { view_session_id: o2 = Et2() } = n2, a2 = Mt2(e); 37132 n2.view_session_id = o2, n2.video_id = a2, e.metadata = n2; 37133 let s = (i3) => { 37134 var d2; 37135 (d2 = t2.mux) == null || d2.emit("hb", { view_drm_type: i3 }); 37136 }; 37137 e.drmTypeCb = s, _.set(t2, {}); 37138 let u3 = Pt2(e, t2), l2 = ge2(e, t2, u3); 37139 Lt2(e, t2, u3), It2(e, t2, u3), Pe2(t2), he2(t2); 37140 let c3 = Ee(e, t2, u3); 37141 return { engine: u3, setAutoplay: c3, setPreload: l2 }; 37142}; 37143var vt2 = (e, t2) => { 37144 let r10 = t2 == null ? void 0 : t2.engine; 37145 r10 && (r10.detachMedia(), r10.destroy()), e != null && e.mux && !e.mux.deleted && (e.mux.destroy(), delete e.mux), e && (e.removeAttribute("src"), e.load(), e.removeEventListener("error", Ge2), e.removeEventListener("error", ae), e.removeEventListener("durationchange", Je2), _.delete(e), e.dispatchEvent(new Event("teardown"))); 37146}; 37147function We(e, t2) { 37148 var c3; 37149 let r10 = O(e); 37150 if (!(r10 === N2.M3U8)) return true; 37151 let o2 = !r10 || ((c3 = t2.canPlayType(r10)) != null ? c3 : true), { preferPlayback: a2 } = e, s = a2 === q.MSE, u3 = a2 === q.NATIVE; 37152 return o2 && (u3 || !(Ve && (s || mt2))); 37153} 37154var Pt2 = (e, t2) => { 37155 let { debug: r10, streamType: n2, startTime: o2 = -1, metadata: a2, preferCmcd: s, _hlsConfig: u3 = {} } = e, c3 = O(e) === N2.M3U8, i3 = We(e, t2); 37156 if (c3 && !i3 && Ve) { 37157 let d2 = { backBufferLength: 30, renderTextTracksNatively: false, liveDurationInfinity: true, capLevelToPlayerSize: true, capLevelOnFPSDrop: true }, p3 = Dt2(n2), f = _t2(e), y4 = s !== w2.NONE ? { useHeaders: s === w2.HEADER, sessionId: a2 == null ? void 0 : a2.view_session_id, contentId: a2 == null ? void 0 : a2.video_id } : void 0; 37158 return new R2({ debug: r10, startPosition: o2, cmcd: y4, xhrSetup: (P3, g) => { 37159 var h3, ce5; 37160 if (s && s !== w2.QUERY) return; 37161 let b3 = new URL(g); 37162 if (!b3.searchParams.has("CMCD")) return; 37163 let m2 = ((ce5 = (h3 = b3.searchParams.get("CMCD")) == null ? void 0 : h3.split(",")) != null ? ce5 : []).filter((ue5) => ue5.startsWith("sid") || ue5.startsWith("cid")).join(","); 37164 b3.searchParams.set("CMCD", m2), P3.open("GET", b3); 37165 }, ...d2, ...p3, ...f, ...u3 }); 37166 } 37167}; 37168var Dt2 = (e) => e === D2.LIVE ? { backBufferLength: 8 } : {}; 37169var _t2 = (e) => { 37170 let { tokens: { drm: t2 } = {}, playbackId: r10, drmTypeCb: n2 } = e, o2 = G2(r10); 37171 return !t2 || !o2 ? {} : { emeEnabled: true, drmSystems: { "com.apple.fps": { licenseUrl: J2(e, "fairplay"), serverCertificateUrl: $e2(e, "fairplay") }, "com.widevine.alpha": { licenseUrl: J2(e, "widevine") }, "com.microsoft.playready": { licenseUrl: J2(e, "playready") } }, requestMediaKeySystemAccessFunc: (a2, s) => (a2 === "com.widevine.alpha" && (s = [...s.map((u3) => { 37172 var c3; 37173 let l2 = (c3 = u3.videoCapabilities) == null ? void 0 : c3.map((i3) => ({ ...i3, robustness: "HW_SECURE_ALL" })); 37174 return { ...u3, videoCapabilities: l2 }; 37175 }), ...s]), navigator.requestMediaKeySystemAccess(a2, s).then((u3) => { 37176 let l2 = st2(a2); 37177 return n2 == null || n2(l2), u3; 37178 })) }; 37179}; 37180var kt2 = async (e) => { 37181 let t2 = await fetch(e); 37182 return t2.status !== 200 ? Promise.reject(t2) : await t2.arrayBuffer(); 37183}; 37184var ht = async (e, t2) => { 37185 let r10 = await fetch(t2, { method: "POST", headers: { "Content-type": "application/octet-stream" }, body: e }); 37186 if (r10.status !== 200) return Promise.reject(r10); 37187 let n2 = await r10.arrayBuffer(); 37188 return new Uint8Array(n2); 37189}; 37190var Nt2 = (e, t2) => { 37191 x(t2, "encrypted", async (n2) => { 37192 try { 37193 let o2 = n2.initDataType; 37194 if (o2 !== "skd") { 37195 console.error(`Received unexpected initialization data type "${o2}"`); 37196 return; 37197 } 37198 if (!t2.mediaKeys) { 37199 let c3 = await navigator.requestMediaKeySystemAccess("com.apple.fps", [{ initDataTypes: [o2], videoCapabilities: [{ contentType: "application/vnd.apple.mpegurl", robustness: "" }], distinctiveIdentifier: "not-allowed", persistentState: "not-allowed", sessionTypes: ["temporary"] }]).then((d2) => { 37200 var p3; 37201 return (p3 = e.drmTypeCb) == null || p3.call(e, B2.FAIRPLAY), d2; 37202 }).catch(() => { 37203 let d2 = E("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser."), p3 = new T(d2, T.MEDIA_ERR_ENCRYPTED, true); 37204 p3.errorCategory = C2.DRM, p3.muxCode = M.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM, t2.dispatchEvent(new CustomEvent("error", { detail: p3 })); 37205 }); 37206 if (!c3) return; 37207 let i3 = await c3.createMediaKeys(); 37208 try { 37209 let d2 = await kt2($e2(e, "fairplay")).catch((p3) => { 37210 if (p3 instanceof Response) { 37211 let f = U2(p3, C2.DRM, e); 37212 return console.error("mediaError", f == null ? void 0 : f.message, f == null ? void 0 : f.context), f ? Promise.reject(f) : Promise.reject(new Error("Unexpected error in app cert request")); 37213 } 37214 return Promise.reject(p3); 37215 }); 37216 await i3.setServerCertificate(d2).catch(() => { 37217 let p3 = E("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate."), f = new T(p3, T.MEDIA_ERR_ENCRYPTED, true); 37218 return f.errorCategory = C2.DRM, f.muxCode = M.ENCRYPTED_UPDATE_SERVER_CERT_FAILED, Promise.reject(f); 37219 }); 37220 } catch (d2) { 37221 t2.dispatchEvent(new CustomEvent("error", { detail: d2 })); 37222 return; 37223 } 37224 await t2.setMediaKeys(i3); 37225 } 37226 let a2 = n2.initData; 37227 if (a2 == null) { 37228 console.error(`Could not start encrypted playback due to missing initData in ${n2.type} event`); 37229 return; 37230 } 37231 let s = t2.mediaKeys.createSession(); 37232 s.addEventListener("keystatuseschange", () => { 37233 s.keyStatuses.forEach((c3) => { 37234 let i3; 37235 if (c3 === "internal-error") { 37236 let d2 = E("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser."); 37237 i3 = new T(d2, T.MEDIA_ERR_ENCRYPTED, true), i3.errorCategory = C2.DRM, i3.muxCode = M.ENCRYPTED_CDM_ERROR; 37238 } else if (c3 === "output-restricted" || c3 === "output-downscaled") { 37239 let d2 = E("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen."); 37240 i3 = new T(d2, T.MEDIA_ERR_ENCRYPTED, false), i3.errorCategory = C2.DRM, i3.muxCode = M.ENCRYPTED_OUTPUT_RESTRICTED; 37241 } 37242 i3 && t2.dispatchEvent(new CustomEvent("error", { detail: i3 })); 37243 }); 37244 }); 37245 let u3 = await Promise.all([s.generateRequest(o2, a2).catch(() => { 37246 let c3 = E("Failed to generate a DRM license request. This may be an issue with the player or your protected content."), i3 = new T(c3, T.MEDIA_ERR_ENCRYPTED, true); 37247 i3.errorCategory = C2.DRM, i3.muxCode = M.ENCRYPTED_GENERATE_REQUEST_FAILED, t2.dispatchEvent(new CustomEvent("error", { detail: i3 })); 37248 }), new Promise((c3) => { 37249 s.addEventListener("message", (i3) => { 37250 c3(i3.message); 37251 }, { once: true }); 37252 })]).then(([, c3]) => c3); 37253 s.generateRequest(o2, a2); 37254 let l2 = await ht(u3, J2(e, "fairplay")).catch((c3) => { 37255 if (c3 instanceof Response) { 37256 let i3 = U2(c3, C2.DRM, e); 37257 return console.error("mediaError", i3 == null ? void 0 : i3.message, i3 == null ? void 0 : i3.context), i3 ? Promise.reject(i3) : Promise.reject(new Error("Unexpected error in license key request")); 37258 } 37259 return Promise.reject(c3); 37260 }); 37261 await s.update(l2).catch(() => { 37262 let c3 = E("Failed to update DRM license. This may be an issue with the player or your protected content."), i3 = new T(c3, T.MEDIA_ERR_ENCRYPTED, true); 37263 return i3.errorCategory = C2.DRM, i3.muxCode = M.ENCRYPTED_UPDATE_LICENSE_FAILED, Promise.reject(i3); 37264 }); 37265 } catch (o2) { 37266 t2.dispatchEvent(new CustomEvent("error", { detail: o2 })); 37267 return; 37268 } 37269 }); 37270}; 37271var J2 = ({ playbackId: e, tokens: { drm: t2 } = {}, customDomain: r10 = I }, n2) => { 37272 let o2 = G2(e); 37273 return `https://license.${r10.toLocaleLowerCase().endsWith(I) ? r10 : I}/license/${n2}/${o2}?token=${t2}`; 37274}; 37275var $e2 = ({ playbackId: e, tokens: { drm: t2 } = {}, customDomain: r10 = I }, n2) => { 37276 let o2 = G2(e); 37277 return `https://license.${r10.toLocaleLowerCase().endsWith(I) ? r10 : I}/appcert/${n2}/${o2}?token=${t2}`; 37278}; 37279var Be = ({ playbackId: e, src: t2, customDomain: r10 }) => { 37280 if (e) return true; 37281 if (typeof t2 != "string") return false; 37282 let n2 = window == null ? void 0 : window.location.href, o2 = new URL(t2, n2).hostname.toLocaleLowerCase(); 37283 return o2.includes(I) || !!r10 && o2.includes(r10.toLocaleLowerCase()); 37284}; 37285var Lt2 = (e, t2, r10) => { 37286 var s; 37287 let { envKey: n2, disableTracking: o2 } = e, a2 = Be(e); 37288 if (!o2 && (n2 || a2)) { 37289 let { playerInitTime: u3, playerSoftwareName: l2, playerSoftwareVersion: c3, beaconCollectionDomain: i3, debug: d2, disableCookies: p3 } = e, f = { ...e.metadata, video_title: ((s = e == null ? void 0 : e.metadata) == null ? void 0 : s.video_title) || void 0 }, y4 = (v2) => typeof v2.player_error_code == "string" ? false : typeof e.errorTranslator == "function" ? e.errorTranslator(v2) : v2; 37290 Cd.monitor(t2, { debug: d2, beaconCollectionDomain: i3, hlsjs: r10, Hls: r10 ? R2 : void 0, automaticErrorTracking: false, errorTranslator: y4, disableCookies: p3, data: { ...n2 ? { env_key: n2 } : {}, player_software_name: l2, player_software: l2, player_software_version: c3, player_init_time: u3, ...f } }); 37291 } 37292}; 37293var It2 = (e, t2, r10) => { 37294 var c3, i3; 37295 let n2 = We(e, t2), { src: o2 } = e, a2 = () => { 37296 t2.ended || !xt2(t2, r10) || (Ye2(t2, r10) ? t2.currentTime = t2.buffered.end(t2.buffered.length - 1) : t2.dispatchEvent(new Event("ended"))); 37297 }, s, u3, l2 = () => { 37298 let d2 = Fe2(t2), p3, f; 37299 d2.length > 0 && (p3 = d2.start(0), f = d2.end(0)), (u3 !== f || s !== p3) && t2.dispatchEvent(new CustomEvent("seekablechange", { composed: true })), s = p3, u3 = f; 37300 }; 37301 if (x(t2, "durationchange", l2), t2 && n2) { 37302 let d2 = O(e); 37303 if (typeof o2 == "string") { 37304 let p3 = () => { 37305 if (Le2(t2) !== D2.LIVE || Number.isFinite(t2.duration)) return; 37306 let y4 = setInterval(l2, 1e3); 37307 t2.addEventListener("teardown", () => { 37308 clearInterval(y4); 37309 }, { once: true }), x(t2, "durationchange", () => { 37310 Number.isFinite(t2.duration) && clearInterval(y4); 37311 }); 37312 }, f = async () => dt3(o2, t2, d2).then(p3).catch((y4) => { 37313 if (y4 instanceof Response) { 37314 let v2 = U2(y4, C2.VIDEO, e); 37315 if (v2) { 37316 t2.dispatchEvent(new CustomEvent("error", { detail: v2 })); 37317 return; 37318 } 37319 } else y4 instanceof Error; 37320 }); 37321 if (t2.preload === "none") { 37322 let y4 = () => { 37323 f(), t2.removeEventListener("loadedmetadata", v2); 37324 }, v2 = () => { 37325 f(), t2.removeEventListener("play", y4); 37326 }; 37327 x(t2, "play", y4, { once: true }), x(t2, "loadedmetadata", v2, { once: true }); 37328 } else f(); 37329 (c3 = e.tokens) != null && c3.drm ? Nt2(e, t2) : x(t2, "encrypted", () => { 37330 let y4 = E("Attempting to play DRM-protected content without providing a DRM token."), v2 = new T(y4, T.MEDIA_ERR_ENCRYPTED, true); 37331 v2.errorCategory = C2.DRM, v2.muxCode = M.ENCRYPTED_MISSING_TOKEN, t2.dispatchEvent(new CustomEvent("error", { detail: v2 })); 37332 }, { once: true }), t2.setAttribute("src", o2), e.startTime && (((i3 = _.get(t2)) != null ? i3 : {}).startTime = e.startTime, t2.addEventListener("durationchange", Je2, { once: true })); 37333 } else t2.removeAttribute("src"); 37334 t2.addEventListener("error", Ge2), t2.addEventListener("error", ae), t2.addEventListener("emptied", () => { 37335 t2.querySelectorAll("track[data-removeondestroy]").forEach((f) => { 37336 f.remove(); 37337 }); 37338 }, { once: true }), x(t2, "pause", a2), x(t2, "seeked", a2), x(t2, "play", () => { 37339 t2.ended || Ke2(t2.currentTime, t2.duration) && (t2.currentTime = t2.seekable.length ? t2.seekable.start(0) : 0); 37340 }); 37341 } else r10 && o2 ? (r10.once(R2.Events.LEVEL_LOADED, (d2, p3) => { 37342 pt2(p3.details, t2, r10), l2(), Le2(t2) === D2.LIVE && !Number.isFinite(t2.duration) && (r10.on(R2.Events.LEVEL_UPDATED, l2), x(t2, "durationchange", () => { 37343 Number.isFinite(t2.duration) && r10.off(R2.Events.LEVELS_UPDATED, l2); 37344 })); 37345 }), r10.on(R2.Events.ERROR, (d2, p3) => { 37346 t2.dispatchEvent(new CustomEvent("error", { detail: At2(p3, e) })); 37347 }), t2.addEventListener("error", ae), x(t2, "waiting", a2), Me2(e, r10), Re(t2, r10), r10.attachMedia(t2)) : console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software."); 37348}; 37349function Je2(e) { 37350 var n2; 37351 let t2 = e.target, r10 = (n2 = _.get(t2)) == null ? void 0 : n2.startTime; 37352 if (r10 && de2(t2.seekable, t2.duration, r10)) { 37353 let o2 = t2.preload === "auto"; 37354 o2 && (t2.preload = "none"), t2.currentTime = r10, o2 && (t2.preload = "auto"); 37355 } 37356} 37357async function Ge2(e) { 37358 if (!e.isTrusted) return; 37359 e.stopImmediatePropagation(); 37360 let t2 = e.target; 37361 if (!(t2 != null && t2.error)) return; 37362 let { message: r10, code: n2 } = t2.error, o2 = new T(r10, n2); 37363 if (t2.src && n2 === T.MEDIA_ERR_SRC_NOT_SUPPORTED && t2.readyState === HTMLMediaElement.HAVE_NOTHING) { 37364 setTimeout(() => { 37365 var s; 37366 let a2 = (s = Rt2(t2)) != null ? s : t2.error; 37367 (a2 == null ? void 0 : a2.code) === T.MEDIA_ERR_SRC_NOT_SUPPORTED && t2.dispatchEvent(new CustomEvent("error", { detail: o2 })); 37368 }, 500); 37369 return; 37370 } 37371 if (t2.src && (n2 !== T.MEDIA_ERR_DECODE || n2 !== void 0)) try { 37372 let { status: a2 } = await fetch(t2.src); 37373 o2.data = { response: { code: a2 } }; 37374 } catch { 37375 } 37376 t2.dispatchEvent(new CustomEvent("error", { detail: o2 })); 37377} 37378function ae(e) { 37379 var n2, o2; 37380 if (!(e instanceof CustomEvent) || !(e.detail instanceof T)) return; 37381 let t2 = e.target, r10 = e.detail; 37382 !r10 || !r10.fatal || (((n2 = _.get(t2)) != null ? n2 : {}).error = r10, (o2 = t2.mux) == null || o2.emit("error", { player_error_code: r10.code, player_error_message: r10.message, player_error_context: r10.context })); 37383} 37384var At2 = (e, t2) => { 37385 var u3, l2, c3; 37386 console.error("getErrorFromHlsErrorData()", e); 37387 let r10 = { [R2.ErrorTypes.NETWORK_ERROR]: T.MEDIA_ERR_NETWORK, [R2.ErrorTypes.MEDIA_ERROR]: T.MEDIA_ERR_DECODE, [R2.ErrorTypes.KEY_SYSTEM_ERROR]: T.MEDIA_ERR_ENCRYPTED }, n2 = (i3) => [ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED, ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED].includes(i3.details) ? T.MEDIA_ERR_NETWORK : r10[i3.type], o2 = (i3) => { 37388 if (i3.type === ErrorTypes.KEY_SYSTEM_ERROR) return C2.DRM; 37389 if (i3.type === ErrorTypes.NETWORK_ERROR) return C2.VIDEO; 37390 }, a2, s = n2(e); 37391 if (s === T.MEDIA_ERR_NETWORK && e.response) { 37392 let i3 = (u3 = o2(e)) != null ? u3 : C2.VIDEO; 37393 a2 = (l2 = U2(e.response, i3, t2)) != null ? l2 : new T("", s); 37394 } else if (s === T.MEDIA_ERR_ENCRYPTED) if (e.details === ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE) { 37395 let i3 = E("Attempting to play DRM-protected content without providing a DRM token."); 37396 a2 = new T(i3, T.MEDIA_ERR_ENCRYPTED, e.fatal), a2.errorCategory = C2.DRM, a2.muxCode = M.ENCRYPTED_MISSING_TOKEN; 37397 } else if (e.details === ErrorDetails.KEY_SYSTEM_NO_ACCESS) { 37398 let i3 = E("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser."); 37399 a2 = new T(i3, T.MEDIA_ERR_ENCRYPTED, e.fatal), a2.errorCategory = C2.DRM, a2.muxCode = M.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM; 37400 } else if (e.details === ErrorDetails.KEY_SYSTEM_NO_SESSION) { 37401 let i3 = E("Failed to generate a DRM license request. This may be an issue with the player or your protected content."); 37402 a2 = new T(i3, T.MEDIA_ERR_ENCRYPTED, true), a2.errorCategory = C2.DRM, a2.muxCode = M.ENCRYPTED_GENERATE_REQUEST_FAILED; 37403 } else if (e.details === ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED) { 37404 let i3 = E("Failed to update DRM license. This may be an issue with the player or your protected content."); 37405 a2 = new T(i3, T.MEDIA_ERR_ENCRYPTED, e.fatal), a2.errorCategory = C2.DRM, a2.muxCode = M.ENCRYPTED_UPDATE_LICENSE_FAILED; 37406 } else if (e.details === ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED) { 37407 let i3 = E("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate."); 37408 a2 = new T(i3, T.MEDIA_ERR_ENCRYPTED, e.fatal), a2.errorCategory = C2.DRM, a2.muxCode = M.ENCRYPTED_UPDATE_SERVER_CERT_FAILED; 37409 } else if (e.details === ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR) { 37410 let i3 = E("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser."); 37411 a2 = new T(i3, T.MEDIA_ERR_ENCRYPTED, e.fatal), a2.errorCategory = C2.DRM, a2.muxCode = M.ENCRYPTED_CDM_ERROR; 37412 } else if (e.details === ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED) { 37413 let i3 = E("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen."); 37414 a2 = new T(i3, T.MEDIA_ERR_ENCRYPTED, false), a2.errorCategory = C2.DRM, a2.muxCode = M.ENCRYPTED_OUTPUT_RESTRICTED; 37415 } else a2 = new T(e.error.message, T.MEDIA_ERR_ENCRYPTED, e.fatal), a2.errorCategory = C2.DRM, a2.muxCode = M.ENCRYPTED_ERROR; 37416 else a2 = new T("", s, e.fatal); 37417 return a2.context || (a2.context = `${e.url ? `url: ${e.url} 37418` : ""}${e.response && (e.response.code || e.response.text) ? `response: ${e.response.code}, ${e.response.text} 37419` : ""}${e.reason ? `failure reason: ${e.reason} 37420` : ""}${e.level ? `level: ${e.level} 37421` : ""}${e.parent ? `parent stream controller: ${e.parent} 37422` : ""}${e.buffer ? `buffer length: ${e.buffer} 37423` : ""}${e.error ? `error: ${e.error} 37424` : ""}${e.event ? `event: ${e.event} 37425` : ""}${e.err ? `error message: ${(c3 = e.err) == null ? void 0 : c3.message} 37426` : ""}`), a2.data = e, a2; 37427}; 37428
vendor: 5,115 bytes, lines 37429-37579
37429// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/constants.js 37430var MediaUIEvents = { 37431 MEDIA_PLAY_REQUEST: "mediaplayrequest", 37432 MEDIA_PAUSE_REQUEST: "mediapauserequest", 37433 MEDIA_MUTE_REQUEST: "mediamuterequest", 37434 MEDIA_UNMUTE_REQUEST: "mediaunmuterequest", 37435 MEDIA_VOLUME_REQUEST: "mediavolumerequest", 37436 MEDIA_SEEK_REQUEST: "mediaseekrequest", 37437 MEDIA_AIRPLAY_REQUEST: "mediaairplayrequest", 37438 MEDIA_ENTER_FULLSCREEN_REQUEST: "mediaenterfullscreenrequest", 37439 MEDIA_EXIT_FULLSCREEN_REQUEST: "mediaexitfullscreenrequest", 37440 MEDIA_PREVIEW_REQUEST: "mediapreviewrequest", 37441 MEDIA_ENTER_PIP_REQUEST: "mediaenterpiprequest", 37442 MEDIA_EXIT_PIP_REQUEST: "mediaexitpiprequest", 37443 MEDIA_ENTER_CAST_REQUEST: "mediaentercastrequest", 37444 MEDIA_EXIT_CAST_REQUEST: "mediaexitcastrequest", 37445 MEDIA_SHOW_TEXT_TRACKS_REQUEST: "mediashowtexttracksrequest", 37446 MEDIA_HIDE_TEXT_TRACKS_REQUEST: "mediahidetexttracksrequest", 37447 MEDIA_SHOW_SUBTITLES_REQUEST: "mediashowsubtitlesrequest", 37448 MEDIA_DISABLE_SUBTITLES_REQUEST: "mediadisablesubtitlesrequest", 37449 MEDIA_TOGGLE_SUBTITLES_REQUEST: "mediatogglesubtitlesrequest", 37450 MEDIA_PLAYBACK_RATE_REQUEST: "mediaplaybackraterequest", 37451 MEDIA_RENDITION_REQUEST: "mediarenditionrequest", 37452 MEDIA_AUDIO_TRACK_REQUEST: "mediaaudiotrackrequest", 37453 MEDIA_SEEK_TO_LIVE_REQUEST: "mediaseektoliverequest", 37454 REGISTER_MEDIA_STATE_RECEIVER: "registermediastatereceiver", 37455 UNREGISTER_MEDIA_STATE_RECEIVER: "unregistermediastatereceiver" 37456}; 37457var MediaStateReceiverAttributes = { 37458 MEDIA_CHROME_ATTRIBUTES: "mediachromeattributes", 37459 MEDIA_CONTROLLER: "mediacontroller" 37460}; 37461var MediaUIProps = { 37462 MEDIA_AIRPLAY_UNAVAILABLE: "mediaAirplayUnavailable", 37463 MEDIA_FULLSCREEN_UNAVAILABLE: "mediaFullscreenUnavailable", 37464 MEDIA_PIP_UNAVAILABLE: "mediaPipUnavailable", 37465 MEDIA_CAST_UNAVAILABLE: "mediaCastUnavailable", 37466 MEDIA_RENDITION_UNAVAILABLE: "mediaRenditionUnavailable", 37467 MEDIA_AUDIO_TRACK_UNAVAILABLE: "mediaAudioTrackUnavailable", 37468 MEDIA_WIDTH: "mediaWidth", 37469 MEDIA_HEIGHT: "mediaHeight", 37470 MEDIA_PAUSED: "mediaPaused", 37471 MEDIA_HAS_PLAYED: "mediaHasPlayed", 37472 MEDIA_ENDED: "mediaEnded", 37473 MEDIA_MUTED: "mediaMuted", 37474 MEDIA_VOLUME_LEVEL: "mediaVolumeLevel", 37475 MEDIA_VOLUME: "mediaVolume", 37476 MEDIA_VOLUME_UNAVAILABLE: "mediaVolumeUnavailable", 37477 MEDIA_IS_PIP: "mediaIsPip", 37478 MEDIA_IS_CASTING: "mediaIsCasting", 37479 MEDIA_IS_AIRPLAYING: "mediaIsAirplaying", 37480 MEDIA_SUBTITLES_LIST: "mediaSubtitlesList", 37481 MEDIA_SUBTITLES_SHOWING: "mediaSubtitlesShowing", 37482 MEDIA_IS_FULLSCREEN: "mediaIsFullscreen", 37483 MEDIA_PLAYBACK_RATE: "mediaPlaybackRate", 37484 MEDIA_CURRENT_TIME: "mediaCurrentTime", 37485 MEDIA_DURATION: "mediaDuration", 37486 MEDIA_SEEKABLE: "mediaSeekable", 37487 MEDIA_PREVIEW_TIME: "mediaPreviewTime", 37488 MEDIA_PREVIEW_IMAGE: "mediaPreviewImage", 37489 MEDIA_PREVIEW_COORDS: "mediaPreviewCoords", 37490 MEDIA_PREVIEW_CHAPTER: "mediaPreviewChapter", 37491 MEDIA_LOADING: "mediaLoading", 37492 MEDIA_BUFFERED: "mediaBuffered", 37493 MEDIA_STREAM_TYPE: "mediaStreamType", 37494 MEDIA_TARGET_LIVE_WINDOW: "mediaTargetLiveWindow", 37495 MEDIA_TIME_IS_LIVE: "mediaTimeIsLive", 37496 MEDIA_RENDITION_LIST: "mediaRenditionList", 37497 MEDIA_RENDITION_SELECTED: "mediaRenditionSelected", 37498 MEDIA_AUDIO_TRACK_LIST: "mediaAudioTrackList", 37499 MEDIA_AUDIO_TRACK_ENABLED: "mediaAudioTrackEnabled", 37500 MEDIA_CHAPTERS_CUES: "mediaChaptersCues" 37501}; 37502var MediaUIPropsEntries = Object.entries( 37503 MediaUIProps 37504); 37505var MediaUIAttributes = MediaUIPropsEntries.reduce( 37506 (dictObj, [key, propName]) => { 37507 dictObj[key] = propName.toLowerCase(); 37508 return dictObj; 37509 }, 37510 {} 37511); 37512var AdditionalStateChangeEvents = { 37513 USER_INACTIVE: "userinactivechange", 37514 BREAKPOINTS_CHANGE: "breakpointchange", 37515 BREAKPOINTS_COMPUTED: "breakpointscomputed" 37516}; 37517var MediaStateChangeEvents = MediaUIPropsEntries.reduce( 37518 (dictObj, [key, propName]) => { 37519 dictObj[key] = propName.toLowerCase(); 37520 return dictObj; 37521 }, 37522 { ...AdditionalStateChangeEvents } 37523); 37524var StateChangeEventToAttributeMap = Object.entries( 37525 MediaStateChangeEvents 37526).reduce( 37527 (mapObj, [key, eventType]) => { 37528 const attrName = MediaUIAttributes[key]; 37529 if (attrName) { 37530 mapObj[eventType] = attrName; 37531 } 37532 return mapObj; 37533 }, 37534 { userinactivechange: "userinactive" } 37535); 37536var AttributeToStateChangeEventMap = Object.entries( 37537 MediaUIAttributes 37538).reduce( 37539 (mapObj, [key, attrName]) => { 37540 const evtType = MediaStateChangeEvents[key]; 37541 if (evtType) { 37542 mapObj[attrName] = evtType; 37543 } 37544 return mapObj; 37545 }, 37546 { userinactive: "userinactivechange" } 37547); 37548var TextTrackKinds = { 37549 SUBTITLES: "subtitles", 37550 CAPTIONS: "captions", 37551 DESCRIPTIONS: "descriptions", 37552 CHAPTERS: "chapters", 37553 METADATA: "metadata" 37554}; 37555var TextTrackModes = { 37556 DISABLED: "disabled", 37557 HIDDEN: "hidden", 37558 SHOWING: "showing" 37559}; 37560var PointerTypes = { 37561 MOUSE: "mouse", 37562 PEN: "pen", 37563 TOUCH: "touch" 37564}; 37565var AvailabilityStates = { 37566 UNAVAILABLE: "unavailable", 37567 UNSUPPORTED: "unsupported" 37568}; 37569var StreamTypes = { 37570 LIVE: "live", 37571 ON_DEMAND: "on-demand", 37572 UNKNOWN: "unknown" 37573}; 37574var WebkitPresentationModes = { 37575 INLINE: "inline", 37576 FULLSCREEN: "fullscreen", 37577 PICTURE_IN_PICTURE: "picture-in-picture" 37578}; 37579
vendor: 1,978 bytes, lines 37580-37639
37580// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/labels/labels.js 37581var tooltipLabels = { 37582 ENTER_AIRPLAY: "Start airplay", 37583 EXIT_AIRPLAY: "Stop airplay", 37584 AUDIO_TRACK_MENU: "Audio", 37585 CAPTIONS: "Captions", 37586 ENABLE_CAPTIONS: "Enable captions", 37587 DISABLE_CAPTIONS: "Disable captions", 37588 START_CAST: "Start casting", 37589 STOP_CAST: "Stop casting", 37590 ENTER_FULLSCREEN: "Enter fullscreen mode", 37591 EXIT_FULLSCREEN: "Exit fullscreen mode", 37592 MUTE: "Mute", 37593 UNMUTE: "Unmute", 37594 ENTER_PIP: "Enter picture in picture mode", 37595 EXIT_PIP: "Enter picture in picture mode", 37596 PLAY: "Play", 37597 PAUSE: "Pause", 37598 PLAYBACK_RATE: "Playback rate", 37599 RENDITIONS: "Quality", 37600 SEEK_BACKWARD: "Seek backward", 37601 SEEK_FORWARD: "Seek forward", 37602 SETTINGS: "Settings" 37603}; 37604var nouns = { 37605 AUDIO_PLAYER: () => "audio player", 37606 VIDEO_PLAYER: () => "video player", 37607 VOLUME: () => "volume", 37608 SEEK: () => "seek", 37609 CLOSED_CAPTIONS: () => "closed captions", 37610 PLAYBACK_RATE: ({ playbackRate = 1 } = {}) => `current playback rate ${playbackRate}`, 37611 PLAYBACK_TIME: () => `playback time`, 37612 MEDIA_LOADING: () => `media loading`, 37613 SETTINGS: () => `settings`, 37614 AUDIO_TRACKS: () => `audio tracks`, 37615 QUALITY: () => `quality` 37616}; 37617var verbs = { 37618 PLAY: () => "play", 37619 PAUSE: () => "pause", 37620 MUTE: () => "mute", 37621 UNMUTE: () => "unmute", 37622 ENTER_AIRPLAY: () => "start airplay", 37623 EXIT_AIRPLAY: () => "stop airplay", 37624 ENTER_CAST: () => "start casting", 37625 EXIT_CAST: () => "stop casting", 37626 ENTER_FULLSCREEN: () => "enter fullscreen mode", 37627 EXIT_FULLSCREEN: () => "exit fullscreen mode", 37628 ENTER_PIP: () => "enter picture in picture mode", 37629 EXIT_PIP: () => "exit picture in picture mode", 37630 SEEK_FORWARD_N_SECS: ({ seekOffset = 30 } = {}) => `seek forward ${seekOffset} seconds`, 37631 SEEK_BACK_N_SECS: ({ seekOffset = 30 } = {}) => `seek back ${seekOffset} seconds`, 37632 SEEK_LIVE: () => "seek to live", 37633 PLAYING_LIVE: () => "playing live" 37634}; 37635var labels_default = { 37636 ...nouns, 37637 ...verbs 37638}; 37639
vendor: 1,773 bytes, lines 37640-37694
37640// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/utils/utils.js 37641function stringifyRenditionList(renditions) { 37642 return renditions == null ? void 0 : renditions.map(stringifyRendition).join(" "); 37643} 37644function parseRenditionList(renditions) { 37645 return renditions == null ? void 0 : renditions.split(/\s+/).map(parseRendition); 37646} 37647function stringifyRendition(rendition) { 37648 if (rendition) { 37649 const { id, width, height } = rendition; 37650 return [id, width, height].filter((a2) => a2 != null).join(":"); 37651 } 37652} 37653function parseRendition(rendition) { 37654 if (rendition) { 37655 const [id, width, height] = rendition.split(":"); 37656 return { id, width: +width, height: +height }; 37657 } 37658} 37659function stringifyAudioTrackList(audioTracks) { 37660 return audioTracks == null ? void 0 : audioTracks.map(stringifyAudioTrack).join(" "); 37661} 37662function parseAudioTrackList(audioTracks) { 37663 return audioTracks == null ? void 0 : audioTracks.split(/\s+/).map(parseAudioTrack); 37664} 37665function stringifyAudioTrack(audioTrack) { 37666 if (audioTrack) { 37667 const { id, kind, language, label } = audioTrack; 37668 return [id, kind, language, label].filter((a2) => a2 != null).join(":"); 37669 } 37670} 37671function parseAudioTrack(audioTrack) { 37672 if (audioTrack) { 37673 const [id, kind, language, label] = audioTrack.split(":"); 37674 return { 37675 id, 37676 kind, 37677 language, 37678 label 37679 }; 37680 } 37681} 37682function camelCase(name) { 37683 return name.replace(/[-_]([a-z])/g, ($0, $1) => $1.toUpperCase()); 37684} 37685function isValidNumber(x2) { 37686 return typeof x2 === "number" && !Number.isNaN(x2) && Number.isFinite(x2); 37687} 37688function isNumericString(str) { 37689 if (typeof str != "string") 37690 return false; 37691 return !isNaN(str) && !isNaN(parseFloat(str)); 37692} 37693var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); 37694
vendor: 2,406 bytes, lines 37695-37772
37695// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/utils/time.js 37696var UnitLabels = [ 37697 { 37698 singular: "hour", 37699 plural: "hours" 37700 }, 37701 { 37702 singular: "minute", 37703 plural: "minutes" 37704 }, 37705 { 37706 singular: "second", 37707 plural: "seconds" 37708 } 37709]; 37710var toTimeUnitPhrase = (timeUnitValue, unitIndex) => { 37711 const unitLabel = timeUnitValue === 1 ? UnitLabels[unitIndex].singular : UnitLabels[unitIndex].plural; 37712 return `${timeUnitValue} ${unitLabel}`; 37713}; 37714var formatAsTimePhrase = (seconds) => { 37715 if (!isValidNumber(seconds)) 37716 return ""; 37717 const positiveSeconds = Math.abs(seconds); 37718 const negative = positiveSeconds !== seconds; 37719 const secondsDateTime = new Date(0, 0, 0, 0, 0, positiveSeconds, 0); 37720 const timeParts = [ 37721 secondsDateTime.getHours(), 37722 secondsDateTime.getMinutes(), 37723 secondsDateTime.getSeconds() 37724 ]; 37725 const timeString = timeParts.map( 37726 (timeUnitValue, index2) => timeUnitValue && toTimeUnitPhrase(timeUnitValue, index2) 37727 ).filter((x2) => x2).join(", "); 37728 const negativeSuffix = negative ? " remaining" : ""; 37729 return `${timeString}${negativeSuffix}`; 37730}; 37731function formatTime(seconds, guide) { 37732 let negative = false; 37733 if (seconds < 0) { 37734 negative = true; 37735 seconds = 0 - seconds; 37736 } 37737 seconds = seconds < 0 ? 0 : seconds; 37738 let s = Math.floor(seconds % 60); 37739 let m2 = Math.floor(seconds / 60 % 60); 37740 let h3 = Math.floor(seconds / 3600); 37741 const gm = Math.floor(guide / 60 % 60); 37742 const gh = Math.floor(guide / 3600); 37743 if (isNaN(seconds) || seconds === Infinity) { 37744 h3 = m2 = s = "0"; 37745 } 37746 h3 = h3 > 0 || gh > 0 ? h3 + ":" : ""; 37747 m2 = ((h3 || gm >= 10) && m2 < 10 ? "0" + m2 : m2) + ":"; 37748 s = s < 10 ? "0" + s : s; 37749 return (negative ? "-" : "") + h3 + m2 + s; 37750} 37751var emptyTimeRanges = Object.freeze({ 37752 length: 0, 37753 start(index2) { 37754 const unsignedIdx = index2 >>> 0; 37755 if (unsignedIdx >= this.length) { 37756 throw new DOMException( 37757 `Failed to execute 'start' on 'TimeRanges': The index provided (${unsignedIdx}) is greater than or equal to the maximum bound (${this.length}).` 37758 ); 37759 } 37760 return 0; 37761 }, 37762 end(index2) { 37763 const unsignedIdx = index2 >>> 0; 37764 if (unsignedIdx >= this.length) { 37765 throw new DOMException( 37766 `Failed to execute 'end' on 'TimeRanges': The index provided (${unsignedIdx}) is greater than or equal to the maximum bound (${this.length}).` 37767 ); 37768 } 37769 return 0; 37770 } 37771}); 37772
vendor: 2,387 bytes, lines 37773-37889
37773// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/utils/server-safe-globals.js 37774var EventTarget2 = class { 37775 addEventListener() { 37776 } 37777 removeEventListener() { 37778 } 37779 dispatchEvent() { 37780 return true; 37781 } 37782}; 37783var Node = class extends EventTarget2 { 37784}; 37785var Element2 = class extends Node { 37786 constructor() { 37787 super(...arguments); 37788 this.role = null; 37789 } 37790}; 37791var ResizeObserver = class { 37792 observe() { 37793 } 37794 unobserve() { 37795 } 37796 disconnect() { 37797 } 37798}; 37799var documentShim = { 37800 createElement: function() { 37801 return new globalThisShim.HTMLElement(); 37802 }, 37803 createElementNS: function() { 37804 return new globalThisShim.HTMLElement(); 37805 }, 37806 addEventListener() { 37807 }, 37808 removeEventListener() { 37809 }, 37810 /** 37811 * 37812 * @param {Event} event 37813 * @returns {boolean} 37814 */ 37815 dispatchEvent(event) { 37816 return false; 37817 } 37818}; 37819var globalThisShim = { 37820 ResizeObserver, 37821 document: documentShim, 37822 Node, 37823 Element: Element2, 37824 HTMLElement: class HTMLElement2 extends Element2 { 37825 constructor() { 37826 super(...arguments); 37827 this.innerHTML = ""; 37828 } 37829 get content() { 37830 return new globalThisShim.DocumentFragment(); 37831 } 37832 }, 37833 DocumentFragment: class DocumentFragment2 extends EventTarget2 { 37834 }, 37835 customElements: { 37836 get: function() { 37837 }, 37838 define: function() { 37839 }, 37840 whenDefined: function() { 37841 } 37842 }, 37843 localStorage: { 37844 /** 37845 * @param {string} key 37846 * @returns {string|null} 37847 */ 37848 getItem(key) { 37849 return null; 37850 }, 37851 /** 37852 * @param {string} key 37853 * @param {string} value 37854 */ 37855 setItem(key, value) { 37856 }, 37857 // eslint-disable-line @typescript-eslint/no-unused-vars 37858 /** 37859 * @param {string} key 37860 */ 37861 removeItem(key) { 37862 } 37863 // eslint-disable-line @typescript-eslint/no-unused-vars 37864 }, 37865 CustomEvent: function CustomEvent2() { 37866 }, 37867 getComputedStyle: function() { 37868 }, 37869 navigator: { 37870 languages: [], 37871 get userAgent() { 37872 return ""; 37873 } 37874 }, 37875 /** 37876 * @param {string} media 37877 */ 37878 matchMedia(media) { 37879 return { 37880 matches: false, 37881 media 37882 }; 37883 } 37884}; 37885var isServer = typeof window === "undefined" || typeof window.customElements === "undefined"; 37886var isShimmed = Object.keys(globalThisShim).every((key) => key in globalThis); 37887var GlobalThis = isServer && !isShimmed ? globalThisShim : globalThis; 37888var Document2 = isServer && !isShimmed ? documentShim : globalThis.document; 37889
vendor: 838 bytes, lines 37890-37918
37890// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/utils/resize-observer.js 37891var callbacksMap = /* @__PURE__ */ new WeakMap(); 37892var getCallbacks = (element) => { 37893 let callbacks = callbacksMap.get(element); 37894 if (!callbacks) 37895 callbacksMap.set(element, callbacks = /* @__PURE__ */ new Set()); 37896 return callbacks; 37897}; 37898var observer = new GlobalThis.ResizeObserver( 37899 (entries) => { 37900 for (const entry of entries) { 37901 for (const callback of getCallbacks(entry.target)) { 37902 callback(entry); 37903 } 37904 } 37905 } 37906); 37907function observeResize(element, callback) { 37908 getCallbacks(element).add(callback); 37909 observer.observe(element); 37910} 37911function unobserveResize(element, callback) { 37912 const callbacks = getCallbacks(element); 37913 callbacks.delete(callback); 37914 if (!callbacks.size) { 37915 observer.unobserve(element); 37916 } 37917} 37918
vendor: 5,770 bytes, lines 37919-38107
37919// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/utils/element-utils.js 37920function getMediaController(host) { 37921 var _a3; 37922 return (_a3 = getAttributeMediaController(host)) != null ? _a3 : closestComposedNode(host, "media-controller"); 37923} 37924function getAttributeMediaController(host) { 37925 var _a3; 37926 const { MEDIA_CONTROLLER } = MediaStateReceiverAttributes; 37927 const mediaControllerId = host.getAttribute(MEDIA_CONTROLLER); 37928 if (mediaControllerId) { 37929 return (_a3 = getDocumentOrShadowRoot(host)) == null ? void 0 : _a3.getElementById( 37930 mediaControllerId 37931 ); 37932 } 37933} 37934var updateIconText = (svg, value, selector = ".value") => { 37935 const node2 = svg.querySelector(selector); 37936 if (!node2) 37937 return; 37938 node2.textContent = value; 37939}; 37940var getAllSlotted = (el, name) => { 37941 const slotSelector = `slot[name="${name}"]`; 37942 const slot = el.shadowRoot.querySelector(slotSelector); 37943 if (!slot) 37944 return []; 37945 return slot.children; 37946}; 37947var getSlotted = (el, name) => getAllSlotted(el, name)[0]; 37948var containsComposedNode = (rootNode, childNode) => { 37949 if (!rootNode || !childNode) 37950 return false; 37951 if (rootNode == null ? void 0 : rootNode.contains(childNode)) 37952 return true; 37953 return containsComposedNode( 37954 rootNode, 37955 childNode.getRootNode().host 37956 ); 37957}; 37958var closestComposedNode = (childNode, selector) => { 37959 if (!childNode) 37960 return null; 37961 const closest = childNode.closest(selector); 37962 if (closest) 37963 return closest; 37964 return closestComposedNode( 37965 childNode.getRootNode().host, 37966 selector 37967 ); 37968}; 37969function getActiveElement(root = document) { 37970 var _a3; 37971 const activeEl = root == null ? void 0 : root.activeElement; 37972 if (!activeEl) 37973 return null; 37974 return (_a3 = getActiveElement(activeEl.shadowRoot)) != null ? _a3 : activeEl; 37975} 37976function getDocumentOrShadowRoot(node2) { 37977 var _a3; 37978 const rootNode = (_a3 = node2 == null ? void 0 : node2.getRootNode) == null ? void 0 : _a3.call(node2); 37979 if (rootNode instanceof ShadowRoot || rootNode instanceof Document) { 37980 return rootNode; 37981 } 37982 return null; 37983} 37984function isElementVisible(element, { depth = 3, checkOpacity = true, checkVisibilityCSS = true } = {}) { 37985 if (element.checkVisibility) { 37986 return element.checkVisibility({ 37987 checkOpacity, 37988 checkVisibilityCSS 37989 }); 37990 } 37991 let el = element; 37992 while (el && depth > 0) { 37993 const style = getComputedStyle(el); 37994 if (checkOpacity && style.opacity === "0" || checkVisibilityCSS && style.visibility === "hidden" || style.display === "none") { 37995 return false; 37996 } 37997 el = el.parentElement; 37998 depth--; 37999 } 38000 return true; 38001} 38002function getPointProgressOnLine(x2, y4, p1, p22) { 38003 const segment = distance(p1, p22); 38004 const toStart = distance(p1, { x: x2, y: y4 }); 38005 const toEnd = distance(p22, { x: x2, y: y4 }); 38006 if (toStart > segment || toEnd > segment) { 38007 return toStart > toEnd ? 1 : 0; 38008 } 38009 return toStart / segment; 38010} 38011function distance(p1, p22) { 38012 return Math.sqrt(Math.pow(p22.x - p1.x, 2) + Math.pow(p22.y - p1.y, 2)); 38013} 38014function getOrInsertCSSRule(styleParent, selectorText) { 38015 const cssRule = getCSSRule(styleParent, (st3) => st3 === selectorText); 38016 if (cssRule) 38017 return cssRule; 38018 return insertCSSRule(styleParent, selectorText); 38019} 38020function getCSSRule(styleParent, predicate) { 38021 var _a3, _b; 38022 let style; 38023 for (style of (_a3 = styleParent.querySelectorAll("style:not([media])")) != null ? _a3 : []) { 38024 let cssRules; 38025 try { 38026 cssRules = (_b = style.sheet) == null ? void 0 : _b.cssRules; 38027 } catch { 38028 continue; 38029 } 38030 for (const rule of cssRules != null ? cssRules : []) { 38031 if (predicate(rule.selectorText)) 38032 return rule; 38033 } 38034 } 38035} 38036function insertCSSRule(styleParent, selectorText) { 38037 var _a3, _b; 38038 const styles = (_a3 = styleParent.querySelectorAll("style:not([media])")) != null ? _a3 : []; 38039 const style = styles == null ? void 0 : styles[styles.length - 1]; 38040 if (!(style == null ? void 0 : style.sheet)) { 38041 console.warn( 38042 "Media Chrome: No style sheet found on style tag of", 38043 styleParent 38044 ); 38045 return { 38046 // @ts-ignore 38047 style: { 38048 setProperty: () => { 38049 }, 38050 removeProperty: () => "", 38051 getPropertyValue: () => "" 38052 } 38053 }; 38054 } 38055 style == null ? void 0 : style.sheet.insertRule(`${selectorText}{}`, style.sheet.cssRules.length); 38056 return ( 38057 /** @type {CSSStyleRule} */ 38058 (_b = style.sheet.cssRules) == null ? void 0 : _b[style.sheet.cssRules.length - 1] 38059 ); 38060} 38061function getNumericAttr(el, attrName, defaultValue = Number.NaN) { 38062 const attrVal = el.getAttribute(attrName); 38063 return attrVal != null ? +attrVal : defaultValue; 38064} 38065function setNumericAttr(el, attrName, value) { 38066 const nextNumericValue = +value; 38067 if (value == null || Number.isNaN(nextNumericValue)) { 38068 if (el.hasAttribute(attrName)) { 38069 el.removeAttribute(attrName); 38070 } 38071 return; 38072 } 38073 if (getNumericAttr(el, attrName, void 0) === nextNumericValue) 38074 return; 38075 el.setAttribute(attrName, `${nextNumericValue}`); 38076} 38077function getBooleanAttr(el, attrName) { 38078 return el.hasAttribute(attrName); 38079} 38080function setBooleanAttr(el, attrName, value) { 38081 if (value == null) { 38082 if (el.hasAttribute(attrName)) { 38083 el.removeAttribute(attrName); 38084 } 38085 return; 38086 } 38087 if (getBooleanAttr(el, attrName) == value) 38088 return; 38089 el.toggleAttribute(attrName, value); 38090} 38091function getStringAttr(el, attrName, defaultValue = null) { 38092 var _a3; 38093 return (_a3 = el.getAttribute(attrName)) != null ? _a3 : defaultValue; 38094} 38095function setStringAttr(el, attrName, value) { 38096 if (value == null) { 38097 if (el.hasAttribute(attrName)) { 38098 el.removeAttribute(attrName); 38099 } 38100 return; 38101 } 38102 const nextValue = `${value}`; 38103 if (getStringAttr(el, attrName, void 0) === nextValue) 38104 return; 38105 el.setAttribute(attrName, nextValue); 38106} 38107
vendor: 6,237 bytes, lines 38108-38267
38108// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-gesture-receiver.js 38109var __accessCheck = (obj, member, msg) => { 38110 if (!member.has(obj)) 38111 throw TypeError("Cannot " + msg); 38112}; 38113var __privateGet = (obj, member, getter) => { 38114 __accessCheck(obj, member, "read from private field"); 38115 return getter ? getter.call(obj) : member.get(obj); 38116}; 38117var __privateAdd = (obj, member, value) => { 38118 if (member.has(obj)) 38119 throw TypeError("Cannot add the same private member more than once"); 38120 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 38121}; 38122var __privateSet = (obj, member, value, setter) => { 38123 __accessCheck(obj, member, "write to private field"); 38124 setter ? setter.call(obj, value) : member.set(obj, value); 38125 return value; 38126}; 38127var _mediaController; 38128var template = Document2.createElement("template"); 38129template.innerHTML = /*html*/ 38130` 38131<style> 38132 :host { 38133 display: var(--media-control-display, var(--media-gesture-receiver-display, inline-block)); 38134 box-sizing: border-box; 38135 } 38136</style> 38137`; 38138var MediaGestureReceiver = class extends GlobalThis.HTMLElement { 38139 constructor(options2 = {}) { 38140 super(); 38141 __privateAdd(this, _mediaController, void 0); 38142 if (!this.shadowRoot) { 38143 const shadow = this.attachShadow({ mode: "open" }); 38144 const buttonHTML = template.content.cloneNode(true); 38145 this.nativeEl = buttonHTML; 38146 let slotTemplate17 = options2.slotTemplate; 38147 if (!slotTemplate17) { 38148 slotTemplate17 = Document2.createElement("template"); 38149 slotTemplate17.innerHTML = `<slot>${options2.defaultContent || ""}</slot>`; 38150 } 38151 this.nativeEl.appendChild(slotTemplate17.content.cloneNode(true)); 38152 shadow.appendChild(buttonHTML); 38153 } 38154 } 38155 // NOTE: Currently "baking in" actions + attrs until we come up with 38156 // a more robust architecture (CJP) 38157 static get observedAttributes() { 38158 return [ 38159 MediaStateReceiverAttributes.MEDIA_CONTROLLER, 38160 MediaUIAttributes.MEDIA_PAUSED 38161 ]; 38162 } 38163 attributeChangedCallback(attrName, oldValue, newValue) { 38164 var _a3, _b, _c, _d, _e5; 38165 if (attrName === MediaStateReceiverAttributes.MEDIA_CONTROLLER) { 38166 if (oldValue) { 38167 (_b = (_a3 = __privateGet(this, _mediaController)) == null ? void 0 : _a3.unassociateElement) == null ? void 0 : _b.call(_a3, this); 38168 __privateSet(this, _mediaController, null); 38169 } 38170 if (newValue && this.isConnected) { 38171 __privateSet(this, _mediaController, (_c = this.getRootNode()) == null ? void 0 : _c.getElementById(newValue)); 38172 (_e5 = (_d = __privateGet(this, _mediaController)) == null ? void 0 : _d.associateElement) == null ? void 0 : _e5.call(_d, this); 38173 } 38174 } 38175 } 38176 connectedCallback() { 38177 var _a3, _b, _c, _d; 38178 this.tabIndex = -1; 38179 this.setAttribute("aria-hidden", "true"); 38180 __privateSet(this, _mediaController, getMediaControllerEl(this)); 38181 if (this.getAttribute(MediaStateReceiverAttributes.MEDIA_CONTROLLER)) { 38182 (_b = (_a3 = __privateGet(this, _mediaController)) == null ? void 0 : _a3.associateElement) == null ? void 0 : _b.call(_a3, this); 38183 } 38184 (_c = __privateGet(this, _mediaController)) == null ? void 0 : _c.addEventListener("pointerdown", this); 38185 (_d = __privateGet(this, _mediaController)) == null ? void 0 : _d.addEventListener("click", this); 38186 } 38187 disconnectedCallback() { 38188 var _a3, _b, _c, _d; 38189 if (this.getAttribute(MediaStateReceiverAttributes.MEDIA_CONTROLLER)) { 38190 (_b = (_a3 = __privateGet(this, _mediaController)) == null ? void 0 : _a3.unassociateElement) == null ? void 0 : _b.call(_a3, this); 38191 } 38192 (_c = __privateGet(this, _mediaController)) == null ? void 0 : _c.removeEventListener("pointerdown", this); 38193 (_d = __privateGet(this, _mediaController)) == null ? void 0 : _d.removeEventListener("click", this); 38194 __privateSet(this, _mediaController, null); 38195 } 38196 handleEvent(event) { 38197 var _a3; 38198 const composedTarget = (_a3 = event.composedPath()) == null ? void 0 : _a3[0]; 38199 const allowList = ["video", "media-controller"]; 38200 if (!allowList.includes(composedTarget == null ? void 0 : composedTarget.localName)) 38201 return; 38202 if (event.type === "pointerdown") { 38203 this._pointerType = event.pointerType; 38204 } else if (event.type === "click") { 38205 const { clientX, clientY } = event; 38206 const { left, top, width, height } = this.getBoundingClientRect(); 38207 const x2 = clientX - left; 38208 const y4 = clientY - top; 38209 if (x2 < 0 || y4 < 0 || x2 > width || y4 > height || // In case this element has no dimensions (or display: none) return. 38210 width === 0 && height === 0) { 38211 return; 38212 } 38213 const { pointerType = this._pointerType } = event; 38214 this._pointerType = void 0; 38215 if (pointerType === PointerTypes.TOUCH) { 38216 this.handleTap(event); 38217 return; 38218 } else if (pointerType === PointerTypes.MOUSE) { 38219 this.handleMouseClick(event); 38220 return; 38221 } 38222 } 38223 } 38224 /** 38225 * @type {boolean} Is the media paused 38226 */ 38227 get mediaPaused() { 38228 return getBooleanAttr(this, MediaUIAttributes.MEDIA_PAUSED); 38229 } 38230 set mediaPaused(value) { 38231 setBooleanAttr(this, MediaUIAttributes.MEDIA_PAUSED, value); 38232 } 38233 // NOTE: Currently "baking in" actions + attrs until we come up with 38234 // a more robust architecture (CJP) 38235 /** 38236 * @abstract 38237 * @argument {Event} e 38238 */ 38239 handleTap(e) { 38240 } 38241 // eslint-disable-line 38242 // eslint-disable-next-line 38243 handleMouseClick(e) { 38244 const eventName = this.mediaPaused ? MediaUIEvents.MEDIA_PLAY_REQUEST : MediaUIEvents.MEDIA_PAUSE_REQUEST; 38245 this.dispatchEvent( 38246 new GlobalThis.CustomEvent(eventName, { composed: true, bubbles: true }) 38247 ); 38248 } 38249}; 38250_mediaController = /* @__PURE__ */ new WeakMap(); 38251function getMediaControllerEl(controlEl) { 38252 var _a3; 38253 const mediaControllerId = controlEl.getAttribute( 38254 MediaStateReceiverAttributes.MEDIA_CONTROLLER 38255 ); 38256 if (mediaControllerId) { 38257 return (_a3 = controlEl.getRootNode()) == null ? void 0 : _a3.getElementById(mediaControllerId); 38258 } 38259 return closestComposedNode(controlEl, "media-controller"); 38260} 38261if (!GlobalThis.customElements.get("media-gesture-receiver")) { 38262 GlobalThis.customElements.define( 38263 "media-gesture-receiver", 38264 MediaGestureReceiver 38265 ); 38266} 38267
vendor: 17,408 bytes, lines 38268-38791
38268// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-container.js 38269var __accessCheck2 = (obj, member, msg) => { 38270 if (!member.has(obj)) 38271 throw TypeError("Cannot " + msg); 38272}; 38273var __privateGet2 = (obj, member, getter) => { 38274 __accessCheck2(obj, member, "read from private field"); 38275 return getter ? getter.call(obj) : member.get(obj); 38276}; 38277var __privateAdd2 = (obj, member, value) => { 38278 if (member.has(obj)) 38279 throw TypeError("Cannot add the same private member more than once"); 38280 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 38281}; 38282var __privateSet2 = (obj, member, value, setter) => { 38283 __accessCheck2(obj, member, "write to private field"); 38284 setter ? setter.call(obj, value) : member.set(obj, value); 38285 return value; 38286}; 38287var __privateMethod = (obj, member, method) => { 38288 __accessCheck2(obj, member, "access private method"); 38289 return method; 38290}; 38291var _pointerDownTimeStamp; 38292var _currentMedia; 38293var _inactiveTimeout; 38294var _autohide; 38295var _handlePointerMove; 38296var handlePointerMove_fn; 38297var _handlePointerUp; 38298var handlePointerUp_fn; 38299var _setInactive; 38300var setInactive_fn; 38301var _setActive; 38302var setActive_fn; 38303var _scheduleInactive; 38304var scheduleInactive_fn; 38305var Attributes = { 38306 AUDIO: "audio", 38307 AUTOHIDE: "autohide", 38308 BREAKPOINTS: "breakpoints", 38309 GESTURES_DISABLED: "gesturesdisabled", 38310 KEYBOARD_CONTROL: "keyboardcontrol", 38311 NO_AUTOHIDE: "noautohide", 38312 USER_INACTIVE: "userinactive" 38313}; 38314var template2 = Document2.createElement("template"); 38315template2.innerHTML = /*html*/ 38316` 38317 <style> 38318 ${/* 38319* outline on media is turned off because it is allowed to get focus to faciliate hotkeys. 38320* However, on keyboard interactions, the focus outline is shown, 38321* which is particularly noticeable when going fullscreen via hotkeys. 38322*/ 38323""} 38324 :host([${MediaUIAttributes.MEDIA_IS_FULLSCREEN}]) ::slotted([slot=media]) { 38325 outline: none; 38326 } 38327 38328 :host { 38329 box-sizing: border-box; 38330 position: relative; 38331 display: inline-block; 38332 line-height: 0; 38333 background-color: var(--media-background-color, #000); 38334 } 38335 38336 :host(:not([${Attributes.AUDIO}])) [part~=layer]:not([part~=media-layer]) { 38337 position: absolute; 38338 top: 0; 38339 left: 0; 38340 bottom: 0; 38341 right: 0; 38342 display: flex; 38343 flex-flow: column nowrap; 38344 align-items: start; 38345 pointer-events: none; 38346 background: none; 38347 } 38348 38349 slot[name=media] { 38350 display: var(--media-slot-display, contents); 38351 } 38352 38353 ${/* 38354* when in audio mode, hide the slotted media element by default 38355*/ 38356""} 38357 :host([${Attributes.AUDIO}]) slot[name=media] { 38358 display: var(--media-slot-display, none); 38359 } 38360 38361 ${/* 38362* when in audio mode, hide the gesture-layer which causes media-controller to be taller than the control bar 38363*/ 38364""} 38365 :host([${Attributes.AUDIO}]) [part~=layer][part~=gesture-layer] { 38366 height: 0; 38367 display: block; 38368 } 38369 38370 ${/* 38371* if gestures are disabled, don't accept pointer-events 38372*/ 38373""} 38374 :host(:not([${Attributes.AUDIO}])[${Attributes.GESTURES_DISABLED}]) ::slotted([slot=gestures-chrome]), 38375 :host(:not([${Attributes.AUDIO}])[${Attributes.GESTURES_DISABLED}]) media-gesture-receiver[slot=gestures-chrome] { 38376 display: none; 38377 } 38378 38379 ${/* 38380* any slotted element that isn't a poster or media slot should be pointer-events auto 38381* we'll want to add here any slotted elements that shouldn't get pointer-events by default when slotted 38382*/ 38383""} 38384 ::slotted(:not([slot=media]):not([slot=poster]):not(media-loading-indicator):not([hidden])) { 38385 pointer-events: auto; 38386 } 38387 38388 :host(:not([${Attributes.AUDIO}])) *[part~=layer][part~=centered-layer] { 38389 align-items: center; 38390 justify-content: center; 38391 } 38392 38393 :host(:not([${Attributes.AUDIO}])) ::slotted(media-gesture-receiver[slot=gestures-chrome]), 38394 :host(:not([${Attributes.AUDIO}])) media-gesture-receiver[slot=gestures-chrome] { 38395 align-self: stretch; 38396 flex-grow: 1; 38397 } 38398 38399 slot[name=middle-chrome] { 38400 display: inline; 38401 flex-grow: 1; 38402 pointer-events: none; 38403 background: none; 38404 } 38405 38406 ${/* Position the media and poster elements to fill the container */ 38407""} 38408 ::slotted([slot=media]), 38409 ::slotted([slot=poster]) { 38410 width: 100%; 38411 height: 100%; 38412 } 38413 38414 ${/* Video specific styles */ 38415""} 38416 :host(:not([${Attributes.AUDIO}])) .spacer { 38417 flex-grow: 1; 38418 } 38419 38420 ${/* Safari needs this to actually make the element fill the window */ 38421""} 38422 :host(:-webkit-full-screen) { 38423 ${/* Needs to use !important otherwise easy to break */ 38424""} 38425 width: 100% !important; 38426 height: 100% !important; 38427 } 38428 38429 ${/* Only add these if auto hide is not disabled */ 38430""} 38431 ::slotted(:not([slot=media]):not([slot=poster]):not([${Attributes.NO_AUTOHIDE}]):not([hidden])) { 38432 opacity: 1; 38433 transition: opacity 0.25s; 38434 } 38435 38436 ${/* Hide controls when inactive, not paused, not audio and auto hide not disabled */ 38437""} 38438 :host([${Attributes.USER_INACTIVE}]:not([${MediaUIAttributes.MEDIA_PAUSED}]):not([${MediaUIAttributes.MEDIA_IS_AIRPLAYING}]):not([${MediaUIAttributes.MEDIA_IS_CASTING}]):not([${Attributes.AUDIO}])) ::slotted(:not([slot=media]):not([slot=poster]):not([${Attributes.NO_AUTOHIDE}])) { 38439 opacity: 0; 38440 transition: opacity 1s; 38441 } 38442 38443 :host([${Attributes.USER_INACTIVE}]:not([${MediaUIAttributes.MEDIA_PAUSED}]):not([${MediaUIAttributes.MEDIA_IS_CASTING}]):not([${Attributes.AUDIO}])) ::slotted([slot=media]) { 38444 cursor: none; 38445 } 38446 38447 ::slotted(media-control-bar) { 38448 align-self: stretch; 38449 } 38450 38451 ${/* ::slotted([slot=poster]) doesn't work for slot fallback content so hide parent slot instead */ 38452""} 38453 :host(:not([${Attributes.AUDIO}])[${MediaUIAttributes.MEDIA_HAS_PLAYED}]) slot[name=poster] { 38454 display: none; 38455 } 38456 38457 ::slotted([role="menu"]) { 38458 align-self: end; 38459 } 38460 38461 ::slotted([role="dialog"]) { 38462 align-self: center; 38463 } 38464 </style> 38465 38466 <slot name="media" part="layer media-layer"></slot> 38467 <slot name="poster" part="layer poster-layer"></slot> 38468 <slot name="gestures-chrome" part="layer gesture-layer"> 38469 <media-gesture-receiver slot="gestures-chrome"></media-gesture-receiver> 38470 </slot> 38471 <span part="layer vertical-layer"> 38472 <slot name="top-chrome" part="top chrome"></slot> 38473 <slot name="middle-chrome" part="middle chrome"></slot> 38474 <slot name="centered-chrome" part="layer centered-layer center centered chrome"></slot> 38475 ${/* default, effectively "bottom-chrome" */ 38476""} 38477 <slot part="bottom chrome"></slot> 38478 </span> 38479`; 38480var MEDIA_UI_ATTRIBUTE_NAMES = Object.values(MediaUIAttributes); 38481var defaultBreakpoints = "sm:384 md:576 lg:768 xl:960"; 38482function resizeCallback(entry) { 38483 setBreakpoints(entry.target, entry.contentRect.width); 38484} 38485function setBreakpoints(container, width) { 38486 var _a3; 38487 if (!container.isConnected) 38488 return; 38489 const breakpoints = (_a3 = container.getAttribute(Attributes.BREAKPOINTS)) != null ? _a3 : defaultBreakpoints; 38490 const ranges = createBreakpointMap(breakpoints); 38491 const activeBreakpoints = getBreakpoints(ranges, width); 38492 let changed = false; 38493 Object.keys(ranges).forEach((name) => { 38494 if (activeBreakpoints.includes(name)) { 38495 if (!container.hasAttribute(`breakpoint${name}`)) { 38496 container.setAttribute(`breakpoint${name}`, ""); 38497 changed = true; 38498 } 38499 return; 38500 } 38501 if (container.hasAttribute(`breakpoint${name}`)) { 38502 container.removeAttribute(`breakpoint${name}`); 38503 changed = true; 38504 } 38505 }); 38506 if (changed) { 38507 const evt = new CustomEvent(MediaStateChangeEvents.BREAKPOINTS_CHANGE, { 38508 detail: activeBreakpoints 38509 }); 38510 container.dispatchEvent(evt); 38511 } 38512} 38513function createBreakpointMap(breakpoints) { 38514 const pairs = breakpoints.split(/\s+/); 38515 return Object.fromEntries(pairs.map((pair) => pair.split(":"))); 38516} 38517function getBreakpoints(breakpoints, width) { 38518 return Object.keys(breakpoints).filter((name) => { 38519 return width >= parseInt(breakpoints[name]); 38520 }); 38521} 38522var MediaContainer = class extends GlobalThis.HTMLElement { 38523 constructor() { 38524 super(); 38525 __privateAdd2(this, _handlePointerMove); 38526 __privateAdd2(this, _handlePointerUp); 38527 __privateAdd2(this, _setInactive); 38528 __privateAdd2(this, _setActive); 38529 __privateAdd2(this, _scheduleInactive); 38530 __privateAdd2(this, _pointerDownTimeStamp, 0); 38531 __privateAdd2(this, _currentMedia, null); 38532 __privateAdd2(this, _inactiveTimeout, null); 38533 __privateAdd2(this, _autohide, void 0); 38534 this.breakpointsComputed = false; 38535 if (!this.shadowRoot) { 38536 this.attachShadow({ mode: "open" }); 38537 this.shadowRoot.appendChild(template2.content.cloneNode(true)); 38538 } 38539 const mutationCallback = (mutationsList) => { 38540 const media = this.media; 38541 for (const mutation of mutationsList) { 38542 if (mutation.type === "childList") { 38543 mutation.removedNodes.forEach((node2) => { 38544 if (node2.slot == "media" && mutation.target == this) { 38545 let previousSibling = mutation.previousSibling && mutation.previousSibling.previousElementSibling; 38546 if (!previousSibling || !media) { 38547 this.mediaUnsetCallback(node2); 38548 } else { 38549 let wasFirst = previousSibling.slot !== "media"; 38550 while ((previousSibling = previousSibling.previousSibling) !== null) { 38551 if (previousSibling.slot == "media") 38552 wasFirst = false; 38553 } 38554 if (wasFirst) 38555 this.mediaUnsetCallback(node2); 38556 } 38557 } 38558 }); 38559 if (media) { 38560 mutation.addedNodes.forEach((node2) => { 38561 if (node2 === media) { 38562 this.handleMediaUpdated(media); 38563 } 38564 }); 38565 } 38566 } 38567 } 38568 }; 38569 const mutationObserver = new MutationObserver(mutationCallback); 38570 mutationObserver.observe(this, { childList: true, subtree: true }); 38571 let pendingResizeCb = false; 38572 const deferResizeCallback = (entry) => { 38573 if (pendingResizeCb) 38574 return; 38575 setTimeout(() => { 38576 resizeCallback(entry); 38577 pendingResizeCb = false; 38578 if (!this.breakpointsComputed) { 38579 this.breakpointsComputed = true; 38580 this.dispatchEvent( 38581 new CustomEvent(MediaStateChangeEvents.BREAKPOINTS_COMPUTED, { 38582 bubbles: true, 38583 composed: true 38584 }) 38585 ); 38586 } 38587 }, 0); 38588 pendingResizeCb = true; 38589 }; 38590 observeResize(this, deferResizeCallback); 38591 const chainedSlot = this.querySelector( 38592 ":scope > slot[slot=media]" 38593 ); 38594 if (chainedSlot) { 38595 chainedSlot.addEventListener("slotchange", () => { 38596 const slotEls = chainedSlot.assignedElements({ flatten: true }); 38597 if (!slotEls.length) { 38598 if (__privateGet2(this, _currentMedia)) { 38599 this.mediaUnsetCallback(__privateGet2(this, _currentMedia)); 38600 } 38601 return; 38602 } 38603 this.handleMediaUpdated(this.media); 38604 }); 38605 } 38606 } 38607 static get observedAttributes() { 38608 return [Attributes.AUTOHIDE, Attributes.GESTURES_DISABLED].concat(MEDIA_UI_ATTRIBUTE_NAMES).filter( 38609 (name) => ![ 38610 MediaUIAttributes.MEDIA_RENDITION_LIST, 38611 MediaUIAttributes.MEDIA_AUDIO_TRACK_LIST, 38612 MediaUIAttributes.MEDIA_CHAPTERS_CUES, 38613 MediaUIAttributes.MEDIA_WIDTH, 38614 MediaUIAttributes.MEDIA_HEIGHT 38615 ].includes(name) 38616 ); 38617 } 38618 // Could share this code with media-chrome-html-element instead 38619 attributeChangedCallback(attrName, oldValue, newValue) { 38620 if (attrName.toLowerCase() == Attributes.AUTOHIDE) { 38621 this.autohide = newValue; 38622 } 38623 } 38624 // First direct child with slot=media, or null 38625 /** 38626 * @returns {HTMLVideoElement & 38627 * {buffered, 38628 * webkitEnterFullscreen?, 38629 * webkitExitFullscreen?, 38630 * requestCast?, 38631 * webkitShowPlaybackTargetPicker?, 38632 * videoTracks?, 38633 * }} 38634 */ 38635 get media() { 38636 let media = this.querySelector(":scope > [slot=media]"); 38637 if ((media == null ? void 0 : media.nodeName) == "SLOT") 38638 media = media.assignedElements({ flatten: true })[0]; 38639 return media; 38640 } 38641 /** 38642 * @param {HTMLMediaElement} media 38643 */ 38644 async handleMediaUpdated(media) { 38645 if (!media) 38646 return; 38647 __privateSet2(this, _currentMedia, media); 38648 if (media.localName.includes("-")) { 38649 await GlobalThis.customElements.whenDefined(media.localName); 38650 } 38651 this.mediaSetCallback(media); 38652 } 38653 connectedCallback() { 38654 var _a3; 38655 const isAudioChrome = this.getAttribute(Attributes.AUDIO) != null; 38656 const label = isAudioChrome ? nouns.AUDIO_PLAYER() : nouns.VIDEO_PLAYER(); 38657 this.setAttribute("role", "region"); 38658 this.setAttribute("aria-label", label); 38659 this.handleMediaUpdated(this.media); 38660 this.setAttribute(Attributes.USER_INACTIVE, ""); 38661 this.addEventListener("pointerdown", this); 38662 this.addEventListener("pointermove", this); 38663 this.addEventListener("pointerup", this); 38664 this.addEventListener("mouseleave", this); 38665 this.addEventListener("keyup", this); 38666 (_a3 = GlobalThis.window) == null ? void 0 : _a3.addEventListener("mouseup", this); 38667 } 38668 disconnectedCallback() { 38669 var _a3; 38670 if (this.media) { 38671 this.mediaUnsetCallback(this.media); 38672 } 38673 (_a3 = GlobalThis.window) == null ? void 0 : _a3.removeEventListener("mouseup", this); 38674 } 38675 /** 38676 * @abstract 38677 * @param {HTMLMediaElement} media 38678 */ 38679 mediaSetCallback(media) { 38680 } 38681 // eslint-disable-line 38682 /** 38683 * @param {HTMLMediaElement} media 38684 */ 38685 mediaUnsetCallback(media) { 38686 __privateSet2(this, _currentMedia, null); 38687 } 38688 handleEvent(event) { 38689 switch (event.type) { 38690 case "pointerdown": 38691 __privateSet2(this, _pointerDownTimeStamp, event.timeStamp); 38692 break; 38693 case "pointermove": 38694 __privateMethod(this, _handlePointerMove, handlePointerMove_fn).call(this, event); 38695 break; 38696 case "pointerup": 38697 __privateMethod(this, _handlePointerUp, handlePointerUp_fn).call(this, event); 38698 break; 38699 case "mouseleave": 38700 __privateMethod(this, _setInactive, setInactive_fn).call(this); 38701 break; 38702 case "mouseup": 38703 this.removeAttribute(Attributes.KEYBOARD_CONTROL); 38704 break; 38705 case "keyup": 38706 __privateMethod(this, _scheduleInactive, scheduleInactive_fn).call(this); 38707 this.setAttribute(Attributes.KEYBOARD_CONTROL, ""); 38708 break; 38709 } 38710 } 38711 set autohide(seconds) { 38712 const parsedSeconds = Number(seconds); 38713 __privateSet2(this, _autohide, isNaN(parsedSeconds) ? 0 : parsedSeconds); 38714 } 38715 get autohide() { 38716 return (__privateGet2(this, _autohide) === void 0 ? 2 : __privateGet2(this, _autohide)).toString(); 38717 } 38718}; 38719_pointerDownTimeStamp = /* @__PURE__ */ new WeakMap(); 38720_currentMedia = /* @__PURE__ */ new WeakMap(); 38721_inactiveTimeout = /* @__PURE__ */ new WeakMap(); 38722_autohide = /* @__PURE__ */ new WeakMap(); 38723_handlePointerMove = /* @__PURE__ */ new WeakSet(); 38724handlePointerMove_fn = function(event) { 38725 if (event.pointerType !== "mouse") { 38726 const MAX_TAP_DURATION = 250; 38727 if (event.timeStamp - __privateGet2(this, _pointerDownTimeStamp) < MAX_TAP_DURATION) 38728 return; 38729 } 38730 __privateMethod(this, _setActive, setActive_fn).call(this); 38731 clearTimeout(__privateGet2(this, _inactiveTimeout)); 38732 if ([this, this.media].includes(event.target)) { 38733 __privateMethod(this, _scheduleInactive, scheduleInactive_fn).call(this); 38734 } 38735}; 38736_handlePointerUp = /* @__PURE__ */ new WeakSet(); 38737handlePointerUp_fn = function(event) { 38738 if (event.pointerType === "touch") { 38739 const controlsVisible = !this.hasAttribute(Attributes.USER_INACTIVE); 38740 if ([this, this.media].includes(event.target) && controlsVisible) { 38741 __privateMethod(this, _setInactive, setInactive_fn).call(this); 38742 } else { 38743 __privateMethod(this, _scheduleInactive, scheduleInactive_fn).call(this); 38744 } 38745 } else if (event.composedPath().some( 38746 (el) => ["media-play-button", "media-fullscreen-button"].includes( 38747 el == null ? void 0 : el.localName 38748 ) 38749 )) { 38750 __privateMethod(this, _scheduleInactive, scheduleInactive_fn).call(this); 38751 } 38752}; 38753_setInactive = /* @__PURE__ */ new WeakSet(); 38754setInactive_fn = function() { 38755 if (__privateGet2(this, _autohide) < 0) 38756 return; 38757 if (this.hasAttribute(Attributes.USER_INACTIVE)) 38758 return; 38759 this.setAttribute(Attributes.USER_INACTIVE, ""); 38760 const evt = new GlobalThis.CustomEvent( 38761 MediaStateChangeEvents.USER_INACTIVE, 38762 { composed: true, bubbles: true, detail: true } 38763 ); 38764 this.dispatchEvent(evt); 38765}; 38766_setActive = /* @__PURE__ */ new WeakSet(); 38767setActive_fn = function() { 38768 if (!this.hasAttribute(Attributes.USER_INACTIVE)) 38769 return; 38770 this.removeAttribute(Attributes.USER_INACTIVE); 38771 const evt = new GlobalThis.CustomEvent( 38772 MediaStateChangeEvents.USER_INACTIVE, 38773 { composed: true, bubbles: true, detail: false } 38774 ); 38775 this.dispatchEvent(evt); 38776}; 38777_scheduleInactive = /* @__PURE__ */ new WeakSet(); 38778scheduleInactive_fn = function() { 38779 __privateMethod(this, _setActive, setActive_fn).call(this); 38780 clearTimeout(__privateGet2(this, _inactiveTimeout)); 38781 const autohide = parseInt(this.autohide); 38782 if (autohide < 0) 38783 return; 38784 __privateSet2(this, _inactiveTimeout, setTimeout(() => { 38785 __privateMethod(this, _setInactive, setInactive_fn).call(this); 38786 }, autohide * 1e3)); 38787}; 38788if (!GlobalThis.customElements.get("media-container")) { 38789 GlobalThis.customElements.define("media-container", MediaContainer); 38790} 38791
vendor: 3,688 bytes, lines 38792-38904
38792// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/utils/attribute-token-list.js 38793var __accessCheck3 = (obj, member, msg) => { 38794 if (!member.has(obj)) 38795 throw TypeError("Cannot " + msg); 38796}; 38797var __privateGet3 = (obj, member, getter) => { 38798 __accessCheck3(obj, member, "read from private field"); 38799 return getter ? getter.call(obj) : member.get(obj); 38800}; 38801var __privateAdd3 = (obj, member, value) => { 38802 if (member.has(obj)) 38803 throw TypeError("Cannot add the same private member more than once"); 38804 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 38805}; 38806var __privateSet3 = (obj, member, value, setter) => { 38807 __accessCheck3(obj, member, "write to private field"); 38808 setter ? setter.call(obj, value) : member.set(obj, value); 38809 return value; 38810}; 38811var _el; 38812var _attr; 38813var _defaultSet; 38814var _tokenSet; 38815var _tokens; 38816var tokens_get; 38817var AttributeTokenList = class { 38818 constructor(el, attr, { defaultValue } = { defaultValue: void 0 }) { 38819 __privateAdd3(this, _tokens); 38820 __privateAdd3(this, _el, void 0); 38821 __privateAdd3(this, _attr, void 0); 38822 __privateAdd3(this, _defaultSet, void 0); 38823 __privateAdd3(this, _tokenSet, /* @__PURE__ */ new Set()); 38824 __privateSet3(this, _el, el); 38825 __privateSet3(this, _attr, attr); 38826 __privateSet3(this, _defaultSet, new Set(defaultValue)); 38827 } 38828 [Symbol.iterator]() { 38829 return __privateGet3(this, _tokens, tokens_get).values(); 38830 } 38831 get length() { 38832 return __privateGet3(this, _tokens, tokens_get).size; 38833 } 38834 get value() { 38835 var _a3; 38836 return (_a3 = [...__privateGet3(this, _tokens, tokens_get)].join(" ")) != null ? _a3 : ""; 38837 } 38838 set value(val) { 38839 var _a3; 38840 if (val === this.value) 38841 return; 38842 __privateSet3(this, _tokenSet, /* @__PURE__ */ new Set()); 38843 this.add(...(_a3 = val == null ? void 0 : val.split(" ")) != null ? _a3 : []); 38844 } 38845 toString() { 38846 return this.value; 38847 } 38848 item(index2) { 38849 return [...__privateGet3(this, _tokens, tokens_get)][index2]; 38850 } 38851 values() { 38852 return __privateGet3(this, _tokens, tokens_get).values(); 38853 } 38854 forEach(callback, thisArg) { 38855 __privateGet3(this, _tokens, tokens_get).forEach(callback, thisArg); 38856 } 38857 add(...tokens) { 38858 var _a3, _b; 38859 tokens.forEach((t2) => __privateGet3(this, _tokenSet).add(t2)); 38860 if (this.value === "" && !((_a3 = __privateGet3(this, _el)) == null ? void 0 : _a3.hasAttribute(`${__privateGet3(this, _attr)}`))) { 38861 return; 38862 } 38863 (_b = __privateGet3(this, _el)) == null ? void 0 : _b.setAttribute(`${__privateGet3(this, _attr)}`, `${this.value}`); 38864 } 38865 remove(...tokens) { 38866 var _a3; 38867 tokens.forEach((t2) => __privateGet3(this, _tokenSet).delete(t2)); 38868 (_a3 = __privateGet3(this, _el)) == null ? void 0 : _a3.setAttribute(`${__privateGet3(this, _attr)}`, `${this.value}`); 38869 } 38870 contains(token2) { 38871 return __privateGet3(this, _tokens, tokens_get).has(token2); 38872 } 38873 toggle(token2, force) { 38874 if (typeof force !== "undefined") { 38875 if (force) { 38876 this.add(token2); 38877 return true; 38878 } else { 38879 this.remove(token2); 38880 return false; 38881 } 38882 } 38883 if (this.contains(token2)) { 38884 this.remove(token2); 38885 return false; 38886 } 38887 this.add(token2); 38888 return true; 38889 } 38890 replace(oldToken, newToken) { 38891 this.remove(oldToken); 38892 this.add(newToken); 38893 return oldToken === newToken; 38894 } 38895}; 38896_el = /* @__PURE__ */ new WeakMap(); 38897_attr = /* @__PURE__ */ new WeakMap(); 38898_defaultSet = /* @__PURE__ */ new WeakMap(); 38899_tokenSet = /* @__PURE__ */ new WeakMap(); 38900_tokens = /* @__PURE__ */ new WeakSet(); 38901tokens_get = function() { 38902 return __privateGet3(this, _tokenSet).size ? __privateGet3(this, _tokenSet) : __privateGet3(this, _defaultSet); 38903}; 38904
vendor: 2,704 bytes, lines 38905-38978
38905// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/utils/captions.js 38906var splitTextTracksStr = (textTracksStr = "") => textTracksStr.split(/\s+/); 38907var parseTextTrackStr = (textTrackStr = "") => { 38908 const [kind, language, encodedLabel] = textTrackStr.split(":"); 38909 const label = encodedLabel ? decodeURIComponent(encodedLabel) : void 0; 38910 return { 38911 kind: kind === "cc" ? TextTrackKinds.CAPTIONS : TextTrackKinds.SUBTITLES, 38912 language, 38913 label 38914 }; 38915}; 38916var parseTextTracksStr = (textTracksStr = "", textTrackLikeObj = {}) => { 38917 return splitTextTracksStr(textTracksStr).map((textTrackStr) => { 38918 const textTrackObj = parseTextTrackStr(textTrackStr); 38919 return { 38920 ...textTrackLikeObj, 38921 ...textTrackObj 38922 }; 38923 }); 38924}; 38925var parseTracks = (trackOrTracks) => { 38926 if (!trackOrTracks) 38927 return []; 38928 if (Array.isArray(trackOrTracks)) { 38929 return trackOrTracks.map((trackObjOrStr) => { 38930 if (typeof trackObjOrStr === "string") { 38931 return parseTextTrackStr(trackObjOrStr); 38932 } 38933 return trackObjOrStr; 38934 }); 38935 } 38936 if (typeof trackOrTracks === "string") { 38937 return parseTextTracksStr(trackOrTracks); 38938 } 38939 return [trackOrTracks]; 38940}; 38941var formatTextTrackObj = ({ kind, label, language } = { kind: "subtitles" }) => { 38942 if (!label) 38943 return language; 38944 return `${kind === "captions" ? "cc" : "sb"}:${language}:${encodeURIComponent( 38945 label 38946 )}`; 38947}; 38948var stringifyTextTrackList = (textTracks = []) => { 38949 return Array.prototype.map.call(textTracks, formatTextTrackObj).join(" "); 38950}; 38951var isMatchingPropOf = (key, value) => (obj) => obj[key] === value; 38952var textTrackObjAsPred = (filterObj) => { 38953 const preds = Object.entries(filterObj).map(([key, value]) => { 38954 return isMatchingPropOf(key, value); 38955 }); 38956 return (textTrack) => preds.every((pred) => pred(textTrack)); 38957}; 38958var updateTracksModeTo = (mode, tracks = [], tracksToUpdate = []) => { 38959 const preds = parseTracks(tracksToUpdate).map(textTrackObjAsPred); 38960 const isTrackToUpdate = (textTrack) => { 38961 return preds.some((pred) => pred(textTrack)); 38962 }; 38963 Array.from(tracks).filter(isTrackToUpdate).forEach((textTrack) => { 38964 textTrack.mode = mode; 38965 }); 38966}; 38967var getTextTracksList = (media, filterPredOrObj = () => true) => { 38968 if (!(media == null ? void 0 : media.textTracks)) 38969 return []; 38970 const filterPred = typeof filterPredOrObj === "function" ? filterPredOrObj : textTrackObjAsPred(filterPredOrObj); 38971 return Array.from(media.textTracks).filter(filterPred); 38972}; 38973var areSubsOn = (el) => { 38974 var _a3; 38975 const showingSubtitles = !!((_a3 = el.mediaSubtitlesShowing) == null ? void 0 : _a3.length) || el.hasAttribute(MediaUIAttributes.MEDIA_SUBTITLES_SHOWING); 38976 return showingSubtitles; 38977}; 38978
vendor: 3,563 bytes, lines 38979-39051
38979// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/utils/fullscreen-api.js 38980var enterFullscreen = (stateOwners) => { 38981 var _a3; 38982 const { media, fullscreenElement } = stateOwners; 38983 const enterFullscreenKey = fullscreenElement && "requestFullscreen" in fullscreenElement ? "requestFullscreen" : fullscreenElement && "webkitRequestFullScreen" in fullscreenElement ? "webkitRequestFullScreen" : void 0; 38984 if (enterFullscreenKey) { 38985 const maybePromise = (_a3 = fullscreenElement[enterFullscreenKey]) == null ? void 0 : _a3.call(fullscreenElement); 38986 if (maybePromise instanceof Promise) { 38987 return maybePromise.catch(() => { 38988 }); 38989 } 38990 } else if (media == null ? void 0 : media.webkitEnterFullscreen) { 38991 media.webkitEnterFullscreen(); 38992 } else if (media == null ? void 0 : media.requestFullscreen) { 38993 media.requestFullscreen(); 38994 } 38995}; 38996var exitFullscreenKey = "exitFullscreen" in Document2 ? "exitFullscreen" : "webkitExitFullscreen" in Document2 ? "webkitExitFullscreen" : "webkitCancelFullScreen" in Document2 ? "webkitCancelFullScreen" : void 0; 38997var exitFullscreen = (stateOwners) => { 38998 var _a3; 38999 const { documentElement } = stateOwners; 39000 if (exitFullscreenKey) { 39001 const maybePromise = (_a3 = documentElement == null ? void 0 : documentElement[exitFullscreenKey]) == null ? void 0 : _a3.call(documentElement); 39002 if (maybePromise instanceof Promise) { 39003 return maybePromise.catch(() => { 39004 }); 39005 } 39006 } 39007}; 39008var fullscreenElementKey = "fullscreenElement" in Document2 ? "fullscreenElement" : "webkitFullscreenElement" in Document2 ? "webkitFullscreenElement" : void 0; 39009var getFullscreenElement = (stateOwners) => { 39010 const { documentElement, media } = stateOwners; 39011 const docFullscreenElement = documentElement == null ? void 0 : documentElement[fullscreenElementKey]; 39012 if (!docFullscreenElement && "webkitDisplayingFullscreen" in media && "webkitPresentationMode" in media && media.webkitDisplayingFullscreen && media.webkitPresentationMode === WebkitPresentationModes.FULLSCREEN) { 39013 return media; 39014 } 39015 return docFullscreenElement; 39016}; 39017var isFullscreen = (stateOwners) => { 39018 var _a3; 39019 const { media, documentElement, fullscreenElement = media } = stateOwners; 39020 if (!media || !documentElement) 39021 return false; 39022 const currentFullscreenElement = getFullscreenElement(stateOwners); 39023 if (!currentFullscreenElement) 39024 return false; 39025 if (currentFullscreenElement === fullscreenElement || currentFullscreenElement === media) { 39026 return true; 39027 } 39028 if (currentFullscreenElement.localName.includes("-")) { 39029 let currentRoot = currentFullscreenElement.shadowRoot; 39030 if (!(fullscreenElementKey in currentRoot)) { 39031 return containsComposedNode( 39032 currentFullscreenElement, 39033 /** @TODO clean up type assumptions (e.g. Node) (CJP) */ 39034 // @ts-ignore 39035 fullscreenElement 39036 ); 39037 } 39038 while (currentRoot == null ? void 0 : currentRoot[fullscreenElementKey]) { 39039 if (currentRoot[fullscreenElementKey] === fullscreenElement) 39040 return true; 39041 currentRoot = (_a3 = currentRoot[fullscreenElementKey]) == null ? void 0 : _a3.shadowRoot; 39042 } 39043 } 39044 return false; 39045}; 39046var fullscreenEnabledKey = "fullscreenEnabled" in Document2 ? "fullscreenEnabled" : "webkitFullscreenEnabled" in Document2 ? "webkitFullscreenEnabled" : void 0; 39047var isFullscreenEnabled = (stateOwners) => { 39048 const { documentElement, media } = stateOwners; 39049 return !!(documentElement == null ? void 0 : documentElement[fullscreenEnabledKey]) || media && "webkitSupportsFullscreen" in media; 39050}; 39051
vendor: 1,852 bytes, lines 39052-39102
39052// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/utils/platform-tests.js 39053var testMediaEl; 39054var getTestMediaEl = () => { 39055 var _a3, _b; 39056 if (testMediaEl) 39057 return testMediaEl; 39058 testMediaEl = (_b = (_a3 = Document2) == null ? void 0 : _a3.createElement) == null ? void 0 : _b.call(_a3, "video"); 39059 return testMediaEl; 39060}; 39061var hasVolumeSupportAsync = async (mediaEl = getTestMediaEl()) => { 39062 if (!mediaEl) 39063 return false; 39064 const prevVolume = mediaEl.volume; 39065 mediaEl.volume = prevVolume / 2 + 0.1; 39066 const abortController = new AbortController(); 39067 const volumeSupported2 = await Promise.race([ 39068 dispatchedVolumeChange(mediaEl, abortController.signal), 39069 volumeChanged(mediaEl, prevVolume) 39070 ]); 39071 abortController.abort(); 39072 return volumeSupported2; 39073}; 39074var dispatchedVolumeChange = (mediaEl, signal) => { 39075 return new Promise((resolve) => { 39076 mediaEl.addEventListener("volumechange", () => resolve(true), { signal }); 39077 }); 39078}; 39079var volumeChanged = async (mediaEl, prevVolume) => { 39080 for (let i3 = 0; i3 < 10; i3++) { 39081 if (mediaEl.volume === prevVolume) 39082 return false; 39083 await delay(10); 39084 } 39085 return mediaEl.volume !== prevVolume; 39086}; 39087var isSafari = /.*Version\/.*Safari\/.*/.test( 39088 GlobalThis.navigator.userAgent 39089); 39090var hasPipSupport = (mediaEl = getTestMediaEl()) => { 39091 if (GlobalThis.matchMedia("(display-mode: standalone)").matches && isSafari) 39092 return false; 39093 return typeof (mediaEl == null ? void 0 : mediaEl.requestPictureInPicture) === "function"; 39094}; 39095var hasFullscreenSupport = (mediaEl = getTestMediaEl()) => { 39096 return isFullscreenEnabled({ documentElement: Document2, media: mediaEl }); 39097}; 39098var fullscreenSupported = hasFullscreenSupport(); 39099var pipSupported = hasPipSupport(); 39100var airplaySupported = !!GlobalThis.WebKitPlaybackTargetAvailabilityEvent; 39101var castSupported = !!GlobalThis.chrome; 39102
vendor: 3,225 bytes, lines 39103-39185
39103// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-store/util.js 39104var getSubtitleTracks = (stateOwners) => { 39105 return getTextTracksList(stateOwners.media, (textTrack) => { 39106 return [TextTrackKinds.SUBTITLES, TextTrackKinds.CAPTIONS].includes( 39107 textTrack.kind 39108 ); 39109 }).sort((a2, b3) => a2.kind >= b3.kind ? 1 : -1); 39110}; 39111var getShowingSubtitleTracks = (stateOwners) => { 39112 return getTextTracksList(stateOwners.media, (textTrack) => { 39113 return textTrack.mode === TextTrackModes.SHOWING && [TextTrackKinds.SUBTITLES, TextTrackKinds.CAPTIONS].includes( 39114 textTrack.kind 39115 ); 39116 }); 39117}; 39118var toggleSubtitleTracks = (stateOwners, force) => { 39119 const tracks = getSubtitleTracks(stateOwners); 39120 const showingSubitleTracks = getShowingSubtitleTracks(stateOwners); 39121 const subtitlesShowing = !!showingSubitleTracks.length; 39122 if (!tracks.length) 39123 return; 39124 if (force === false || subtitlesShowing && force !== true) { 39125 updateTracksModeTo(TextTrackModes.DISABLED, tracks, showingSubitleTracks); 39126 } else if (force === true || !subtitlesShowing && force !== false) { 39127 let subTrack = tracks[0]; 39128 const { options: options2 } = stateOwners; 39129 if (!(options2 == null ? void 0 : options2.noSubtitlesLangPref)) { 39130 const subtitlesPref = globalThis.localStorage.getItem( 39131 "media-chrome-pref-subtitles-lang" 39132 ); 39133 const userLangPrefs = subtitlesPref ? [subtitlesPref, ...globalThis.navigator.languages] : globalThis.navigator.languages; 39134 const preferredAvailableSubs = tracks.filter((textTrack) => { 39135 return userLangPrefs.some( 39136 (lang) => textTrack.language.toLowerCase().startsWith(lang.split("-")[0]) 39137 ); 39138 }).sort((textTrackA, textTrackB) => { 39139 const idxA = userLangPrefs.findIndex( 39140 (lang) => textTrackA.language.toLowerCase().startsWith(lang.split("-")[0]) 39141 ); 39142 const idxB = userLangPrefs.findIndex( 39143 (lang) => textTrackB.language.toLowerCase().startsWith(lang.split("-")[0]) 39144 ); 39145 return idxA - idxB; 39146 }); 39147 if (preferredAvailableSubs[0]) { 39148 subTrack = preferredAvailableSubs[0]; 39149 } 39150 } 39151 const { language, label, kind } = subTrack; 39152 updateTracksModeTo(TextTrackModes.DISABLED, tracks, showingSubitleTracks); 39153 updateTracksModeTo(TextTrackModes.SHOWING, tracks, [ 39154 { language, label, kind } 39155 ]); 39156 } 39157}; 39158var areValuesEq = (x2, y4) => { 39159 if (x2 === y4) 39160 return true; 39161 if (typeof x2 !== typeof y4) 39162 return false; 39163 if (typeof x2 === "number" && Number.isNaN(x2) && Number.isNaN(y4)) 39164 return true; 39165 if (typeof x2 !== "object") 39166 return false; 39167 if (Array.isArray(x2)) 39168 return areArraysEq(x2, y4); 39169 return Object.entries(x2).every( 39170 // NOTE: Checking key in y to disambiguate between between missing keys and keys whose value are undefined (CJP) 39171 ([key, value]) => key in y4 && areValuesEq(value, y4[key]) 39172 ); 39173}; 39174var areArraysEq = (xs, ys) => { 39175 const xIsArray = Array.isArray(xs); 39176 const yIsArray = Array.isArray(ys); 39177 if (xIsArray !== yIsArray) 39178 return false; 39179 if (!(xIsArray || yIsArray)) 39180 return true; 39181 if (xs.length !== ys.length) 39182 return false; 39183 return xs.every((x2, i3) => areValuesEq(x2, ys[i3])); 39184}; 39185
vendor: 26,273 bytes, lines 39186-39966
39186// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-store/state-mediator.js 39187var StreamTypeValues = Object.values(StreamTypes); 39188var volumeSupported; 39189var volumeSupportPromise = hasVolumeSupportAsync().then((supported) => { 39190 volumeSupported = supported; 39191 return volumeSupported; 39192}); 39193var prepareStateOwners = async (...stateOwners) => { 39194 await Promise.all( 39195 stateOwners.filter((x2) => x2).map(async (stateOwner) => { 39196 if (!("localName" in stateOwner && stateOwner instanceof GlobalThis.HTMLElement)) { 39197 return; 39198 } 39199 const name = stateOwner.localName; 39200 if (!name.includes("-")) 39201 return; 39202 const classDef = GlobalThis.customElements.get(name); 39203 if (classDef && stateOwner instanceof classDef) 39204 return; 39205 await GlobalThis.customElements.whenDefined(name); 39206 GlobalThis.customElements.upgrade(stateOwner); 39207 }) 39208 ); 39209}; 39210var stateMediator = { 39211 mediaWidth: { 39212 get(stateOwners) { 39213 var _a3; 39214 const { media } = stateOwners; 39215 return (_a3 = media == null ? void 0 : media.videoWidth) != null ? _a3 : 0; 39216 }, 39217 mediaEvents: ["resize"] 39218 }, 39219 mediaHeight: { 39220 get(stateOwners) { 39221 var _a3; 39222 const { media } = stateOwners; 39223 return (_a3 = media == null ? void 0 : media.videoHeight) != null ? _a3 : 0; 39224 }, 39225 mediaEvents: ["resize"] 39226 }, 39227 mediaPaused: { 39228 get(stateOwners) { 39229 var _a3; 39230 const { media } = stateOwners; 39231 return (_a3 = media == null ? void 0 : media.paused) != null ? _a3 : true; 39232 }, 39233 set(value, stateOwners) { 39234 var _a3; 39235 const { media } = stateOwners; 39236 if (!media) 39237 return; 39238 if (value) { 39239 media.pause(); 39240 } else { 39241 (_a3 = media.play()) == null ? void 0 : _a3.catch(() => { 39242 }); 39243 } 39244 }, 39245 mediaEvents: ["play", "playing", "pause", "emptied"] 39246 }, 39247 mediaHasPlayed: { 39248 // We want to let the user know that the media started playing at any point (`media-has-played`). 39249 // Since these propagators are all called when boostrapping state, let's verify this is 39250 // a real playing event by checking that 1) there's media and 2) it isn't currently paused. 39251 get(stateOwners, event) { 39252 const { media } = stateOwners; 39253 if (!media) 39254 return false; 39255 if (!event) 39256 return !media.paused; 39257 return event.type === "playing"; 39258 }, 39259 mediaEvents: ["playing", "emptied"] 39260 }, 39261 mediaEnded: { 39262 get(stateOwners) { 39263 var _a3; 39264 const { media } = stateOwners; 39265 return (_a3 = media == null ? void 0 : media.ended) != null ? _a3 : false; 39266 }, 39267 mediaEvents: ["seeked", "ended", "emptied"] 39268 }, 39269 mediaPlaybackRate: { 39270 get(stateOwners) { 39271 var _a3; 39272 const { media } = stateOwners; 39273 return (_a3 = media == null ? void 0 : media.playbackRate) != null ? _a3 : 1; 39274 }, 39275 set(value, stateOwners) { 39276 const { media } = stateOwners; 39277 if (!media) 39278 return; 39279 if (!Number.isFinite(+value)) 39280 return; 39281 media.playbackRate = +value; 39282 }, 39283 mediaEvents: ["ratechange", "loadstart"] 39284 }, 39285 mediaMuted: { 39286 get(stateOwners) { 39287 var _a3; 39288 const { media } = stateOwners; 39289 return (_a3 = media == null ? void 0 : media.muted) != null ? _a3 : false; 39290 }, 39291 set(value, stateOwners) { 39292 const { media } = stateOwners; 39293 if (!media) 39294 return; 39295 media.muted = value; 39296 }, 39297 mediaEvents: ["volumechange"] 39298 }, 39299 mediaVolume: { 39300 get(stateOwners) { 39301 var _a3; 39302 const { media } = stateOwners; 39303 return (_a3 = media == null ? void 0 : media.volume) != null ? _a3 : 1; 39304 }, 39305 set(value, stateOwners) { 39306 const { media } = stateOwners; 39307 if (!media) 39308 return; 39309 try { 39310 if (value == null) { 39311 GlobalThis.localStorage.removeItem("media-chrome-pref-volume"); 39312 } else { 39313 GlobalThis.localStorage.setItem( 39314 "media-chrome-pref-volume", 39315 value.toString() 39316 ); 39317 } 39318 } catch (err) { 39319 } 39320 if (!Number.isFinite(+value)) 39321 return; 39322 media.volume = +value; 39323 }, 39324 mediaEvents: ["volumechange"], 39325 stateOwnersUpdateHandlers: [ 39326 (handler, stateOwners) => { 39327 const { 39328 options: { noVolumePref } 39329 } = stateOwners; 39330 if (noVolumePref) 39331 return; 39332 try { 39333 const volumePref = GlobalThis.localStorage.getItem( 39334 "media-chrome-pref-volume" 39335 ); 39336 if (volumePref == null) 39337 return; 39338 stateMediator.mediaVolume.set(+volumePref, stateOwners); 39339 handler(+volumePref); 39340 } catch (e) { 39341 console.debug("Error getting volume pref", e); 39342 } 39343 } 39344 ] 39345 }, 39346 // NOTE: Keeping this roughly equivalent to prior impl to reduce number of changes, 39347 // however we may want to model "derived" state differently from "primary" state 39348 // (in this case, derived === mediaVolumeLevel, primary === mediaMuted, mediaVolume) (CJP) 39349 mediaVolumeLevel: { 39350 get(stateOwners) { 39351 const { media } = stateOwners; 39352 if (typeof (media == null ? void 0 : media.volume) == "undefined") 39353 return "high"; 39354 if (media.muted || media.volume === 0) 39355 return "off"; 39356 if (media.volume < 0.5) 39357 return "low"; 39358 if (media.volume < 0.75) 39359 return "medium"; 39360 return "high"; 39361 }, 39362 mediaEvents: ["volumechange"] 39363 }, 39364 mediaCurrentTime: { 39365 get(stateOwners) { 39366 var _a3; 39367 const { media } = stateOwners; 39368 return (_a3 = media == null ? void 0 : media.currentTime) != null ? _a3 : 0; 39369 }, 39370 set(value, stateOwners) { 39371 const { media } = stateOwners; 39372 if (!media || !isValidNumber(value)) 39373 return; 39374 media.currentTime = value; 39375 }, 39376 mediaEvents: ["timeupdate", "loadedmetadata"] 39377 }, 39378 mediaDuration: { 39379 get(stateOwners) { 39380 const { media, options: { defaultDuration } = {} } = stateOwners; 39381 if (defaultDuration && (!media || !media.duration || Number.isNaN(media.duration) || !Number.isFinite(media.duration))) { 39382 return defaultDuration; 39383 } 39384 return Number.isFinite(media == null ? void 0 : media.duration) ? media.duration : Number.NaN; 39385 }, 39386 mediaEvents: ["durationchange", "loadedmetadata", "emptied"] 39387 }, 39388 mediaLoading: { 39389 get(stateOwners) { 39390 const { media } = stateOwners; 39391 return (media == null ? void 0 : media.readyState) < 3; 39392 }, 39393 mediaEvents: ["waiting", "playing", "emptied"] 39394 }, 39395 mediaSeekable: { 39396 get(stateOwners) { 39397 var _a3; 39398 const { media } = stateOwners; 39399 if (!((_a3 = media == null ? void 0 : media.seekable) == null ? void 0 : _a3.length)) 39400 return void 0; 39401 const start = media.seekable.start(0); 39402 const end = media.seekable.end(media.seekable.length - 1); 39403 if (!start && !end) 39404 return void 0; 39405 return [Number(start.toFixed(3)), Number(end.toFixed(3))]; 39406 }, 39407 mediaEvents: ["loadedmetadata", "emptied", "progress", "seekablechange"] 39408 }, 39409 mediaBuffered: { 39410 get(stateOwners) { 39411 var _a3; 39412 const { media } = stateOwners; 39413 const timeRanges = (_a3 = media == null ? void 0 : media.buffered) != null ? _a3 : []; 39414 return Array.from(timeRanges).map((_3, i3) => [ 39415 Number(timeRanges.start(i3).toFixed(3)), 39416 Number(timeRanges.end(i3).toFixed(3)) 39417 ]); 39418 }, 39419 mediaEvents: ["progress", "emptied"] 39420 }, 39421 mediaStreamType: { 39422 get(stateOwners) { 39423 const { media, options: { defaultStreamType } = {} } = stateOwners; 39424 const usedDefaultStreamType = [ 39425 StreamTypes.LIVE, 39426 StreamTypes.ON_DEMAND 39427 ].includes(defaultStreamType) ? defaultStreamType : void 0; 39428 if (!media) 39429 return usedDefaultStreamType; 39430 const { streamType } = media; 39431 if (StreamTypeValues.includes(streamType)) { 39432 if (streamType === StreamTypes.UNKNOWN) { 39433 return usedDefaultStreamType; 39434 } 39435 return streamType; 39436 } 39437 const duration = media.duration; 39438 if (duration === Infinity) { 39439 return StreamTypes.LIVE; 39440 } else if (Number.isFinite(duration)) { 39441 return StreamTypes.ON_DEMAND; 39442 } 39443 return usedDefaultStreamType; 39444 }, 39445 mediaEvents: [ 39446 "emptied", 39447 "durationchange", 39448 "loadedmetadata", 39449 "streamtypechange" 39450 ] 39451 }, 39452 mediaTargetLiveWindow: { 39453 get(stateOwners) { 39454 const { media } = stateOwners; 39455 if (!media) 39456 return Number.NaN; 39457 const { targetLiveWindow } = media; 39458 const streamType = stateMediator.mediaStreamType.get(stateOwners); 39459 if ((targetLiveWindow == null || Number.isNaN(targetLiveWindow)) && streamType === StreamTypes.LIVE) { 39460 return 0; 39461 } 39462 return targetLiveWindow; 39463 }, 39464 mediaEvents: [ 39465 "emptied", 39466 "durationchange", 39467 "loadedmetadata", 39468 "streamtypechange", 39469 "targetlivewindowchange" 39470 ] 39471 }, 39472 mediaTimeIsLive: { 39473 get(stateOwners) { 39474 const { 39475 media, 39476 // Default to 10 seconds 39477 options: { liveEdgeOffset = 10 } = {} 39478 } = stateOwners; 39479 if (!media) 39480 return false; 39481 if (typeof media.liveEdgeStart === "number") { 39482 if (Number.isNaN(media.liveEdgeStart)) 39483 return false; 39484 return media.currentTime >= media.liveEdgeStart; 39485 } 39486 const live = stateMediator.mediaStreamType.get(stateOwners) === StreamTypes.LIVE; 39487 if (!live) 39488 return false; 39489 const seekable = media.seekable; 39490 if (!seekable) 39491 return true; 39492 if (!seekable.length) 39493 return false; 39494 const liveEdgeStart = seekable.end(seekable.length - 1) - liveEdgeOffset; 39495 return media.currentTime >= liveEdgeStart; 39496 }, 39497 mediaEvents: ["playing", "timeupdate", "progress", "waiting", "emptied"] 39498 }, 39499 // Text Tracks modeling 39500 mediaSubtitlesList: { 39501 get(stateOwners) { 39502 return getSubtitleTracks(stateOwners).map( 39503 ({ kind, label, language }) => ({ kind, label, language }) 39504 ); 39505 }, 39506 mediaEvents: ["loadstart"], 39507 textTracksEvents: ["addtrack", "removetrack"] 39508 }, 39509 mediaSubtitlesShowing: { 39510 get(stateOwners) { 39511 return getShowingSubtitleTracks(stateOwners).map( 39512 ({ kind, label, language }) => ({ kind, label, language }) 39513 ); 39514 }, 39515 mediaEvents: ["loadstart"], 39516 textTracksEvents: ["addtrack", "removetrack", "change"], 39517 stateOwnersUpdateHandlers: [ 39518 (_handler, stateOwners) => { 39519 var _a3, _b; 39520 const { media, options: options2 } = stateOwners; 39521 if (!media) 39522 return; 39523 const updateDefaultSubtitlesCallback = (event) => { 39524 var _a22; 39525 if (!options2.defaultSubtitles) 39526 return; 39527 const nonSubsEvent = event && ![TextTrackKinds.CAPTIONS, TextTrackKinds.SUBTITLES].includes( 39528 // @ts-ignore 39529 (_a22 = event == null ? void 0 : event.track) == null ? void 0 : _a22.kind 39530 ); 39531 if (nonSubsEvent) 39532 return; 39533 toggleSubtitleTracks(stateOwners, true); 39534 }; 39535 (_a3 = media.textTracks) == null ? void 0 : _a3.addEventListener( 39536 "addtrack", 39537 updateDefaultSubtitlesCallback 39538 ); 39539 (_b = media.textTracks) == null ? void 0 : _b.addEventListener( 39540 "removetrack", 39541 updateDefaultSubtitlesCallback 39542 ); 39543 updateDefaultSubtitlesCallback(); 39544 return () => { 39545 var _a22, _b2; 39546 (_a22 = media.textTracks) == null ? void 0 : _a22.removeEventListener( 39547 "addtrack", 39548 updateDefaultSubtitlesCallback 39549 ); 39550 (_b2 = media.textTracks) == null ? void 0 : _b2.removeEventListener( 39551 "removetrack", 39552 updateDefaultSubtitlesCallback 39553 ); 39554 }; 39555 } 39556 ] 39557 }, 39558 mediaChaptersCues: { 39559 get(stateOwners) { 39560 var _a3; 39561 const { media } = stateOwners; 39562 if (!media) 39563 return []; 39564 const [chaptersTrack] = getTextTracksList(media, { 39565 kind: TextTrackKinds.CHAPTERS 39566 }); 39567 return Array.from((_a3 = chaptersTrack == null ? void 0 : chaptersTrack.cues) != null ? _a3 : []).map( 39568 ({ text, startTime, endTime }) => ({ 39569 text, 39570 startTime, 39571 endTime 39572 }) 39573 ); 39574 }, 39575 mediaEvents: ["loadstart", "loadedmetadata"], 39576 textTracksEvents: ["addtrack", "removetrack", "change"], 39577 stateOwnersUpdateHandlers: [ 39578 (handler, stateOwners) => { 39579 var _a3; 39580 const { media } = stateOwners; 39581 if (!media) 39582 return; 39583 const chaptersTrack = media.querySelector( 39584 'track[kind="chapters"][default][src]' 39585 ); 39586 const shadowChaptersTrack = (_a3 = media.shadowRoot) == null ? void 0 : _a3.querySelector( 39587 ':is(video,audio) > track[kind="chapters"][default][src]' 39588 ); 39589 chaptersTrack == null ? void 0 : chaptersTrack.addEventListener("load", handler); 39590 shadowChaptersTrack == null ? void 0 : shadowChaptersTrack.addEventListener("load", handler); 39591 return () => { 39592 chaptersTrack == null ? void 0 : chaptersTrack.removeEventListener("load", handler); 39593 shadowChaptersTrack == null ? void 0 : shadowChaptersTrack.removeEventListener("load", handler); 39594 }; 39595 } 39596 ] 39597 }, 39598 // Modeling state tied to root node 39599 mediaIsPip: { 39600 get(stateOwners) { 39601 var _a3, _b; 39602 const { media, documentElement } = stateOwners; 39603 if (!media || !documentElement) 39604 return false; 39605 if (!documentElement.pictureInPictureElement) 39606 return false; 39607 if (documentElement.pictureInPictureElement === media) 39608 return true; 39609 if (documentElement.pictureInPictureElement instanceof HTMLMediaElement) { 39610 if (!((_a3 = media.localName) == null ? void 0 : _a3.includes("-"))) 39611 return false; 39612 return containsComposedNode( 39613 media, 39614 documentElement.pictureInPictureElement 39615 ); 39616 } 39617 if (documentElement.pictureInPictureElement.localName.includes("-")) { 39618 let currentRoot = documentElement.pictureInPictureElement.shadowRoot; 39619 while (currentRoot == null ? void 0 : currentRoot.pictureInPictureElement) { 39620 if (currentRoot.pictureInPictureElement === media) 39621 return true; 39622 currentRoot = (_b = currentRoot.pictureInPictureElement) == null ? void 0 : _b.shadowRoot; 39623 } 39624 } 39625 return false; 39626 }, 39627 set(value, stateOwners) { 39628 const { media } = stateOwners; 39629 if (!media) 39630 return; 39631 if (value) { 39632 if (!Document2.pictureInPictureEnabled) { 39633 console.warn("MediaChrome: Picture-in-picture is not enabled"); 39634 return; 39635 } 39636 if (!media.requestPictureInPicture) { 39637 console.warn( 39638 "MediaChrome: The current media does not support picture-in-picture" 39639 ); 39640 return; 39641 } 39642 const warnNotReady = () => { 39643 console.warn( 39644 "MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0." 39645 ); 39646 }; 39647 media.requestPictureInPicture().catch((err) => { 39648 if (err.code === 11) { 39649 if (!media.src) { 39650 console.warn( 39651 "MediaChrome: The media is not ready for picture-in-picture. It must have a src set." 39652 ); 39653 return; 39654 } 39655 if (media.readyState === 0 && media.preload === "none") { 39656 const cleanup = () => { 39657 media.removeEventListener("loadedmetadata", tryPip); 39658 media.preload = "none"; 39659 }; 39660 const tryPip = () => { 39661 media.requestPictureInPicture().catch(warnNotReady); 39662 cleanup(); 39663 }; 39664 media.addEventListener("loadedmetadata", tryPip); 39665 media.preload = "metadata"; 39666 setTimeout(() => { 39667 if (media.readyState === 0) 39668 warnNotReady(); 39669 cleanup(); 39670 }, 1e3); 39671 } else { 39672 throw err; 39673 } 39674 } else { 39675 throw err; 39676 } 39677 }); 39678 } else if (Document2.pictureInPictureElement) { 39679 Document2.exitPictureInPicture(); 39680 } 39681 }, 39682 mediaEvents: ["enterpictureinpicture", "leavepictureinpicture"] 39683 }, 39684 mediaRenditionList: { 39685 get(stateOwners) { 39686 var _a3; 39687 const { media } = stateOwners; 39688 return [...(_a3 = media == null ? void 0 : media.videoRenditions) != null ? _a3 : []].map((videoRendition) => ({ 39689 ...videoRendition 39690 })); 39691 }, 39692 mediaEvents: ["emptied", "loadstart"], 39693 videoRenditionsEvents: ["addrendition", "removerendition"] 39694 }, 39695 /** @TODO Model this as a derived value? (CJP) */ 39696 mediaRenditionSelected: { 39697 get(stateOwners) { 39698 var _a3, _b, _c; 39699 const { media } = stateOwners; 39700 return (_c = (_b = media == null ? void 0 : media.videoRenditions) == null ? void 0 : _b[(_a3 = media.videoRenditions) == null ? void 0 : _a3.selectedIndex]) == null ? void 0 : _c.id; 39701 }, 39702 set(value, stateOwners) { 39703 const { media } = stateOwners; 39704 if (!(media == null ? void 0 : media.videoRenditions)) { 39705 console.warn( 39706 "MediaController: Rendition selection not supported by this media." 39707 ); 39708 return; 39709 } 39710 const renditionId = value; 39711 const index2 = Array.prototype.findIndex.call( 39712 media.videoRenditions, 39713 (r10) => r10.id == renditionId 39714 ); 39715 if (media.videoRenditions.selectedIndex != index2) { 39716 media.videoRenditions.selectedIndex = index2; 39717 } 39718 }, 39719 mediaEvents: ["emptied"], 39720 videoRenditionsEvents: ["addrendition", "removerendition", "change"] 39721 }, 39722 mediaAudioTrackList: { 39723 get(stateOwners) { 39724 var _a3; 39725 const { media } = stateOwners; 39726 return [...(_a3 = media == null ? void 0 : media.audioTracks) != null ? _a3 : []]; 39727 }, 39728 mediaEvents: ["emptied", "loadstart"], 39729 audioTracksEvents: ["addtrack", "removetrack"] 39730 }, 39731 mediaAudioTrackEnabled: { 39732 get(stateOwners) { 39733 var _a3, _b; 39734 const { media } = stateOwners; 39735 return (_b = [...(_a3 = media == null ? void 0 : media.audioTracks) != null ? _a3 : []].find( 39736 (audioTrack) => audioTrack.enabled 39737 )) == null ? void 0 : _b.id; 39738 }, 39739 set(value, stateOwners) { 39740 const { media } = stateOwners; 39741 if (!(media == null ? void 0 : media.audioTracks)) { 39742 console.warn( 39743 "MediaChrome: Audio track selection not supported by this media." 39744 ); 39745 return; 39746 } 39747 const audioTrackId = value; 39748 for (const track of media.audioTracks) { 39749 track.enabled = audioTrackId == track.id; 39750 } 39751 }, 39752 mediaEvents: ["emptied"], 39753 audioTracksEvents: ["addtrack", "removetrack", "change"] 39754 }, 39755 mediaIsFullscreen: { 39756 get(stateOwners) { 39757 return isFullscreen(stateOwners); 39758 }, 39759 set(value, stateOwners) { 39760 if (!value) { 39761 exitFullscreen(stateOwners); 39762 } else { 39763 enterFullscreen(stateOwners); 39764 } 39765 }, 39766 // older Safari version may require webkit-specific events 39767 rootEvents: ["fullscreenchange", "webkitfullscreenchange"], 39768 // iOS requires webkit-specific events on the video. 39769 mediaEvents: ["webkitbeginfullscreen", "webkitendfullscreen", "webkitpresentationmodechanged"] 39770 }, 39771 mediaIsCasting: { 39772 // Note this relies on a customized castable-video element. 39773 get(stateOwners) { 39774 var _a3; 39775 const { media } = stateOwners; 39776 if (!(media == null ? void 0 : media.remote) || ((_a3 = media.remote) == null ? void 0 : _a3.state) === "disconnected") 39777 return false; 39778 return !!media.remote.state; 39779 }, 39780 set(value, stateOwners) { 39781 var _a3, _b; 39782 const { media } = stateOwners; 39783 if (!media) 39784 return; 39785 if (value && ((_a3 = media.remote) == null ? void 0 : _a3.state) !== "disconnected") 39786 return; 39787 if (!value && ((_b = media.remote) == null ? void 0 : _b.state) !== "connected") 39788 return; 39789 if (typeof media.remote.prompt !== "function") { 39790 console.warn( 39791 "MediaChrome: Casting is not supported in this environment" 39792 ); 39793 return; 39794 } 39795 media.remote.prompt().catch(() => { 39796 }); 39797 }, 39798 remoteEvents: ["connect", "connecting", "disconnect"] 39799 }, 39800 // NOTE: Newly added state for tracking airplaying 39801 mediaIsAirplaying: { 39802 // NOTE: Cannot know if airplaying since Safari doesn't fully support HTMLMediaElement::remote yet (e.g. remote::state) (CJP) 39803 get() { 39804 return false; 39805 }, 39806 set(_value2, stateOwners) { 39807 const { media } = stateOwners; 39808 if (!media) 39809 return; 39810 if (!(media.webkitShowPlaybackTargetPicker && GlobalThis.WebKitPlaybackTargetAvailabilityEvent)) { 39811 console.warn( 39812 "MediaChrome: received a request to select AirPlay but AirPlay is not supported in this environment" 39813 ); 39814 return; 39815 } 39816 media.webkitShowPlaybackTargetPicker(); 39817 }, 39818 mediaEvents: ["webkitcurrentplaybacktargetiswirelesschanged"] 39819 }, 39820 mediaFullscreenUnavailable: { 39821 get(stateOwners) { 39822 const { media } = stateOwners; 39823 if (!fullscreenSupported || !hasFullscreenSupport(media)) 39824 return AvailabilityStates.UNSUPPORTED; 39825 return void 0; 39826 } 39827 }, 39828 mediaPipUnavailable: { 39829 get(stateOwners) { 39830 const { media } = stateOwners; 39831 if (!pipSupported || !hasPipSupport(media)) 39832 return AvailabilityStates.UNSUPPORTED; 39833 } 39834 }, 39835 mediaVolumeUnavailable: { 39836 get(stateOwners) { 39837 const { media } = stateOwners; 39838 if (volumeSupported === false || (media == null ? void 0 : media.volume) == void 0) { 39839 return AvailabilityStates.UNSUPPORTED; 39840 } 39841 return void 0; 39842 }, 39843 // NOTE: Slightly different impl here. Added generic support for 39844 // "stateOwnersUpdateHandlers" since the original impl had to hack around 39845 // race conditions. (CJP) 39846 stateOwnersUpdateHandlers: [ 39847 (handler) => { 39848 if (volumeSupported == null) { 39849 volumeSupportPromise.then( 39850 (supported) => handler(supported ? void 0 : AvailabilityStates.UNSUPPORTED) 39851 ); 39852 } 39853 } 39854 ] 39855 }, 39856 mediaCastUnavailable: { 39857 // @ts-ignore 39858 get(stateOwners, { availability = "not-available" } = {}) { 39859 var _a3; 39860 const { media } = stateOwners; 39861 if (!castSupported || !((_a3 = media == null ? void 0 : media.remote) == null ? void 0 : _a3.state)) { 39862 return AvailabilityStates.UNSUPPORTED; 39863 } 39864 if (availability == null || availability === "available") 39865 return void 0; 39866 return AvailabilityStates.UNAVAILABLE; 39867 }, 39868 stateOwnersUpdateHandlers: [ 39869 (handler, stateOwners) => { 39870 var _a3; 39871 const { media } = stateOwners; 39872 if (!media) 39873 return; 39874 const remotePlaybackDisabled = media.disableRemotePlayback || media.hasAttribute("disableremoteplayback"); 39875 if (!remotePlaybackDisabled) { 39876 (_a3 = media == null ? void 0 : media.remote) == null ? void 0 : _a3.watchAvailability((availabilityBool) => { 39877 const availability = availabilityBool ? "available" : "not-available"; 39878 handler({ availability }); 39879 }).catch((error) => { 39880 if (error.name === "NotSupportedError") { 39881 handler({ availability: null }); 39882 } else { 39883 handler({ availability: "not-available" }); 39884 } 39885 }); 39886 } 39887 return () => { 39888 var _a22; 39889 (_a22 = media == null ? void 0 : media.remote) == null ? void 0 : _a22.cancelWatchAvailability().catch(() => { 39890 }); 39891 }; 39892 } 39893 ] 39894 }, 39895 mediaAirplayUnavailable: { 39896 get(_stateOwners, event) { 39897 if (!airplaySupported) 39898 return AvailabilityStates.UNSUPPORTED; 39899 if ((event == null ? void 0 : event.availability) === "not-available") { 39900 return AvailabilityStates.UNAVAILABLE; 39901 } 39902 return void 0; 39903 }, 39904 // NOTE: Keeping this event, as it's still the documented way of monitoring 39905 // for AirPlay availability from Apple. 39906 // See: https://developer.apple.com/documentation/webkitjs/adding_an_airplay_button_to_your_safari_media_controls#2940021 (CJP) 39907 mediaEvents: ["webkitplaybacktargetavailabilitychanged"], 39908 stateOwnersUpdateHandlers: [ 39909 (handler, stateOwners) => { 39910 var _a3; 39911 const { media } = stateOwners; 39912 if (!media) 39913 return; 39914 const remotePlaybackDisabled = media.disableRemotePlayback || media.hasAttribute("disableremoteplayback"); 39915 if (!remotePlaybackDisabled) { 39916 (_a3 = media == null ? void 0 : media.remote) == null ? void 0 : _a3.watchAvailability((availabilityBool) => { 39917 const availability = availabilityBool ? "available" : "not-available"; 39918 handler({ availability }); 39919 }).catch((error) => { 39920 if (error.name === "NotSupportedError") { 39921 handler({ availability: null }); 39922 } else { 39923 handler({ availability: "not-available" }); 39924 } 39925 }); 39926 } 39927 return () => { 39928 var _a22; 39929 (_a22 = media == null ? void 0 : media.remote) == null ? void 0 : _a22.cancelWatchAvailability().catch(() => { 39930 }); 39931 }; 39932 } 39933 ] 39934 }, 39935 mediaRenditionUnavailable: { 39936 get(stateOwners) { 39937 var _a3; 39938 const { media } = stateOwners; 39939 if (!(media == null ? void 0 : media.videoRenditions)) { 39940 return AvailabilityStates.UNSUPPORTED; 39941 } 39942 if (!((_a3 = media.videoRenditions) == null ? void 0 : _a3.length)) { 39943 return AvailabilityStates.UNAVAILABLE; 39944 } 39945 return void 0; 39946 }, 39947 mediaEvents: ["emptied", "loadstart"], 39948 videoRenditionsEvents: ["addrendition", "removerendition"] 39949 }, 39950 mediaAudioTrackUnavailable: { 39951 get(stateOwners) { 39952 var _a3, _b; 39953 const { media } = stateOwners; 39954 if (!(media == null ? void 0 : media.audioTracks)) { 39955 return AvailabilityStates.UNSUPPORTED; 39956 } 39957 if (((_b = (_a3 = media.audioTracks) == null ? void 0 : _a3.length) != null ? _b : 0) <= 1) { 39958 return AvailabilityStates.UNAVAILABLE; 39959 } 39960 return void 0; 39961 }, 39962 mediaEvents: ["emptied", "loadstart"], 39963 audioTracksEvents: ["addtrack", "removetrack"] 39964 } 39965}; 39966
vendor: 7,845 bytes, lines 39967-40156
39967// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-store/request-map.js 39968var requestMap = { 39969 /** 39970 * @TODO Consider adding state to `StateMediator` for e.g. `mediaThumbnailCues` and use that for derived state here (CJP) 39971 */ 39972 [MediaUIEvents.MEDIA_PREVIEW_REQUEST](stateMediator2, stateOwners, { detail }) { 39973 var _a3, _b, _c; 39974 const { media } = stateOwners; 39975 const mediaPreviewTime = detail != null ? detail : void 0; 39976 let mediaPreviewImage = void 0; 39977 let mediaPreviewCoords = void 0; 39978 if (media && mediaPreviewTime != null) { 39979 const [track] = getTextTracksList(media, { 39980 kind: TextTrackKinds.METADATA, 39981 label: "thumbnails" 39982 }); 39983 const cue = Array.prototype.find.call((_a3 = track == null ? void 0 : track.cues) != null ? _a3 : [], (c3, i3, cs) => { 39984 if (i3 === 0) 39985 return c3.endTime > mediaPreviewTime; 39986 if (i3 === cs.length - 1) 39987 return c3.startTime <= mediaPreviewTime; 39988 return c3.startTime <= mediaPreviewTime && c3.endTime > mediaPreviewTime; 39989 }); 39990 if (cue) { 39991 const base = !/'^(?:[a-z]+:)?\/\//i.test(cue.text) ? (_b = media == null ? void 0 : media.querySelector( 39992 'track[label="thumbnails"]' 39993 )) == null ? void 0 : _b.src : void 0; 39994 const url = new URL(cue.text, base); 39995 const previewCoordsStr = new URLSearchParams(url.hash).get("#xywh"); 39996 mediaPreviewCoords = previewCoordsStr.split(",").map((numStr) => +numStr); 39997 mediaPreviewImage = url.href; 39998 } 39999 } 40000 const mediaDuration = stateMediator2.mediaDuration.get(stateOwners); 40001 const mediaChaptersCues = stateMediator2.mediaChaptersCues.get(stateOwners); 40002 let mediaPreviewChapter = (_c = mediaChaptersCues.find((c3, i3, cs) => { 40003 if (i3 === cs.length - 1 && mediaDuration === c3.endTime) { 40004 return c3.startTime <= mediaPreviewTime && c3.endTime >= mediaPreviewTime; 40005 } 40006 return c3.startTime <= mediaPreviewTime && c3.endTime > mediaPreviewTime; 40007 })) == null ? void 0 : _c.text; 40008 if (detail != null && mediaPreviewChapter == null) { 40009 mediaPreviewChapter = ""; 40010 } 40011 return { 40012 mediaPreviewTime, 40013 mediaPreviewImage, 40014 mediaPreviewCoords, 40015 mediaPreviewChapter 40016 }; 40017 }, 40018 [MediaUIEvents.MEDIA_PAUSE_REQUEST](stateMediator2, stateOwners) { 40019 const key = "mediaPaused"; 40020 const value = true; 40021 stateMediator2[key].set(value, stateOwners); 40022 }, 40023 [MediaUIEvents.MEDIA_PLAY_REQUEST](stateMediator2, stateOwners) { 40024 var _a3; 40025 const key = "mediaPaused"; 40026 const value = false; 40027 const live = stateMediator2.mediaStreamType.get(stateOwners) === StreamTypes.LIVE; 40028 if (live) { 40029 const notDvr = !(stateMediator2.mediaTargetLiveWindow.get(stateOwners) > 0); 40030 const liveEdgeTime = (_a3 = stateMediator2.mediaSeekable.get(stateOwners)) == null ? void 0 : _a3[1]; 40031 if (notDvr && liveEdgeTime) { 40032 stateMediator2.mediaCurrentTime.set(liveEdgeTime, stateOwners); 40033 } 40034 } 40035 stateMediator2[key].set(value, stateOwners); 40036 }, 40037 [MediaUIEvents.MEDIA_PLAYBACK_RATE_REQUEST](stateMediator2, stateOwners, { detail }) { 40038 const key = "mediaPlaybackRate"; 40039 const value = detail; 40040 stateMediator2[key].set(value, stateOwners); 40041 }, 40042 [MediaUIEvents.MEDIA_MUTE_REQUEST](stateMediator2, stateOwners) { 40043 const key = "mediaMuted"; 40044 const value = true; 40045 stateMediator2[key].set(value, stateOwners); 40046 }, 40047 [MediaUIEvents.MEDIA_UNMUTE_REQUEST](stateMediator2, stateOwners) { 40048 const key = "mediaMuted"; 40049 const value = false; 40050 if (!stateMediator2.mediaVolume.get(stateOwners)) { 40051 stateMediator2.mediaVolume.set(0.25, stateOwners); 40052 } 40053 stateMediator2[key].set(value, stateOwners); 40054 }, 40055 [MediaUIEvents.MEDIA_VOLUME_REQUEST](stateMediator2, stateOwners, { detail }) { 40056 const key = "mediaVolume"; 40057 const value = detail; 40058 if (value && stateMediator2.mediaMuted.get(stateOwners)) { 40059 stateMediator2.mediaMuted.set(false, stateOwners); 40060 } 40061 stateMediator2[key].set(value, stateOwners); 40062 }, 40063 [MediaUIEvents.MEDIA_SEEK_REQUEST](stateMediator2, stateOwners, { detail }) { 40064 const key = "mediaCurrentTime"; 40065 const value = detail; 40066 stateMediator2[key].set(value, stateOwners); 40067 }, 40068 [MediaUIEvents.MEDIA_SEEK_TO_LIVE_REQUEST](stateMediator2, stateOwners) { 40069 var _a3; 40070 const key = "mediaCurrentTime"; 40071 const value = (_a3 = stateMediator2.mediaSeekable.get(stateOwners)) == null ? void 0 : _a3[1]; 40072 if (Number.isNaN(Number(value))) 40073 return; 40074 stateMediator2[key].set(value, stateOwners); 40075 }, 40076 // Text Tracks state change requests 40077 [MediaUIEvents.MEDIA_SHOW_SUBTITLES_REQUEST](_stateMediator, stateOwners, { detail }) { 40078 var _a3; 40079 const { options: options2 } = stateOwners; 40080 const tracks = getSubtitleTracks(stateOwners); 40081 const tracksToUpdate = parseTracks(detail); 40082 const preferredLanguage = (_a3 = tracksToUpdate[0]) == null ? void 0 : _a3.language; 40083 if (preferredLanguage && !options2.noSubtitlesLangPref) { 40084 GlobalThis.localStorage.setItem( 40085 "media-chrome-pref-subtitles-lang", 40086 preferredLanguage 40087 ); 40088 } 40089 updateTracksModeTo(TextTrackModes.SHOWING, tracks, tracksToUpdate); 40090 }, 40091 [MediaUIEvents.MEDIA_DISABLE_SUBTITLES_REQUEST](_stateMediator, stateOwners, { detail }) { 40092 const tracks = getSubtitleTracks(stateOwners); 40093 const tracksToUpdate = detail != null ? detail : []; 40094 updateTracksModeTo(TextTrackModes.DISABLED, tracks, tracksToUpdate); 40095 }, 40096 [MediaUIEvents.MEDIA_TOGGLE_SUBTITLES_REQUEST](_stateMediator, stateOwners, { detail }) { 40097 toggleSubtitleTracks(stateOwners, detail); 40098 }, 40099 // Renditions/Tracks state change requests 40100 [MediaUIEvents.MEDIA_RENDITION_REQUEST](stateMediator2, stateOwners, { detail }) { 40101 const key = "mediaRenditionSelected"; 40102 const value = detail; 40103 stateMediator2[key].set(value, stateOwners); 40104 }, 40105 [MediaUIEvents.MEDIA_AUDIO_TRACK_REQUEST](stateMediator2, stateOwners, { detail }) { 40106 const key = "mediaAudioTrackEnabled"; 40107 const value = detail; 40108 stateMediator2[key].set(value, stateOwners); 40109 }, 40110 // State change requests dependent on root node 40111 [MediaUIEvents.MEDIA_ENTER_PIP_REQUEST](stateMediator2, stateOwners) { 40112 const key = "mediaIsPip"; 40113 const value = true; 40114 if (stateMediator2.mediaIsFullscreen.get(stateOwners)) { 40115 stateMediator2.mediaIsFullscreen.set(false, stateOwners); 40116 } 40117 stateMediator2[key].set(value, stateOwners); 40118 }, 40119 [MediaUIEvents.MEDIA_EXIT_PIP_REQUEST](stateMediator2, stateOwners) { 40120 const key = "mediaIsPip"; 40121 const value = false; 40122 stateMediator2[key].set(value, stateOwners); 40123 }, 40124 [MediaUIEvents.MEDIA_ENTER_FULLSCREEN_REQUEST](stateMediator2, stateOwners) { 40125 const key = "mediaIsFullscreen"; 40126 const value = true; 40127 if (stateMediator2.mediaIsPip.get(stateOwners)) { 40128 stateMediator2.mediaIsPip.set(false, stateOwners); 40129 } 40130 stateMediator2[key].set(value, stateOwners); 40131 }, 40132 [MediaUIEvents.MEDIA_EXIT_FULLSCREEN_REQUEST](stateMediator2, stateOwners) { 40133 const key = "mediaIsFullscreen"; 40134 const value = false; 40135 stateMediator2[key].set(value, stateOwners); 40136 }, 40137 [MediaUIEvents.MEDIA_ENTER_CAST_REQUEST](stateMediator2, stateOwners) { 40138 const key = "mediaIsCasting"; 40139 const value = true; 40140 if (stateMediator2.mediaIsFullscreen.get(stateOwners)) { 40141 stateMediator2.mediaIsFullscreen.set(false, stateOwners); 40142 } 40143 stateMediator2[key].set(value, stateOwners); 40144 }, 40145 [MediaUIEvents.MEDIA_EXIT_CAST_REQUEST](stateMediator2, stateOwners) { 40146 const key = "mediaIsCasting"; 40147 const value = false; 40148 stateMediator2[key].set(value, stateOwners); 40149 }, 40150 [MediaUIEvents.MEDIA_AIRPLAY_REQUEST](stateMediator2, stateOwners) { 40151 const key = "mediaIsAirplaying"; 40152 const value = true; 40153 stateMediator2[key].set(value, stateOwners); 40154 } 40155}; 40156
vendor: 12,179 bytes, lines 40157-40429
40157// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-store/media-store.js 40158var createMediaStore = ({ 40159 media, 40160 fullscreenElement, 40161 documentElement, 40162 stateMediator: stateMediator2 = stateMediator, 40163 requestMap: requestMap2 = requestMap, 40164 options: options2 = {}, 40165 monitorStateOwnersOnlyWithSubscriptions = true 40166}) => { 40167 const callbacks = []; 40168 const stateOwners = { 40169 // Spreading options here since folks should not rely on holding onto references 40170 // for any app-level logic wrt options. 40171 options: { ...options2 } 40172 }; 40173 let state = Object.freeze({ 40174 mediaPreviewTime: void 0, 40175 mediaPreviewImage: void 0, 40176 mediaPreviewCoords: void 0, 40177 mediaPreviewChapter: void 0 40178 }); 40179 const updateState = (nextStateDelta) => { 40180 if (nextStateDelta == void 0) 40181 return; 40182 if (areValuesEq(nextStateDelta, state)) { 40183 return; 40184 } 40185 state = Object.freeze({ 40186 ...state, 40187 ...nextStateDelta 40188 }); 40189 callbacks.forEach((cb) => cb(state)); 40190 }; 40191 const updateStateFromFacade = () => { 40192 const nextState = Object.entries(stateMediator2).reduce( 40193 (nextState2, [stateName, { get }]) => { 40194 nextState2[stateName] = get(stateOwners); 40195 return nextState2; 40196 }, 40197 {} 40198 ); 40199 updateState(nextState); 40200 }; 40201 const stateUpdateHandlers = {}; 40202 let nextStateOwners = void 0; 40203 const updateStateOwners = async (nextStateOwnersDelta, nextSubscriberCount) => { 40204 var _a3, _b, _c, _d, _e5, _f, _g, _h, _i2, _j, _k, _l, _m, _n, _o, _p; 40205 const pendingUpdate = !!nextStateOwners; 40206 nextStateOwners = { 40207 ...stateOwners, 40208 ...nextStateOwners != null ? nextStateOwners : {}, 40209 ...nextStateOwnersDelta 40210 }; 40211 if (pendingUpdate) 40212 return; 40213 await prepareStateOwners(...Object.values(nextStateOwnersDelta)); 40214 const shouldTeardownFromSubscriberCount = callbacks.length > 0 && nextSubscriberCount === 0 && monitorStateOwnersOnlyWithSubscriptions; 40215 const mediaChanged = stateOwners.media !== nextStateOwners.media; 40216 const textTracksChanged = ((_a3 = stateOwners.media) == null ? void 0 : _a3.textTracks) !== ((_b = nextStateOwners.media) == null ? void 0 : _b.textTracks); 40217 const videoRenditionsChanged = ((_c = stateOwners.media) == null ? void 0 : _c.videoRenditions) !== ((_d = nextStateOwners.media) == null ? void 0 : _d.videoRenditions); 40218 const audioTracksChanged = ((_e5 = stateOwners.media) == null ? void 0 : _e5.audioTracks) !== ((_f = nextStateOwners.media) == null ? void 0 : _f.audioTracks); 40219 const remoteChanged = ((_g = stateOwners.media) == null ? void 0 : _g.remote) !== ((_h = nextStateOwners.media) == null ? void 0 : _h.remote); 40220 const rootNodeChanged = stateOwners.documentElement !== nextStateOwners.documentElement; 40221 const teardownMedia = !!stateOwners.media && (mediaChanged || shouldTeardownFromSubscriberCount); 40222 const teardownTextTracks = !!((_i2 = stateOwners.media) == null ? void 0 : _i2.textTracks) && (textTracksChanged || shouldTeardownFromSubscriberCount); 40223 const teardownVideoRenditions = !!((_j = stateOwners.media) == null ? void 0 : _j.videoRenditions) && (videoRenditionsChanged || shouldTeardownFromSubscriberCount); 40224 const teardownAudioTracks = !!((_k = stateOwners.media) == null ? void 0 : _k.audioTracks) && (audioTracksChanged || shouldTeardownFromSubscriberCount); 40225 const teardownRemote = !!((_l = stateOwners.media) == null ? void 0 : _l.remote) && (remoteChanged || shouldTeardownFromSubscriberCount); 40226 const teardownRootNode = !!stateOwners.documentElement && (rootNodeChanged || shouldTeardownFromSubscriberCount); 40227 const teardownSomething = teardownMedia || teardownTextTracks || teardownVideoRenditions || teardownAudioTracks || teardownRemote || teardownRootNode; 40228 const shouldSetupFromSubscriberCount = callbacks.length === 0 && nextSubscriberCount === 1 && monitorStateOwnersOnlyWithSubscriptions; 40229 const setupMedia = !!nextStateOwners.media && (mediaChanged || shouldSetupFromSubscriberCount); 40230 const setupTextTracks = !!((_m = nextStateOwners.media) == null ? void 0 : _m.textTracks) && (textTracksChanged || shouldSetupFromSubscriberCount); 40231 const setupVideoRenditions = !!((_n = nextStateOwners.media) == null ? void 0 : _n.videoRenditions) && (videoRenditionsChanged || shouldSetupFromSubscriberCount); 40232 const setupAudioTracks = !!((_o = nextStateOwners.media) == null ? void 0 : _o.audioTracks) && (audioTracksChanged || shouldSetupFromSubscriberCount); 40233 const setupRemote = !!((_p = nextStateOwners.media) == null ? void 0 : _p.remote) && (remoteChanged || shouldSetupFromSubscriberCount); 40234 const setupRootNode = !!nextStateOwners.documentElement && (rootNodeChanged || shouldSetupFromSubscriberCount); 40235 const setupSomething = setupMedia || setupTextTracks || setupVideoRenditions || setupAudioTracks || setupRemote || setupRootNode; 40236 const somethingToDo = teardownSomething || setupSomething; 40237 if (!somethingToDo) { 40238 Object.entries(nextStateOwners).forEach( 40239 ([stateOwnerName, stateOwner]) => { 40240 stateOwners[stateOwnerName] = stateOwner; 40241 } 40242 ); 40243 updateStateFromFacade(); 40244 nextStateOwners = void 0; 40245 return; 40246 } 40247 Object.entries(stateMediator2).forEach( 40248 ([ 40249 stateName, 40250 { 40251 get, 40252 mediaEvents = [], 40253 textTracksEvents = [], 40254 videoRenditionsEvents = [], 40255 audioTracksEvents = [], 40256 remoteEvents = [], 40257 rootEvents = [], 40258 stateOwnersUpdateHandlers = [] 40259 } 40260 ]) => { 40261 if (!stateUpdateHandlers[stateName]) { 40262 stateUpdateHandlers[stateName] = {}; 40263 } 40264 const handler = (event) => { 40265 const nextValue = get(stateOwners, event); 40266 updateState({ [stateName]: nextValue }); 40267 }; 40268 let prevHandler; 40269 prevHandler = stateUpdateHandlers[stateName].mediaEvents; 40270 mediaEvents.forEach((eventType) => { 40271 if (prevHandler && teardownMedia) { 40272 stateOwners.media.removeEventListener(eventType, prevHandler); 40273 stateUpdateHandlers[stateName].mediaEvents = void 0; 40274 } 40275 if (setupMedia) { 40276 nextStateOwners.media.addEventListener(eventType, handler); 40277 stateUpdateHandlers[stateName].mediaEvents = handler; 40278 } 40279 }); 40280 prevHandler = stateUpdateHandlers[stateName].textTracksEvents; 40281 textTracksEvents.forEach((eventType) => { 40282 var _a22, _b2; 40283 if (prevHandler && teardownTextTracks) { 40284 (_a22 = stateOwners.media.textTracks) == null ? void 0 : _a22.removeEventListener( 40285 eventType, 40286 prevHandler 40287 ); 40288 stateUpdateHandlers[stateName].textTracksEvents = void 0; 40289 } 40290 if (setupTextTracks) { 40291 (_b2 = nextStateOwners.media.textTracks) == null ? void 0 : _b2.addEventListener( 40292 eventType, 40293 handler 40294 ); 40295 stateUpdateHandlers[stateName].textTracksEvents = handler; 40296 } 40297 }); 40298 prevHandler = stateUpdateHandlers[stateName].videoRenditionsEvents; 40299 videoRenditionsEvents.forEach((eventType) => { 40300 var _a22, _b2; 40301 if (prevHandler && teardownVideoRenditions) { 40302 (_a22 = stateOwners.media.videoRenditions) == null ? void 0 : _a22.removeEventListener( 40303 eventType, 40304 prevHandler 40305 ); 40306 stateUpdateHandlers[stateName].videoRenditionsEvents = void 0; 40307 } 40308 if (setupVideoRenditions) { 40309 (_b2 = nextStateOwners.media.videoRenditions) == null ? void 0 : _b2.addEventListener( 40310 eventType, 40311 handler 40312 ); 40313 stateUpdateHandlers[stateName].videoRenditionsEvents = handler; 40314 } 40315 }); 40316 prevHandler = stateUpdateHandlers[stateName].audioTracksEvents; 40317 audioTracksEvents.forEach((eventType) => { 40318 var _a22, _b2; 40319 if (prevHandler && teardownAudioTracks) { 40320 (_a22 = stateOwners.media.audioTracks) == null ? void 0 : _a22.removeEventListener( 40321 eventType, 40322 prevHandler 40323 ); 40324 stateUpdateHandlers[stateName].audioTracksEvents = void 0; 40325 } 40326 if (setupAudioTracks) { 40327 (_b2 = nextStateOwners.media.audioTracks) == null ? void 0 : _b2.addEventListener( 40328 eventType, 40329 handler 40330 ); 40331 stateUpdateHandlers[stateName].audioTracksEvents = handler; 40332 } 40333 }); 40334 prevHandler = stateUpdateHandlers[stateName].remoteEvents; 40335 remoteEvents.forEach((eventType) => { 40336 var _a22, _b2; 40337 if (prevHandler && teardownRemote) { 40338 (_a22 = stateOwners.media.remote) == null ? void 0 : _a22.removeEventListener( 40339 eventType, 40340 prevHandler 40341 ); 40342 stateUpdateHandlers[stateName].remoteEvents = void 0; 40343 } 40344 if (setupRemote) { 40345 (_b2 = nextStateOwners.media.remote) == null ? void 0 : _b2.addEventListener(eventType, handler); 40346 stateUpdateHandlers[stateName].remoteEvents = handler; 40347 } 40348 }); 40349 prevHandler = stateUpdateHandlers[stateName].rootEvents; 40350 rootEvents.forEach((eventType) => { 40351 if (prevHandler && teardownRootNode) { 40352 stateOwners.documentElement.removeEventListener( 40353 eventType, 40354 prevHandler 40355 ); 40356 stateUpdateHandlers[stateName].rootEvents = void 0; 40357 } 40358 if (setupRootNode) { 40359 nextStateOwners.documentElement.addEventListener( 40360 eventType, 40361 handler 40362 ); 40363 stateUpdateHandlers[stateName].rootEvents = handler; 40364 } 40365 }); 40366 const prevHandlerTeardown = stateUpdateHandlers[stateName].stateOwnersUpdateHandlers; 40367 stateOwnersUpdateHandlers.forEach((fn) => { 40368 if (prevHandlerTeardown && teardownSomething) { 40369 prevHandlerTeardown(); 40370 } 40371 if (setupSomething) { 40372 stateUpdateHandlers[stateName].stateOwnersUpdateHandlers = fn( 40373 handler, 40374 nextStateOwners 40375 ); 40376 } 40377 }); 40378 } 40379 ); 40380 Object.entries(nextStateOwners).forEach(([stateOwnerName, stateOwner]) => { 40381 stateOwners[stateOwnerName] = stateOwner; 40382 }); 40383 updateStateFromFacade(); 40384 nextStateOwners = void 0; 40385 }; 40386 updateStateOwners({ media, fullscreenElement, documentElement, options: options2 }); 40387 return { 40388 // note that none of these cases directly interact with the media element, root node, full screen element, etc. 40389 // note these "actions" could just be the events if we wanted, especially if we normalize on "detail" for 40390 // any payload-relevant values 40391 // This is roughly equivalent to our used to be in our state requests dictionary object, though much of the 40392 // "heavy lifting" is now moved into the facade `set()` 40393 dispatch(action) { 40394 const { type, detail } = action; 40395 if (requestMap2[type]) { 40396 updateState(requestMap2[type](stateMediator2, stateOwners, action)); 40397 return; 40398 } 40399 if (type === "mediaelementchangerequest") { 40400 updateStateOwners({ media: detail }); 40401 } else if (type === "fullscreenelementchangerequest") { 40402 updateStateOwners({ fullscreenElement: detail }); 40403 } else if (type === "documentelementchangerequest") { 40404 updateStateOwners({ documentElement: detail }); 40405 } else if (type === "optionschangerequest") { 40406 Object.entries(detail != null ? detail : {}).forEach(([optionName, optionValue]) => { 40407 stateOwners.options[optionName] = optionValue; 40408 }); 40409 } 40410 }, 40411 getState() { 40412 return state; 40413 }, 40414 subscribe(callback) { 40415 updateStateOwners({}, callbacks.length + 1); 40416 callbacks.push(callback); 40417 callback(state); 40418 return () => { 40419 const idx = callbacks.indexOf(callback); 40420 if (idx >= 0) { 40421 updateStateOwners({}, callbacks.length - 1); 40422 callbacks.splice(idx, 1); 40423 } 40424 }; 40425 } 40426 }; 40427}; 40428var media_store_default = createMediaStore; 40429
vendor: 24,689 bytes, lines 40430-41085
40430// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-controller.js 40431var __accessCheck4 = (obj, member, msg) => { 40432 if (!member.has(obj)) 40433 throw TypeError("Cannot " + msg); 40434}; 40435var __privateGet4 = (obj, member, getter) => { 40436 __accessCheck4(obj, member, "read from private field"); 40437 return getter ? getter.call(obj) : member.get(obj); 40438}; 40439var __privateAdd4 = (obj, member, value) => { 40440 if (member.has(obj)) 40441 throw TypeError("Cannot add the same private member more than once"); 40442 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 40443}; 40444var __privateSet4 = (obj, member, value, setter) => { 40445 __accessCheck4(obj, member, "write to private field"); 40446 setter ? setter.call(obj, value) : member.set(obj, value); 40447 return value; 40448}; 40449var __privateMethod2 = (obj, member, method) => { 40450 __accessCheck4(obj, member, "access private method"); 40451 return method; 40452}; 40453var _hotKeys; 40454var _fullscreenElement; 40455var _mediaStore; 40456var _mediaStateCallback; 40457var _mediaStoreUnsubscribe; 40458var _mediaStateEventHandler; 40459var _setupDefaultStore; 40460var setupDefaultStore_fn; 40461var _keyUpHandler; 40462var keyUpHandler_fn; 40463var _keyDownHandler; 40464var keyDownHandler_fn; 40465var ButtonPressedKeys = [ 40466 "ArrowLeft", 40467 "ArrowRight", 40468 "Enter", 40469 " ", 40470 "f", 40471 "m", 40472 "k", 40473 "c" 40474]; 40475var DEFAULT_SEEK_OFFSET = 10; 40476var Attributes2 = { 40477 DEFAULT_SUBTITLES: "defaultsubtitles", 40478 DEFAULT_STREAM_TYPE: "defaultstreamtype", 40479 DEFAULT_DURATION: "defaultduration", 40480 FULLSCREEN_ELEMENT: "fullscreenelement", 40481 HOTKEYS: "hotkeys", 40482 KEYS_USED: "keysused", 40483 LIVE_EDGE_OFFSET: "liveedgeoffset", 40484 NO_AUTO_SEEK_TO_LIVE: "noautoseektolive", 40485 NO_HOTKEYS: "nohotkeys", 40486 NO_VOLUME_PREF: "novolumepref", 40487 NO_SUBTITLES_LANG_PREF: "nosubtitleslangpref", 40488 NO_DEFAULT_STORE: "nodefaultstore", 40489 KEYBOARD_FORWARD_SEEK_OFFSET: "keyboardforwardseekoffset", 40490 KEYBOARD_BACKWARD_SEEK_OFFSET: "keyboardbackwardseekoffset" 40491}; 40492var MediaController = class extends MediaContainer { 40493 constructor() { 40494 super(); 40495 __privateAdd4(this, _setupDefaultStore); 40496 __privateAdd4(this, _keyUpHandler); 40497 __privateAdd4(this, _keyDownHandler); 40498 this.mediaStateReceivers = []; 40499 this.associatedElementSubscriptions = /* @__PURE__ */ new Map(); 40500 __privateAdd4(this, _hotKeys, new AttributeTokenList(this, Attributes2.HOTKEYS)); 40501 __privateAdd4(this, _fullscreenElement, void 0); 40502 __privateAdd4(this, _mediaStore, void 0); 40503 __privateAdd4(this, _mediaStateCallback, void 0); 40504 __privateAdd4(this, _mediaStoreUnsubscribe, void 0); 40505 __privateAdd4(this, _mediaStateEventHandler, (event) => { 40506 var _a3; 40507 (_a3 = __privateGet4(this, _mediaStore)) == null ? void 0 : _a3.dispatch(event); 40508 }); 40509 this.associateElement(this); 40510 let prevState = {}; 40511 __privateSet4(this, _mediaStateCallback, (nextState) => { 40512 Object.entries(nextState).forEach(([stateName, stateValue]) => { 40513 if (stateName in prevState && prevState[stateName] === stateValue) 40514 return; 40515 this.propagateMediaState(stateName, stateValue); 40516 const attrName = stateName.toLowerCase(); 40517 const evt = new GlobalThis.CustomEvent( 40518 AttributeToStateChangeEventMap[attrName], 40519 { composed: true, detail: stateValue } 40520 ); 40521 this.dispatchEvent(evt); 40522 }); 40523 prevState = nextState; 40524 }); 40525 this.enableHotkeys(); 40526 } 40527 static get observedAttributes() { 40528 return super.observedAttributes.concat( 40529 Attributes2.NO_HOTKEYS, 40530 Attributes2.HOTKEYS, 40531 Attributes2.DEFAULT_STREAM_TYPE, 40532 Attributes2.DEFAULT_SUBTITLES, 40533 Attributes2.DEFAULT_DURATION 40534 ); 40535 } 40536 get mediaStore() { 40537 return __privateGet4(this, _mediaStore); 40538 } 40539 set mediaStore(value) { 40540 var _a3, _b; 40541 if (__privateGet4(this, _mediaStore)) { 40542 (_a3 = __privateGet4(this, _mediaStoreUnsubscribe)) == null ? void 0 : _a3.call(this); 40543 __privateSet4(this, _mediaStoreUnsubscribe, void 0); 40544 } 40545 __privateSet4(this, _mediaStore, value); 40546 if (!__privateGet4(this, _mediaStore) && !this.hasAttribute(Attributes2.NO_DEFAULT_STORE)) { 40547 __privateMethod2(this, _setupDefaultStore, setupDefaultStore_fn).call(this); 40548 return; 40549 } 40550 __privateSet4(this, _mediaStoreUnsubscribe, (_b = __privateGet4(this, _mediaStore)) == null ? void 0 : _b.subscribe( 40551 __privateGet4(this, _mediaStateCallback) 40552 )); 40553 } 40554 get fullscreenElement() { 40555 var _a3; 40556 return (_a3 = __privateGet4(this, _fullscreenElement)) != null ? _a3 : this; 40557 } 40558 set fullscreenElement(element) { 40559 var _a3; 40560 if (this.hasAttribute(Attributes2.FULLSCREEN_ELEMENT)) { 40561 this.removeAttribute(Attributes2.FULLSCREEN_ELEMENT); 40562 } 40563 __privateSet4(this, _fullscreenElement, element); 40564 (_a3 = __privateGet4(this, _mediaStore)) == null ? void 0 : _a3.dispatch({ 40565 type: "fullscreenelementchangerequest", 40566 detail: this.fullscreenElement 40567 }); 40568 } 40569 attributeChangedCallback(attrName, oldValue, newValue) { 40570 var _a3, _b, _c, _d, _e5, _f; 40571 super.attributeChangedCallback(attrName, oldValue, newValue); 40572 if (attrName === Attributes2.NO_HOTKEYS) { 40573 if (newValue !== oldValue && newValue === "") { 40574 if (this.hasAttribute(Attributes2.HOTKEYS)) { 40575 console.warn( 40576 "Media Chrome: Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled." 40577 ); 40578 } 40579 this.disableHotkeys(); 40580 } else if (newValue !== oldValue && newValue === null) { 40581 this.enableHotkeys(); 40582 } 40583 } else if (attrName === Attributes2.HOTKEYS) { 40584 __privateGet4(this, _hotKeys).value = newValue; 40585 } else if (attrName === Attributes2.DEFAULT_SUBTITLES && newValue !== oldValue) { 40586 (_a3 = __privateGet4(this, _mediaStore)) == null ? void 0 : _a3.dispatch({ 40587 type: "optionschangerequest", 40588 detail: { 40589 defaultSubtitles: this.hasAttribute(Attributes2.DEFAULT_SUBTITLES) 40590 } 40591 }); 40592 } else if (attrName === Attributes2.DEFAULT_STREAM_TYPE) { 40593 (_c = __privateGet4(this, _mediaStore)) == null ? void 0 : _c.dispatch({ 40594 type: "optionschangerequest", 40595 detail: { 40596 defaultStreamType: (_b = this.getAttribute(Attributes2.DEFAULT_STREAM_TYPE)) != null ? _b : void 0 40597 } 40598 }); 40599 } else if (attrName === Attributes2.LIVE_EDGE_OFFSET) { 40600 (_d = __privateGet4(this, _mediaStore)) == null ? void 0 : _d.dispatch({ 40601 type: "optionschangerequest", 40602 detail: { 40603 liveEdgeOffset: this.hasAttribute(Attributes2.LIVE_EDGE_OFFSET) ? +this.getAttribute(Attributes2.LIVE_EDGE_OFFSET) : void 0 40604 } 40605 }); 40606 } else if (attrName === Attributes2.FULLSCREEN_ELEMENT) { 40607 const el = newValue ? (_e5 = this.getRootNode()) == null ? void 0 : _e5.getElementById(newValue) : void 0; 40608 __privateSet4(this, _fullscreenElement, el); 40609 (_f = __privateGet4(this, _mediaStore)) == null ? void 0 : _f.dispatch({ 40610 type: "fullscreenelementchangerequest", 40611 detail: this.fullscreenElement 40612 }); 40613 } 40614 } 40615 connectedCallback() { 40616 var _a3, _b; 40617 if (!__privateGet4(this, _mediaStore) && !this.hasAttribute(Attributes2.NO_DEFAULT_STORE)) { 40618 __privateMethod2(this, _setupDefaultStore, setupDefaultStore_fn).call(this); 40619 } 40620 (_a3 = __privateGet4(this, _mediaStore)) == null ? void 0 : _a3.dispatch({ 40621 type: "documentelementchangerequest", 40622 detail: Document2 40623 }); 40624 super.connectedCallback(); 40625 if (__privateGet4(this, _mediaStore) && !__privateGet4(this, _mediaStoreUnsubscribe)) { 40626 __privateSet4(this, _mediaStoreUnsubscribe, (_b = __privateGet4(this, _mediaStore)) == null ? void 0 : _b.subscribe( 40627 __privateGet4(this, _mediaStateCallback) 40628 )); 40629 } 40630 this.enableHotkeys(); 40631 } 40632 disconnectedCallback() { 40633 var _a3, _b, _c, _d; 40634 (_a3 = super.disconnectedCallback) == null ? void 0 : _a3.call(this); 40635 if (__privateGet4(this, _mediaStore)) { 40636 (_b = __privateGet4(this, _mediaStore)) == null ? void 0 : _b.dispatch({ 40637 type: "documentelementchangerequest", 40638 detail: void 0 40639 }); 40640 (_c = __privateGet4(this, _mediaStore)) == null ? void 0 : _c.dispatch({ 40641 type: MediaUIEvents.MEDIA_TOGGLE_SUBTITLES_REQUEST, 40642 detail: false 40643 }); 40644 } 40645 if (__privateGet4(this, _mediaStoreUnsubscribe)) { 40646 (_d = __privateGet4(this, _mediaStoreUnsubscribe)) == null ? void 0 : _d.call(this); 40647 __privateSet4(this, _mediaStoreUnsubscribe, void 0); 40648 } 40649 } 40650 /** 40651 * @override 40652 * @param {HTMLMediaElement} media 40653 */ 40654 mediaSetCallback(media) { 40655 var _a3; 40656 super.mediaSetCallback(media); 40657 (_a3 = __privateGet4(this, _mediaStore)) == null ? void 0 : _a3.dispatch({ 40658 type: "mediaelementchangerequest", 40659 detail: media 40660 }); 40661 if (!media.hasAttribute("tabindex")) { 40662 media.tabIndex = -1; 40663 } 40664 } 40665 /** 40666 * @override 40667 * @param {HTMLMediaElement} media 40668 */ 40669 mediaUnsetCallback(media) { 40670 var _a3; 40671 super.mediaUnsetCallback(media); 40672 (_a3 = __privateGet4(this, _mediaStore)) == null ? void 0 : _a3.dispatch({ 40673 type: "mediaelementchangerequest", 40674 detail: void 0 40675 }); 40676 } 40677 propagateMediaState(stateName, state) { 40678 propagateMediaState(this.mediaStateReceivers, stateName, state); 40679 } 40680 associateElement(element) { 40681 if (!element) 40682 return; 40683 const { associatedElementSubscriptions } = this; 40684 if (associatedElementSubscriptions.has(element)) 40685 return; 40686 const registerMediaStateReceiver = this.registerMediaStateReceiver.bind(this); 40687 const unregisterMediaStateReceiver = this.unregisterMediaStateReceiver.bind(this); 40688 const unsubscribe = monitorForMediaStateReceivers( 40689 element, 40690 registerMediaStateReceiver, 40691 unregisterMediaStateReceiver 40692 ); 40693 Object.values(MediaUIEvents).forEach((eventName) => { 40694 element.addEventListener(eventName, __privateGet4(this, _mediaStateEventHandler)); 40695 }); 40696 associatedElementSubscriptions.set(element, unsubscribe); 40697 } 40698 unassociateElement(element) { 40699 if (!element) 40700 return; 40701 const { associatedElementSubscriptions } = this; 40702 if (!associatedElementSubscriptions.has(element)) 40703 return; 40704 const unsubscribe = associatedElementSubscriptions.get(element); 40705 unsubscribe(); 40706 associatedElementSubscriptions.delete(element); 40707 Object.values(MediaUIEvents).forEach((eventName) => { 40708 element.removeEventListener(eventName, __privateGet4(this, _mediaStateEventHandler)); 40709 }); 40710 } 40711 registerMediaStateReceiver(el) { 40712 if (!el) 40713 return; 40714 const els = this.mediaStateReceivers; 40715 const index2 = els.indexOf(el); 40716 if (index2 > -1) 40717 return; 40718 els.push(el); 40719 if (__privateGet4(this, _mediaStore)) { 40720 Object.entries(__privateGet4(this, _mediaStore).getState()).forEach( 40721 ([stateName, stateValue]) => { 40722 propagateMediaState([el], stateName, stateValue); 40723 } 40724 ); 40725 } 40726 } 40727 unregisterMediaStateReceiver(el) { 40728 const els = this.mediaStateReceivers; 40729 const index2 = els.indexOf(el); 40730 if (index2 < 0) 40731 return; 40732 els.splice(index2, 1); 40733 } 40734 enableHotkeys() { 40735 this.addEventListener("keydown", __privateMethod2(this, _keyDownHandler, keyDownHandler_fn)); 40736 } 40737 disableHotkeys() { 40738 this.removeEventListener("keydown", __privateMethod2(this, _keyDownHandler, keyDownHandler_fn)); 40739 this.removeEventListener("keyup", __privateMethod2(this, _keyUpHandler, keyUpHandler_fn)); 40740 } 40741 get hotkeys() { 40742 return __privateGet4(this, _hotKeys); 40743 } 40744 keyboardShortcutHandler(e) { 40745 var _a3, _b, _c, _d, _e5; 40746 const target = e.target; 40747 const keysUsed = ((_c = (_b = (_a3 = target.getAttribute(Attributes2.KEYS_USED)) == null ? void 0 : _a3.split(" ")) != null ? _b : target == null ? void 0 : target.keysUsed) != null ? _c : []).map((key) => key === "Space" ? " " : key).filter(Boolean); 40748 if (keysUsed.includes(e.key)) { 40749 return; 40750 } 40751 let eventName, detail, evt; 40752 if (__privateGet4(this, _hotKeys).contains(`no${e.key.toLowerCase()}`)) 40753 return; 40754 if (e.key === " " && __privateGet4(this, _hotKeys).contains(`nospace`)) 40755 return; 40756 switch (e.key) { 40757 case " ": 40758 case "k": 40759 eventName = __privateGet4(this, _mediaStore).getState().mediaPaused ? MediaUIEvents.MEDIA_PLAY_REQUEST : MediaUIEvents.MEDIA_PAUSE_REQUEST; 40760 this.dispatchEvent( 40761 new GlobalThis.CustomEvent(eventName, { 40762 composed: true, 40763 bubbles: true 40764 }) 40765 ); 40766 break; 40767 case "m": 40768 eventName = this.mediaStore.getState().mediaVolumeLevel === "off" ? MediaUIEvents.MEDIA_UNMUTE_REQUEST : MediaUIEvents.MEDIA_MUTE_REQUEST; 40769 this.dispatchEvent( 40770 new GlobalThis.CustomEvent(eventName, { 40771 composed: true, 40772 bubbles: true 40773 }) 40774 ); 40775 break; 40776 case "f": 40777 eventName = this.mediaStore.getState().mediaIsFullscreen ? MediaUIEvents.MEDIA_EXIT_FULLSCREEN_REQUEST : MediaUIEvents.MEDIA_ENTER_FULLSCREEN_REQUEST; 40778 this.dispatchEvent( 40779 new GlobalThis.CustomEvent(eventName, { 40780 composed: true, 40781 bubbles: true 40782 }) 40783 ); 40784 break; 40785 case "c": 40786 this.dispatchEvent( 40787 new GlobalThis.CustomEvent( 40788 MediaUIEvents.MEDIA_TOGGLE_SUBTITLES_REQUEST, 40789 { composed: true, bubbles: true } 40790 ) 40791 ); 40792 break; 40793 case "ArrowLeft": { 40794 const offsetValue = this.hasAttribute( 40795 Attributes2.KEYBOARD_BACKWARD_SEEK_OFFSET 40796 ) ? +this.getAttribute(Attributes2.KEYBOARD_BACKWARD_SEEK_OFFSET) : DEFAULT_SEEK_OFFSET; 40797 detail = Math.max( 40798 ((_d = this.mediaStore.getState().mediaCurrentTime) != null ? _d : 0) - offsetValue, 40799 0 40800 ); 40801 evt = new GlobalThis.CustomEvent(MediaUIEvents.MEDIA_SEEK_REQUEST, { 40802 composed: true, 40803 bubbles: true, 40804 detail 40805 }); 40806 this.dispatchEvent(evt); 40807 break; 40808 } 40809 case "ArrowRight": { 40810 const offsetValue = this.hasAttribute( 40811 Attributes2.KEYBOARD_FORWARD_SEEK_OFFSET 40812 ) ? +this.getAttribute(Attributes2.KEYBOARD_FORWARD_SEEK_OFFSET) : DEFAULT_SEEK_OFFSET; 40813 detail = Math.max( 40814 ((_e5 = this.mediaStore.getState().mediaCurrentTime) != null ? _e5 : 0) + offsetValue, 40815 0 40816 ); 40817 evt = new GlobalThis.CustomEvent(MediaUIEvents.MEDIA_SEEK_REQUEST, { 40818 composed: true, 40819 bubbles: true, 40820 detail 40821 }); 40822 this.dispatchEvent(evt); 40823 break; 40824 } 40825 default: 40826 break; 40827 } 40828 } 40829}; 40830_hotKeys = /* @__PURE__ */ new WeakMap(); 40831_fullscreenElement = /* @__PURE__ */ new WeakMap(); 40832_mediaStore = /* @__PURE__ */ new WeakMap(); 40833_mediaStateCallback = /* @__PURE__ */ new WeakMap(); 40834_mediaStoreUnsubscribe = /* @__PURE__ */ new WeakMap(); 40835_mediaStateEventHandler = /* @__PURE__ */ new WeakMap(); 40836_setupDefaultStore = /* @__PURE__ */ new WeakSet(); 40837setupDefaultStore_fn = function() { 40838 var _a3; 40839 this.mediaStore = media_store_default({ 40840 media: this.media, 40841 fullscreenElement: this.fullscreenElement, 40842 options: { 40843 defaultSubtitles: this.hasAttribute(Attributes2.DEFAULT_SUBTITLES), 40844 defaultDuration: this.hasAttribute(Attributes2.DEFAULT_DURATION) ? +this.getAttribute(Attributes2.DEFAULT_DURATION) : void 0, 40845 defaultStreamType: ( 40846 /** @type {import('./media-store/state-mediator.js').StreamTypeValue} */ 40847 (_a3 = this.getAttribute( 40848 Attributes2.DEFAULT_STREAM_TYPE 40849 )) != null ? _a3 : void 0 40850 ), 40851 liveEdgeOffset: this.hasAttribute(Attributes2.LIVE_EDGE_OFFSET) ? +this.getAttribute(Attributes2.LIVE_EDGE_OFFSET) : void 0, 40852 // NOTE: This wasn't updated if it was changed later. Should it be? (CJP) 40853 noVolumePref: this.hasAttribute(Attributes2.NO_VOLUME_PREF), 40854 noSubtitlesLangPref: this.hasAttribute( 40855 Attributes2.NO_SUBTITLES_LANG_PREF 40856 ) 40857 } 40858 }); 40859}; 40860_keyUpHandler = /* @__PURE__ */ new WeakSet(); 40861keyUpHandler_fn = function(e) { 40862 const { key } = e; 40863 if (!ButtonPressedKeys.includes(key)) { 40864 this.removeEventListener("keyup", __privateMethod2(this, _keyUpHandler, keyUpHandler_fn)); 40865 return; 40866 } 40867 this.keyboardShortcutHandler(e); 40868}; 40869_keyDownHandler = /* @__PURE__ */ new WeakSet(); 40870keyDownHandler_fn = function(e) { 40871 const { metaKey, altKey, key } = e; 40872 if (metaKey || altKey || !ButtonPressedKeys.includes(key)) { 40873 this.removeEventListener("keyup", __privateMethod2(this, _keyUpHandler, keyUpHandler_fn)); 40874 return; 40875 } 40876 if ([" ", "ArrowLeft", "ArrowRight"].includes(key) && !(__privateGet4(this, _hotKeys).contains(`no${key.toLowerCase()}`) || key === " " && __privateGet4(this, _hotKeys).contains("nospace"))) { 40877 e.preventDefault(); 40878 } 40879 this.addEventListener("keyup", __privateMethod2(this, _keyUpHandler, keyUpHandler_fn), { once: true }); 40880}; 40881var MEDIA_UI_ATTRIBUTE_NAMES2 = Object.values(MediaUIAttributes); 40882var MEDIA_UI_PROP_NAMES = Object.values(MediaUIProps); 40883var getMediaUIAttributesFrom = (child) => { 40884 var _a3, _b, _c, _d; 40885 let { observedAttributes } = child.constructor; 40886 if (!observedAttributes && ((_a3 = child.nodeName) == null ? void 0 : _a3.includes("-"))) { 40887 GlobalThis.customElements.upgrade(child); 40888 ({ observedAttributes } = child.constructor); 40889 } 40890 const mediaChromeAttributesList = (_d = (_c = (_b = child == null ? void 0 : child.getAttribute) == null ? void 0 : _b.call(child, MediaStateReceiverAttributes.MEDIA_CHROME_ATTRIBUTES)) == null ? void 0 : _c.split) == null ? void 0 : _d.call(_c, /\s+/); 40891 if (!Array.isArray(observedAttributes || mediaChromeAttributesList)) 40892 return []; 40893 return (observedAttributes || mediaChromeAttributesList).filter( 40894 (attrName) => MEDIA_UI_ATTRIBUTE_NAMES2.includes(attrName) 40895 ); 40896}; 40897var hasMediaUIProps = (mediaStateReceiverCandidate) => { 40898 var _a3, _b; 40899 if (((_a3 = mediaStateReceiverCandidate.nodeName) == null ? void 0 : _a3.includes("-")) && !!GlobalThis.customElements.get( 40900 (_b = mediaStateReceiverCandidate.nodeName) == null ? void 0 : _b.toLowerCase() 40901 ) && !(mediaStateReceiverCandidate instanceof GlobalThis.customElements.get( 40902 mediaStateReceiverCandidate.nodeName.toLowerCase() 40903 ))) { 40904 GlobalThis.customElements.upgrade(mediaStateReceiverCandidate); 40905 } 40906 return MEDIA_UI_PROP_NAMES.some( 40907 (propName) => propName in mediaStateReceiverCandidate 40908 ); 40909}; 40910var isMediaStateReceiver = (child) => { 40911 return hasMediaUIProps(child) || !!getMediaUIAttributesFrom(child).length; 40912}; 40913var serializeTuple = (tuple) => { 40914 var _a3; 40915 return (_a3 = tuple == null ? void 0 : tuple.join) == null ? void 0 : _a3.call(tuple, ":"); 40916}; 40917var CustomAttrSerializer = { 40918 [MediaUIAttributes.MEDIA_SUBTITLES_LIST]: stringifyTextTrackList, 40919 [MediaUIAttributes.MEDIA_SUBTITLES_SHOWING]: stringifyTextTrackList, 40920 [MediaUIAttributes.MEDIA_SEEKABLE]: serializeTuple, 40921 [MediaUIAttributes.MEDIA_BUFFERED]: (tuples) => tuples == null ? void 0 : tuples.map(serializeTuple).join(" "), 40922 [MediaUIAttributes.MEDIA_PREVIEW_COORDS]: (coords) => coords == null ? void 0 : coords.join(" "), 40923 [MediaUIAttributes.MEDIA_RENDITION_LIST]: stringifyRenditionList, 40924 [MediaUIAttributes.MEDIA_AUDIO_TRACK_LIST]: stringifyAudioTrackList 40925}; 40926var setAttr = async (child, attrName, attrValue) => { 40927 var _a3, _b; 40928 if (!child.isConnected) { 40929 await delay(0); 40930 } 40931 if (typeof attrValue === "boolean" || attrValue == null) { 40932 return setBooleanAttr(child, attrName, attrValue); 40933 } 40934 if (typeof attrValue === "number") { 40935 return setNumericAttr(child, attrName, attrValue); 40936 } 40937 if (typeof attrValue === "string") { 40938 return setStringAttr(child, attrName, attrValue); 40939 } 40940 if (Array.isArray(attrValue) && !attrValue.length) { 40941 return child.removeAttribute(attrName); 40942 } 40943 const val = (_b = (_a3 = CustomAttrSerializer[attrName]) == null ? void 0 : _a3.call(CustomAttrSerializer, attrValue)) != null ? _b : attrValue; 40944 return child.setAttribute(attrName, val); 40945}; 40946var isMediaSlotElementDescendant = (el) => { 40947 var _a3; 40948 return !!((_a3 = el.closest) == null ? void 0 : _a3.call(el, '*[slot="media"]')); 40949}; 40950var traverseForMediaStateReceivers = (rootNode, mediaStateReceiverCallback) => { 40951 if (isMediaSlotElementDescendant(rootNode)) { 40952 return; 40953 } 40954 const traverseForMediaStateReceiversSync = (rootNode2, mediaStateReceiverCallback2) => { 40955 var _a3, _b; 40956 if (isMediaStateReceiver(rootNode2)) { 40957 mediaStateReceiverCallback2(rootNode2); 40958 } 40959 const { children = [] } = rootNode2 != null ? rootNode2 : {}; 40960 const shadowChildren = (_b = (_a3 = rootNode2 == null ? void 0 : rootNode2.shadowRoot) == null ? void 0 : _a3.children) != null ? _b : []; 40961 const allChildren = [...children, ...shadowChildren]; 40962 allChildren.forEach( 40963 (child) => traverseForMediaStateReceivers( 40964 child, 40965 mediaStateReceiverCallback2 40966 ) 40967 ); 40968 }; 40969 const name = rootNode == null ? void 0 : rootNode.nodeName.toLowerCase(); 40970 if (name.includes("-") && !isMediaStateReceiver(rootNode)) { 40971 GlobalThis.customElements.whenDefined(name).then(() => { 40972 traverseForMediaStateReceiversSync(rootNode, mediaStateReceiverCallback); 40973 }); 40974 return; 40975 } 40976 traverseForMediaStateReceiversSync(rootNode, mediaStateReceiverCallback); 40977}; 40978var propagateMediaState = (els, stateName, val) => { 40979 els.forEach((el) => { 40980 if (stateName in el) { 40981 el[stateName] = val; 40982 return; 40983 } 40984 const relevantAttrs = getMediaUIAttributesFrom(el); 40985 const attrName = stateName.toLowerCase(); 40986 if (!relevantAttrs.includes(attrName)) 40987 return; 40988 setAttr(el, attrName, val); 40989 }); 40990}; 40991var monitorForMediaStateReceivers = (rootNode, registerMediaStateReceiver, unregisterMediaStateReceiver) => { 40992 traverseForMediaStateReceivers(rootNode, registerMediaStateReceiver); 40993 const registerMediaStateReceiverHandler = (evt) => { 40994 var _a3; 40995 const el = (_a3 = evt == null ? void 0 : evt.composedPath()[0]) != null ? _a3 : evt.target; 40996 registerMediaStateReceiver(el); 40997 }; 40998 const unregisterMediaStateReceiverHandler = (evt) => { 40999 var _a3; 41000 const el = (_a3 = evt == null ? void 0 : evt.composedPath()[0]) != null ? _a3 : evt.target; 41001 unregisterMediaStateReceiver(el); 41002 }; 41003 rootNode.addEventListener( 41004 MediaUIEvents.REGISTER_MEDIA_STATE_RECEIVER, 41005 registerMediaStateReceiverHandler 41006 ); 41007 rootNode.addEventListener( 41008 MediaUIEvents.UNREGISTER_MEDIA_STATE_RECEIVER, 41009 unregisterMediaStateReceiverHandler 41010 ); 41011 const mutationCallback = (mutationsList) => { 41012 mutationsList.forEach((mutationRecord) => { 41013 const { 41014 addedNodes = [], 41015 removedNodes = [], 41016 type, 41017 target, 41018 attributeName 41019 } = mutationRecord; 41020 if (type === "childList") { 41021 Array.prototype.forEach.call( 41022 addedNodes, 41023 (node2) => traverseForMediaStateReceivers( 41024 node2, 41025 registerMediaStateReceiver 41026 ) 41027 ); 41028 Array.prototype.forEach.call( 41029 removedNodes, 41030 (node2) => traverseForMediaStateReceivers( 41031 node2, 41032 unregisterMediaStateReceiver 41033 ) 41034 ); 41035 } else if (type === "attributes" && attributeName === MediaStateReceiverAttributes.MEDIA_CHROME_ATTRIBUTES) { 41036 if (isMediaStateReceiver(target)) { 41037 registerMediaStateReceiver(target); 41038 } else { 41039 unregisterMediaStateReceiver(target); 41040 } 41041 } 41042 }); 41043 }; 41044 let prevSlotted = []; 41045 const slotChangeHandler = (event) => { 41046 const slotEl = event.target; 41047 if (slotEl.name === "media") 41048 return; 41049 prevSlotted.forEach( 41050 (node2) => traverseForMediaStateReceivers(node2, unregisterMediaStateReceiver) 41051 ); 41052 prevSlotted = [ 41053 ...slotEl.assignedElements({ flatten: true }) 41054 ]; 41055 prevSlotted.forEach( 41056 (node2) => traverseForMediaStateReceivers(node2, registerMediaStateReceiver) 41057 ); 41058 }; 41059 rootNode.addEventListener("slotchange", slotChangeHandler); 41060 const observer2 = new MutationObserver(mutationCallback); 41061 observer2.observe(rootNode, { 41062 childList: true, 41063 attributes: true, 41064 subtree: true 41065 }); 41066 const unsubscribe = () => { 41067 traverseForMediaStateReceivers(rootNode, unregisterMediaStateReceiver); 41068 rootNode.removeEventListener("slotchange", slotChangeHandler); 41069 observer2.disconnect(); 41070 rootNode.removeEventListener( 41071 MediaUIEvents.REGISTER_MEDIA_STATE_RECEIVER, 41072 registerMediaStateReceiverHandler 41073 ); 41074 rootNode.removeEventListener( 41075 MediaUIEvents.UNREGISTER_MEDIA_STATE_RECEIVER, 41076 unregisterMediaStateReceiverHandler 41077 ); 41078 }; 41079 return unsubscribe; 41080}; 41081if (!GlobalThis.customElements.get("media-controller")) { 41082 GlobalThis.customElements.define("media-controller", MediaController); 41083} 41084var media_controller_default = MediaController; 41085
vendor: 10,103 bytes, lines 41086-41372
41086// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-chrome-button.js 41087var __accessCheck5 = (obj, member, msg) => { 41088 if (!member.has(obj)) 41089 throw TypeError("Cannot " + msg); 41090}; 41091var __privateGet5 = (obj, member, getter) => { 41092 __accessCheck5(obj, member, "read from private field"); 41093 return getter ? getter.call(obj) : member.get(obj); 41094}; 41095var __privateAdd5 = (obj, member, value) => { 41096 if (member.has(obj)) 41097 throw TypeError("Cannot add the same private member more than once"); 41098 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 41099}; 41100var __privateSet5 = (obj, member, value, setter) => { 41101 __accessCheck5(obj, member, "write to private field"); 41102 setter ? setter.call(obj, value) : member.set(obj, value); 41103 return value; 41104}; 41105var __privateMethod3 = (obj, member, method) => { 41106 __accessCheck5(obj, member, "access private method"); 41107 return method; 41108}; 41109var _mediaController2; 41110var _clickListener; 41111var _positionTooltip; 41112var _keyupListener; 41113var _keydownListener; 41114var _setupTooltip; 41115var setupTooltip_fn; 41116var Attributes3 = { 41117 TOOLTIP_PLACEMENT: "tooltipplacement" 41118}; 41119var template3 = Document2.createElement("template"); 41120template3.innerHTML = /*html*/ 41121` 41122<style> 41123 :host { 41124 position: relative; 41125 font: var(--media-font, 41126 var(--media-font-weight, bold) 41127 var(--media-font-size, 14px) / 41128 var(--media-text-content-height, var(--media-control-height, 24px)) 41129 var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif)); 41130 color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238))); 41131 background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7))); 41132 padding: var(--media-button-padding, var(--media-control-padding, 10px)); 41133 justify-content: var(--media-button-justify-content, center); 41134 display: inline-flex; 41135 align-items: center; 41136 vertical-align: middle; 41137 box-sizing: border-box; 41138 transition: background .15s linear; 41139 pointer-events: auto; 41140 cursor: pointer; 41141 -webkit-tap-highlight-color: transparent; 41142 } 41143 41144 ${/* 41145 Only show outline when keyboard focusing. 41146 https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo 41147*/ 41148""} 41149 :host(:focus-visible) { 41150 box-shadow: inset 0 0 0 2px rgb(27 127 204 / .9); 41151 outline: 0; 41152 } 41153 ${/* 41154* hide default focus ring, particularly when using mouse 41155*/ 41156""} 41157 :host(:where(:focus)) { 41158 box-shadow: none; 41159 outline: 0; 41160 } 41161 41162 :host(:hover) { 41163 background: var(--media-control-hover-background, rgba(50 50 70 / .7)); 41164 } 41165 41166 svg, img, ::slotted(svg), ::slotted(img) { 41167 width: var(--media-button-icon-width); 41168 height: var(--media-button-icon-height, var(--media-control-height, 24px)); 41169 transform: var(--media-button-icon-transform); 41170 transition: var(--media-button-icon-transition); 41171 fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238))); 41172 vertical-align: middle; 41173 max-width: 100%; 41174 max-height: 100%; 41175 min-width: 100%; 41176 } 41177 41178 media-tooltip { 41179 ${/** Make sure unpositioned tooltip doesn't cause page overflow (scroll). */ 41180""} 41181 max-width: 0; 41182 overflow-x: clip; 41183 opacity: 0; 41184 transition: opacity .3s, max-width 0s 9s; 41185 } 41186 41187 :host(:hover) media-tooltip, 41188 :host(:focus-visible) media-tooltip { 41189 max-width: 100vw; 41190 opacity: 1; 41191 transition: opacity .3s; 41192 } 41193 41194 :host([notooltip]) slot[name="tooltip"] { 41195 display: none; 41196 } 41197</style> 41198 41199<slot name="tooltip"> 41200 <media-tooltip part="tooltip" aria-hidden="true"> 41201 <slot name="tooltip-content"></slot> 41202 </media-tooltip> 41203</slot> 41204`; 41205var MediaChromeButton = class extends GlobalThis.HTMLElement { 41206 constructor(options2 = {}) { 41207 var _a3; 41208 super(); 41209 __privateAdd5(this, _setupTooltip); 41210 __privateAdd5(this, _mediaController2, void 0); 41211 this.preventClick = false; 41212 this.tooltipEl = null; 41213 this.tooltipContent = ""; 41214 __privateAdd5(this, _clickListener, (e) => { 41215 if (!this.preventClick) { 41216 this.handleClick(e); 41217 } 41218 setTimeout(__privateGet5(this, _positionTooltip), 0); 41219 }); 41220 __privateAdd5(this, _positionTooltip, () => { 41221 var _a4, _b; 41222 (_b = (_a4 = this.tooltipEl) == null ? void 0 : _a4.updateXOffset) == null ? void 0 : _b.call(_a4); 41223 }); 41224 __privateAdd5(this, _keyupListener, (e) => { 41225 const { key } = e; 41226 if (!this.keysUsed.includes(key)) { 41227 this.removeEventListener("keyup", __privateGet5(this, _keyupListener)); 41228 return; 41229 } 41230 if (!this.preventClick) { 41231 this.handleClick(e); 41232 } 41233 }); 41234 __privateAdd5(this, _keydownListener, (e) => { 41235 const { metaKey, altKey, key } = e; 41236 if (metaKey || altKey || !this.keysUsed.includes(key)) { 41237 this.removeEventListener("keyup", __privateGet5(this, _keyupListener)); 41238 return; 41239 } 41240 this.addEventListener("keyup", __privateGet5(this, _keyupListener), { once: true }); 41241 }); 41242 if (!this.shadowRoot) { 41243 this.attachShadow({ mode: "open" }); 41244 const buttonHTML = template3.content.cloneNode(true); 41245 this.nativeEl = buttonHTML; 41246 let slotTemplate17 = options2.slotTemplate; 41247 if (!slotTemplate17) { 41248 slotTemplate17 = Document2.createElement("template"); 41249 slotTemplate17.innerHTML = `<slot>${options2.defaultContent || ""}</slot>`; 41250 } 41251 if (options2.tooltipContent) { 41252 buttonHTML.querySelector('slot[name="tooltip-content"]').innerHTML = (_a3 = options2.tooltipContent) != null ? _a3 : ""; 41253 this.tooltipContent = options2.tooltipContent; 41254 } 41255 this.nativeEl.appendChild(slotTemplate17.content.cloneNode(true)); 41256 this.shadowRoot.appendChild(buttonHTML); 41257 } 41258 this.tooltipEl = this.shadowRoot.querySelector("media-tooltip"); 41259 } 41260 static get observedAttributes() { 41261 return [ 41262 "disabled", 41263 Attributes3.TOOLTIP_PLACEMENT, 41264 MediaStateReceiverAttributes.MEDIA_CONTROLLER 41265 ]; 41266 } 41267 enable() { 41268 this.addEventListener("click", __privateGet5(this, _clickListener)); 41269 this.addEventListener("keydown", __privateGet5(this, _keydownListener)); 41270 this.tabIndex = 0; 41271 } 41272 disable() { 41273 this.removeEventListener("click", __privateGet5(this, _clickListener)); 41274 this.removeEventListener("keydown", __privateGet5(this, _keydownListener)); 41275 this.removeEventListener("keyup", __privateGet5(this, _keyupListener)); 41276 this.tabIndex = -1; 41277 } 41278 attributeChangedCallback(attrName, oldValue, newValue) { 41279 var _a3, _b, _c, _d, _e5; 41280 if (attrName === MediaStateReceiverAttributes.MEDIA_CONTROLLER) { 41281 if (oldValue) { 41282 (_b = (_a3 = __privateGet5(this, _mediaController2)) == null ? void 0 : _a3.unassociateElement) == null ? void 0 : _b.call(_a3, this); 41283 __privateSet5(this, _mediaController2, null); 41284 } 41285 if (newValue && this.isConnected) { 41286 __privateSet5(this, _mediaController2, (_c = this.getRootNode()) == null ? void 0 : _c.getElementById(newValue)); 41287 (_e5 = (_d = __privateGet5(this, _mediaController2)) == null ? void 0 : _d.associateElement) == null ? void 0 : _e5.call(_d, this); 41288 } 41289 } else if (attrName === "disabled" && newValue !== oldValue) { 41290 if (newValue == null) { 41291 this.enable(); 41292 } else { 41293 this.disable(); 41294 } 41295 } else if (attrName === Attributes3.TOOLTIP_PLACEMENT && this.tooltipEl && newValue !== oldValue) { 41296 this.tooltipEl.placement = newValue; 41297 } 41298 __privateGet5(this, _positionTooltip).call(this); 41299 } 41300 connectedCallback() { 41301 var _a3, _b, _c; 41302 const { style } = getOrInsertCSSRule(this.shadowRoot, ":host"); 41303 style.setProperty( 41304 "display", 41305 `var(--media-control-display, var(--${this.localName}-display, inline-flex))` 41306 ); 41307 if (!this.hasAttribute("disabled")) { 41308 this.enable(); 41309 } 41310 this.setAttribute("role", "button"); 41311 const mediaControllerId = this.getAttribute( 41312 MediaStateReceiverAttributes.MEDIA_CONTROLLER 41313 ); 41314 if (mediaControllerId) { 41315 __privateSet5( 41316 this, 41317 _mediaController2, 41318 // @ts-ignore 41319 (_a3 = this.getRootNode()) == null ? void 0 : _a3.getElementById(mediaControllerId) 41320 ); 41321 (_c = (_b = __privateGet5(this, _mediaController2)) == null ? void 0 : _b.associateElement) == null ? void 0 : _c.call(_b, this); 41322 } 41323 GlobalThis.customElements.whenDefined("media-tooltip").then(() => __privateMethod3(this, _setupTooltip, setupTooltip_fn).call(this)); 41324 } 41325 disconnectedCallback() { 41326 var _a3, _b; 41327 this.disable(); 41328 (_b = (_a3 = __privateGet5(this, _mediaController2)) == null ? void 0 : _a3.unassociateElement) == null ? void 0 : _b.call(_a3, this); 41329 __privateSet5(this, _mediaController2, null); 41330 this.removeEventListener("mouseenter", __privateGet5(this, _positionTooltip)); 41331 this.removeEventListener("focus", __privateGet5(this, _positionTooltip)); 41332 this.removeEventListener("click", __privateGet5(this, _clickListener)); 41333 } 41334 get keysUsed() { 41335 return ["Enter", " "]; 41336 } 41337 /** 41338 * Get or set tooltip placement 41339 */ 41340 get tooltipPlacement() { 41341 return getStringAttr(this, Attributes3.TOOLTIP_PLACEMENT); 41342 } 41343 set tooltipPlacement(value) { 41344 setStringAttr(this, Attributes3.TOOLTIP_PLACEMENT, value); 41345 } 41346 /** 41347 * @abstract 41348 * @argument {Event} e 41349 */ 41350 handleClick(e) { 41351 } 41352 // eslint-disable-line 41353}; 41354_mediaController2 = /* @__PURE__ */ new WeakMap(); 41355_clickListener = /* @__PURE__ */ new WeakMap(); 41356_positionTooltip = /* @__PURE__ */ new WeakMap(); 41357_keyupListener = /* @__PURE__ */ new WeakMap(); 41358_keydownListener = /* @__PURE__ */ new WeakMap(); 41359_setupTooltip = /* @__PURE__ */ new WeakSet(); 41360setupTooltip_fn = function() { 41361 this.addEventListener("mouseenter", __privateGet5(this, _positionTooltip)); 41362 this.addEventListener("focus", __privateGet5(this, _positionTooltip)); 41363 this.addEventListener("click", __privateGet5(this, _clickListener)); 41364 const initialPlacement = this.tooltipPlacement; 41365 if (initialPlacement && this.tooltipEl) { 41366 this.tooltipEl.placement = initialPlacement; 41367 } 41368}; 41369if (!GlobalThis.customElements.get("media-chrome-button")) { 41370 GlobalThis.customElements.define("media-chrome-button", MediaChromeButton); 41371} 41372
vendor: 3,085 bytes, lines 41373-41467
41373// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-airplay-button.js 41374var airplayIcon = `<svg aria-hidden="true" viewBox="0 0 26 24"> 41375 <path d="M22.13 3H3.87a.87.87 0 0 0-.87.87v13.26a.87.87 0 0 0 .87.87h3.4L9 16H5V5h16v11h-4l1.72 2h3.4a.87.87 0 0 0 .87-.87V3.87a.87.87 0 0 0-.86-.87Zm-8.75 11.44a.5.5 0 0 0-.76 0l-4.91 5.73a.5.5 0 0 0 .38.83h9.82a.501.501 0 0 0 .38-.83l-4.91-5.73Z"/> 41376</svg> 41377`; 41378var slotTemplate = Document2.createElement("template"); 41379slotTemplate.innerHTML = /*html*/ 41380` 41381 <style> 41382 :host([${MediaUIAttributes.MEDIA_IS_AIRPLAYING}]) slot[name=icon] slot:not([name=exit]) { 41383 display: none !important; 41384 } 41385 41386 ${/* Double negative, but safer if display doesn't equal 'block' */ 41387""} 41388 :host(:not([${MediaUIAttributes.MEDIA_IS_AIRPLAYING}])) slot[name=icon] slot:not([name=enter]) { 41389 display: none !important; 41390 } 41391 41392 :host([${MediaUIAttributes.MEDIA_IS_AIRPLAYING}]) slot[name=tooltip-enter], 41393 :host(:not([${MediaUIAttributes.MEDIA_IS_AIRPLAYING}])) slot[name=tooltip-exit] { 41394 display: none; 41395 } 41396 </style> 41397 41398 <slot name="icon"> 41399 <slot name="enter">${airplayIcon}</slot> 41400 <slot name="exit">${airplayIcon}</slot> 41401 </slot> 41402`; 41403var tooltipContent = ( 41404 /*html*/ 41405 ` 41406 <slot name="tooltip-enter">${tooltipLabels.ENTER_AIRPLAY}</slot> 41407 <slot name="tooltip-exit">${tooltipLabels.EXIT_AIRPLAY}</slot> 41408` 41409); 41410var updateAriaLabel = (el) => { 41411 const label = el.mediaIsAirplaying ? verbs.EXIT_AIRPLAY() : verbs.ENTER_AIRPLAY(); 41412 el.setAttribute("aria-label", label); 41413}; 41414var MediaAirplayButton = class extends MediaChromeButton { 41415 static get observedAttributes() { 41416 return [ 41417 ...super.observedAttributes, 41418 MediaUIAttributes.MEDIA_IS_AIRPLAYING, 41419 MediaUIAttributes.MEDIA_AIRPLAY_UNAVAILABLE 41420 ]; 41421 } 41422 constructor(options2 = {}) { 41423 super({ slotTemplate, tooltipContent, ...options2 }); 41424 } 41425 connectedCallback() { 41426 super.connectedCallback(); 41427 updateAriaLabel(this); 41428 } 41429 attributeChangedCallback(attrName, oldValue, newValue) { 41430 super.attributeChangedCallback(attrName, oldValue, newValue); 41431 if (attrName === MediaUIAttributes.MEDIA_IS_AIRPLAYING) { 41432 updateAriaLabel(this); 41433 } 41434 } 41435 /** 41436 * Are we currently airplaying 41437 */ 41438 get mediaIsAirplaying() { 41439 return getBooleanAttr(this, MediaUIAttributes.MEDIA_IS_AIRPLAYING); 41440 } 41441 set mediaIsAirplaying(value) { 41442 setBooleanAttr(this, MediaUIAttributes.MEDIA_IS_AIRPLAYING, value); 41443 } 41444 /** 41445 * Airplay unavailability state 41446 */ 41447 get mediaAirplayUnavailable() { 41448 return getStringAttr(this, MediaUIAttributes.MEDIA_AIRPLAY_UNAVAILABLE); 41449 } 41450 set mediaAirplayUnavailable(value) { 41451 setStringAttr(this, MediaUIAttributes.MEDIA_AIRPLAY_UNAVAILABLE, value); 41452 } 41453 handleClick() { 41454 const evt = new GlobalThis.CustomEvent( 41455 MediaUIEvents.MEDIA_AIRPLAY_REQUEST, 41456 { 41457 composed: true, 41458 bubbles: true 41459 } 41460 ); 41461 this.dispatchEvent(evt); 41462 } 41463}; 41464if (!GlobalThis.customElements.get("media-airplay-button")) { 41465 GlobalThis.customElements.define("media-airplay-button", MediaAirplayButton); 41466} 41467
vendor: 5,822 bytes, lines 41468-41587
41468// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-captions-button.js 41469var ccIconOn = `<svg aria-hidden="true" viewBox="0 0 26 24"> 41470 <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/> 41471</svg>`; 41472var ccIconOff = `<svg aria-hidden="true" viewBox="0 0 26 24"> 41473 <path d="M17.73 14.09a1.4 1.4 0 0 1-1 .37 1.579 1.579 0 0 1-1.27-.58A3 3 0 0 1 15 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34A2.89 2.89 0 0 0 19 9.07a3 3 0 0 0-2.14-.78 3.14 3.14 0 0 0-2.42 1 3.91 3.91 0 0 0-.93 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.17 3.17 0 0 0 1.07-1.74l-1.4-.45c-.083.43-.3.822-.62 1.12Zm-7.22 0a1.43 1.43 0 0 1-1 .37 1.58 1.58 0 0 1-1.27-.58A3 3 0 0 1 7.76 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34a2.81 2.81 0 0 0-.74-1.32 2.94 2.94 0 0 0-2.13-.78 3.18 3.18 0 0 0-2.43 1 4 4 0 0 0-.92 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.23 3.23 0 0 0 1.07-1.74l-1.4-.45a2.06 2.06 0 0 1-.6 1.07Zm12.32-8.41a2.59 2.59 0 0 0-2.3-2.51C18.72 3.05 15.86 3 13 3c-2.86 0-5.72.05-7.53.17a2.59 2.59 0 0 0-2.3 2.51c-.23 4.207-.23 8.423 0 12.63a2.57 2.57 0 0 0 2.3 2.5c1.81.13 4.67.19 7.53.19 2.86 0 5.72-.06 7.53-.19a2.57 2.57 0 0 0 2.3-2.5c.23-4.207.23-8.423 0-12.63Zm-1.49 12.53a1.11 1.11 0 0 1-.91 1.11c-1.67.11-4.45.18-7.43.18-2.98 0-5.76-.07-7.43-.18a1.11 1.11 0 0 1-.91-1.11c-.21-4.14-.21-8.29 0-12.43a1.11 1.11 0 0 1 .91-1.11C7.24 4.56 10 4.49 13 4.49s5.76.07 7.43.18a1.11 1.11 0 0 1 .91 1.11c.21 4.14.21 8.29 0 12.43Z"/> 41474</svg>`; 41475var slotTemplate2 = Document2.createElement("template"); 41476slotTemplate2.innerHTML = /*html*/ 41477` 41478 <style> 41479 :host([aria-checked="true"]) slot[name=off] { 41480 display: none !important; 41481 } 41482 41483 ${/* Double negative, but safer if display doesn't equal 'block' */ 41484""} 41485 :host(:not([aria-checked="true"])) slot[name=on] { 41486 display: none !important; 41487 } 41488 41489 :host([aria-checked="true"]) slot[name=tooltip-enable], 41490 :host(:not([aria-checked="true"])) slot[name=tooltip-disable] { 41491 display: none; 41492 } 41493 </style> 41494 41495 <slot name="icon"> 41496 <slot name="on">${ccIconOn}</slot> 41497 <slot name="off">${ccIconOff}</slot> 41498 </slot> 41499`; 41500var tooltipContent2 = ( 41501 /*html*/ 41502 ` 41503 <slot name="tooltip-enable">${tooltipLabels.ENABLE_CAPTIONS}</slot> 41504 <slot name="tooltip-disable">${tooltipLabels.DISABLE_CAPTIONS}</slot> 41505` 41506); 41507var updateAriaChecked = (el) => { 41508 el.setAttribute("aria-checked", areSubsOn(el).toString()); 41509}; 41510var MediaCaptionsButton = class extends MediaChromeButton { 41511 static get observedAttributes() { 41512 return [ 41513 ...super.observedAttributes, 41514 MediaUIAttributes.MEDIA_SUBTITLES_LIST, 41515 MediaUIAttributes.MEDIA_SUBTITLES_SHOWING 41516 ]; 41517 } 41518 constructor(options2 = {}) { 41519 super({ slotTemplate: slotTemplate2, tooltipContent: tooltipContent2, ...options2 }); 41520 this._captionsReady = false; 41521 } 41522 connectedCallback() { 41523 super.connectedCallback(); 41524 this.setAttribute("role", "switch"); 41525 this.setAttribute("aria-label", nouns.CLOSED_CAPTIONS()); 41526 updateAriaChecked(this); 41527 } 41528 attributeChangedCallback(attrName, oldValue, newValue) { 41529 super.attributeChangedCallback(attrName, oldValue, newValue); 41530 if (attrName === MediaUIAttributes.MEDIA_SUBTITLES_SHOWING) { 41531 updateAriaChecked(this); 41532 } 41533 } 41534 /** 41535 * An array of TextTrack-like objects. 41536 * Objects must have the properties: kind, language, and label. 41537 */ 41538 get mediaSubtitlesList() { 41539 return getSubtitlesListAttr(this, MediaUIAttributes.MEDIA_SUBTITLES_LIST); 41540 } 41541 set mediaSubtitlesList(list) { 41542 setSubtitlesListAttr(this, MediaUIAttributes.MEDIA_SUBTITLES_LIST, list); 41543 } 41544 /** 41545 * An array of TextTrack-like objects. 41546 * Objects must have the properties: kind, language, and label. 41547 */ 41548 get mediaSubtitlesShowing() { 41549 return getSubtitlesListAttr( 41550 this, 41551 MediaUIAttributes.MEDIA_SUBTITLES_SHOWING 41552 ); 41553 } 41554 set mediaSubtitlesShowing(list) { 41555 setSubtitlesListAttr(this, MediaUIAttributes.MEDIA_SUBTITLES_SHOWING, list); 41556 } 41557 handleClick() { 41558 this.dispatchEvent( 41559 new GlobalThis.CustomEvent(MediaUIEvents.MEDIA_TOGGLE_SUBTITLES_REQUEST, { 41560 composed: true, 41561 bubbles: true 41562 }) 41563 ); 41564 } 41565}; 41566var getSubtitlesListAttr = (el, attrName) => { 41567 const attrVal = el.getAttribute(attrName); 41568 return attrVal ? parseTextTracksStr(attrVal) : []; 41569}; 41570var setSubtitlesListAttr = (el, attrName, list) => { 41571 if (!(list == null ? void 0 : list.length)) { 41572 el.removeAttribute(attrName); 41573 return; 41574 } 41575 const newValStr = stringifyTextTrackList(list); 41576 const oldVal = el.getAttribute(attrName); 41577 if (oldVal === newValStr) 41578 return; 41579 el.setAttribute(attrName, newValStr); 41580}; 41581if (!GlobalThis.customElements.get("media-captions-button")) { 41582 GlobalThis.customElements.define( 41583 "media-captions-button", 41584 MediaCaptionsButton 41585 ); 41586} 41587
vendor: 3,987 bytes, lines 41588-41676
41588// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-cast-button.js 41589var enterIcon = `<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/></g></svg>`; 41590var exitIcon = `<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/><path class="cast_caf_icon_boxfill" d="M5,7 L5,8.63 C8,8.6 13.37,14 13.37,17 L19,17 L19,7 Z"/></g></svg>`; 41591var slotTemplate3 = Document2.createElement("template"); 41592slotTemplate3.innerHTML = /*html*/ 41593` 41594 <style> 41595 :host([${MediaUIAttributes.MEDIA_IS_CASTING}]) slot[name=icon] slot:not([name=exit]) { 41596 display: none !important; 41597 } 41598 41599 ${/* Double negative, but safer if display doesn't equal 'block' */ 41600""} 41601 :host(:not([${MediaUIAttributes.MEDIA_IS_CASTING}])) slot[name=icon] slot:not([name=enter]) { 41602 display: none !important; 41603 } 41604 41605 :host([${MediaUIAttributes.MEDIA_IS_CASTING}]) slot[name=tooltip-enter], 41606 :host(:not([${MediaUIAttributes.MEDIA_IS_CASTING}])) slot[name=tooltip-exit] { 41607 display: none; 41608 } 41609 </style> 41610 41611 <slot name="icon"> 41612 <slot name="enter">${enterIcon}</slot> 41613 <slot name="exit">${exitIcon}</slot> 41614 </slot> 41615`; 41616var tooltipContent3 = ( 41617 /*html*/ 41618 ` 41619 <slot name="tooltip-enter">${tooltipLabels.START_CAST}</slot> 41620 <slot name="tooltip-exit">${tooltipLabels.STOP_CAST}</slot> 41621` 41622); 41623var updateAriaLabel2 = (el) => { 41624 const label = el.mediaIsCasting ? verbs.EXIT_CAST() : verbs.ENTER_CAST(); 41625 el.setAttribute("aria-label", label); 41626}; 41627var MediaCastButton = class extends MediaChromeButton { 41628 static get observedAttributes() { 41629 return [ 41630 ...super.observedAttributes, 41631 MediaUIAttributes.MEDIA_IS_CASTING, 41632 MediaUIAttributes.MEDIA_CAST_UNAVAILABLE 41633 ]; 41634 } 41635 constructor(options2 = {}) { 41636 super({ slotTemplate: slotTemplate3, tooltipContent: tooltipContent3, ...options2 }); 41637 } 41638 connectedCallback() { 41639 super.connectedCallback(); 41640 updateAriaLabel2(this); 41641 } 41642 attributeChangedCallback(attrName, oldValue, newValue) { 41643 super.attributeChangedCallback(attrName, oldValue, newValue); 41644 if (attrName === MediaUIAttributes.MEDIA_IS_CASTING) { 41645 updateAriaLabel2(this); 41646 } 41647 } 41648 /** 41649 * @type {boolean} Are we currently casting 41650 */ 41651 get mediaIsCasting() { 41652 return getBooleanAttr(this, MediaUIAttributes.MEDIA_IS_CASTING); 41653 } 41654 set mediaIsCasting(value) { 41655 setBooleanAttr(this, MediaUIAttributes.MEDIA_IS_CASTING, value); 41656 } 41657 /** 41658 * @type {string | undefined} Cast unavailability state 41659 */ 41660 get mediaCastUnavailable() { 41661 return getStringAttr(this, MediaUIAttributes.MEDIA_CAST_UNAVAILABLE); 41662 } 41663 set mediaCastUnavailable(value) { 41664 setStringAttr(this, MediaUIAttributes.MEDIA_CAST_UNAVAILABLE, value); 41665 } 41666 handleClick() { 41667 const eventName = this.mediaIsCasting ? MediaUIEvents.MEDIA_EXIT_CAST_REQUEST : MediaUIEvents.MEDIA_ENTER_CAST_REQUEST; 41668 this.dispatchEvent( 41669 new GlobalThis.CustomEvent(eventName, { composed: true, bubbles: true }) 41670 ); 41671 } 41672}; 41673if (!GlobalThis.customElements.get("media-cast-button")) { 41674 GlobalThis.customElements.define("media-cast-button", MediaCastButton); 41675} 41676
vendor: 6,977 bytes, lines 41677-41875
41677// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-chrome-dialog.js 41678var __accessCheck6 = (obj, member, msg) => { 41679 if (!member.has(obj)) 41680 throw TypeError("Cannot " + msg); 41681}; 41682var __privateGet6 = (obj, member, getter) => { 41683 __accessCheck6(obj, member, "read from private field"); 41684 return getter ? getter.call(obj) : member.get(obj); 41685}; 41686var __privateAdd6 = (obj, member, value) => { 41687 if (member.has(obj)) 41688 throw TypeError("Cannot add the same private member more than once"); 41689 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 41690}; 41691var __privateSet6 = (obj, member, value, setter) => { 41692 __accessCheck6(obj, member, "write to private field"); 41693 setter ? setter.call(obj, value) : member.set(obj, value); 41694 return value; 41695}; 41696var __privateMethod4 = (obj, member, method) => { 41697 __accessCheck6(obj, member, "access private method"); 41698 return method; 41699}; 41700var _previouslyFocused; 41701var _invokerElement; 41702var _handleOpen; 41703var handleOpen_fn; 41704var _handleClosed; 41705var handleClosed_fn; 41706var _handleInvoke; 41707var handleInvoke_fn; 41708var _handleFocusOut; 41709var handleFocusOut_fn; 41710var _handleKeyDown; 41711var handleKeyDown_fn; 41712var template4 = Document2.createElement("template"); 41713template4.innerHTML = /*html*/ 41714` 41715 <style> 41716 :host { 41717 font: var(--media-font, 41718 var(--media-font-weight, normal) 41719 var(--media-font-size, 14px) / 41720 var(--media-text-content-height, var(--media-control-height, 24px)) 41721 var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif)); 41722 color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238))); 41723 background: var(--media-dialog-background, var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .8)))); 41724 border-radius: var(--media-dialog-border-radius); 41725 border: var(--media-dialog-border, none); 41726 display: var(--media-dialog-display, inline-flex); 41727 transition: var(--media-dialog-transition-in, 41728 visibility 0s, 41729 opacity .2s ease-out, 41730 transform .15s ease-out 41731 ) !important; 41732 ${/* ^^Prevent transition override by media-container */ 41733""} 41734 visibility: var(--media-dialog-visibility, visible); 41735 opacity: var(--media-dialog-opacity, 1); 41736 transform: var(--media-dialog-transform-in, translateY(0) scale(1)); 41737 } 41738 41739 :host([hidden]) { 41740 transition: var(--media-dialog-transition-out, 41741 visibility .15s ease-in, 41742 opacity .15s ease-in, 41743 transform .15s ease-in 41744 ) !important; 41745 visibility: var(--media-dialog-hidden-visibility, hidden); 41746 opacity: var(--media-dialog-hidden-opacity, 0); 41747 transform: var(--media-dialog-transform-out, translateY(2px) scale(.99)); 41748 pointer-events: none; 41749 } 41750 </style> 41751 <slot></slot> 41752`; 41753var Attributes4 = { 41754 HIDDEN: "hidden", 41755 ANCHOR: "anchor" 41756}; 41757var MediaChromeDialog = class extends GlobalThis.HTMLElement { 41758 constructor() { 41759 super(); 41760 __privateAdd6(this, _handleOpen); 41761 __privateAdd6(this, _handleClosed); 41762 __privateAdd6(this, _handleInvoke); 41763 __privateAdd6(this, _handleFocusOut); 41764 __privateAdd6(this, _handleKeyDown); 41765 __privateAdd6(this, _previouslyFocused, null); 41766 __privateAdd6(this, _invokerElement, null); 41767 if (!this.shadowRoot) { 41768 this.attachShadow({ mode: "open" }); 41769 this.nativeEl = this.constructor.template.content.cloneNode(true); 41770 this.shadowRoot.append(this.nativeEl); 41771 } 41772 this.addEventListener("invoke", this); 41773 this.addEventListener("focusout", this); 41774 this.addEventListener("keydown", this); 41775 } 41776 static get observedAttributes() { 41777 return [Attributes4.HIDDEN, Attributes4.ANCHOR]; 41778 } 41779 handleEvent(event) { 41780 switch (event.type) { 41781 case "invoke": 41782 __privateMethod4(this, _handleInvoke, handleInvoke_fn).call(this, event); 41783 break; 41784 case "focusout": 41785 __privateMethod4(this, _handleFocusOut, handleFocusOut_fn).call(this, event); 41786 break; 41787 case "keydown": 41788 __privateMethod4(this, _handleKeyDown, handleKeyDown_fn).call(this, event); 41789 break; 41790 } 41791 } 41792 connectedCallback() { 41793 if (!this.role) { 41794 this.role = "dialog"; 41795 } 41796 } 41797 attributeChangedCallback(attrName, oldValue, newValue) { 41798 if (attrName === Attributes4.HIDDEN && newValue !== oldValue) { 41799 if (this.hidden) { 41800 __privateMethod4(this, _handleClosed, handleClosed_fn).call(this); 41801 } else { 41802 __privateMethod4(this, _handleOpen, handleOpen_fn).call(this); 41803 } 41804 } 41805 } 41806 focus() { 41807 __privateSet6(this, _previouslyFocused, getActiveElement()); 41808 const focusable = this.querySelector( 41809 '[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]' 41810 ); 41811 focusable == null ? void 0 : focusable.focus(); 41812 } 41813 get keysUsed() { 41814 return ["Escape", "Tab"]; 41815 } 41816}; 41817_previouslyFocused = /* @__PURE__ */ new WeakMap(); 41818_invokerElement = /* @__PURE__ */ new WeakMap(); 41819_handleOpen = /* @__PURE__ */ new WeakSet(); 41820handleOpen_fn = function() { 41821 var _a3; 41822 (_a3 = __privateGet6(this, _invokerElement)) == null ? void 0 : _a3.setAttribute("aria-expanded", "true"); 41823 this.addEventListener("transitionend", () => this.focus(), { once: true }); 41824}; 41825_handleClosed = /* @__PURE__ */ new WeakSet(); 41826handleClosed_fn = function() { 41827 var _a3; 41828 (_a3 = __privateGet6(this, _invokerElement)) == null ? void 0 : _a3.setAttribute("aria-expanded", "false"); 41829}; 41830_handleInvoke = /* @__PURE__ */ new WeakSet(); 41831handleInvoke_fn = function(event) { 41832 __privateSet6(this, _invokerElement, event.relatedTarget); 41833 if (!containsComposedNode(this, event.relatedTarget)) { 41834 this.hidden = !this.hidden; 41835 } 41836}; 41837_handleFocusOut = /* @__PURE__ */ new WeakSet(); 41838handleFocusOut_fn = function(event) { 41839 var _a3; 41840 if (!containsComposedNode(this, event.relatedTarget)) { 41841 (_a3 = __privateGet6(this, _previouslyFocused)) == null ? void 0 : _a3.focus(); 41842 if (__privateGet6(this, _invokerElement) && __privateGet6(this, _invokerElement) !== event.relatedTarget && !this.hidden) { 41843 this.hidden = true; 41844 } 41845 } 41846}; 41847_handleKeyDown = /* @__PURE__ */ new WeakSet(); 41848handleKeyDown_fn = function(event) { 41849 var _a3, _b, _c, _d, _e5; 41850 const { key, ctrlKey, altKey, metaKey } = event; 41851 if (ctrlKey || altKey || metaKey) { 41852 return; 41853 } 41854 if (!this.keysUsed.includes(key)) { 41855 return; 41856 } 41857 event.preventDefault(); 41858 event.stopPropagation(); 41859 if (key === "Tab") { 41860 if (event.shiftKey) { 41861 (_b = (_a3 = this.previousElementSibling) == null ? void 0 : _a3.focus) == null ? void 0 : _b.call(_a3); 41862 } else { 41863 (_d = (_c = this.nextElementSibling) == null ? void 0 : _c.focus) == null ? void 0 : _d.call(_c); 41864 } 41865 this.blur(); 41866 } else if (key === "Escape") { 41867 (_e5 = __privateGet6(this, _previouslyFocused)) == null ? void 0 : _e5.focus(); 41868 this.hidden = true; 41869 } 41870}; 41871MediaChromeDialog.template = template4; 41872if (!GlobalThis.customElements.get("media-chrome-dialog")) { 41873 GlobalThis.customElements.define("media-chrome-dialog", MediaChromeDialog); 41874} 41875
vendor: 20,965 bytes, lines 41876-42451
41876// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-chrome-range.js 41877var __accessCheck7 = (obj, member, msg) => { 41878 if (!member.has(obj)) 41879 throw TypeError("Cannot " + msg); 41880}; 41881var __privateGet7 = (obj, member, getter) => { 41882 __accessCheck7(obj, member, "read from private field"); 41883 return getter ? getter.call(obj) : member.get(obj); 41884}; 41885var __privateAdd7 = (obj, member, value) => { 41886 if (member.has(obj)) 41887 throw TypeError("Cannot add the same private member more than once"); 41888 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 41889}; 41890var __privateSet7 = (obj, member, value, setter) => { 41891 __accessCheck7(obj, member, "write to private field"); 41892 setter ? setter.call(obj, value) : member.set(obj, value); 41893 return value; 41894}; 41895var __privateMethod5 = (obj, member, method) => { 41896 __accessCheck7(obj, member, "access private method"); 41897 return method; 41898}; 41899var _mediaController3; 41900var _isInputTarget; 41901var _startpoint; 41902var _endpoint; 41903var _cssRules; 41904var _segments; 41905var _onFocusIn; 41906var _onFocusOut; 41907var _updateComputedStyles; 41908var _updateActiveSegment; 41909var updateActiveSegment_fn; 41910var _enableUserEvents; 41911var enableUserEvents_fn; 41912var _disableUserEvents; 41913var disableUserEvents_fn; 41914var _handlePointerDown; 41915var handlePointerDown_fn; 41916var _handlePointerEnter; 41917var handlePointerEnter_fn; 41918var _handlePointerUp2; 41919var handlePointerUp_fn2; 41920var _handlePointerLeave; 41921var handlePointerLeave_fn; 41922var _handlePointerMove2; 41923var handlePointerMove_fn2; 41924var template5 = Document2.createElement("template"); 41925template5.innerHTML = /*html*/ 41926` 41927 <style> 41928 :host { 41929 --_focus-box-shadow: var(--media-focus-box-shadow, inset 0 0 0 2px rgb(27 127 204 / .9)); 41930 --_media-range-padding: var(--media-range-padding, var(--media-control-padding, 10px)); 41931 41932 box-shadow: var(--_focus-visible-box-shadow, none); 41933 background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7))); 41934 height: calc(var(--media-control-height, 24px) + 2 * var(--_media-range-padding)); 41935 display: inline-flex; 41936 align-items: center; 41937 ${/* Don't horizontal align w/ justify-content! #container can go negative on the x-axis w/ small width. */ 41938""} 41939 vertical-align: middle; 41940 box-sizing: border-box; 41941 position: relative; 41942 width: 100px; 41943 transition: background .15s linear; 41944 cursor: pointer; 41945 pointer-events: auto; 41946 touch-action: none; ${/* Prevent scrolling when dragging on mobile. */ 41947""} 41948 z-index: 1; ${/* Apply z-index to overlap buttons below. */ 41949""} 41950 } 41951 41952 ${/* Reset before `outline` on track could be set by a CSS var */ 41953""} 41954 input[type=range]:focus { 41955 outline: 0; 41956 } 41957 input[type=range]:focus::-webkit-slider-runnable-track { 41958 outline: 0; 41959 } 41960 41961 :host(:hover) { 41962 background: var(--media-control-hover-background, rgb(50 50 70 / .7)); 41963 } 41964 41965 #leftgap { 41966 padding-left: var(--media-range-padding-left, var(--_media-range-padding)); 41967 } 41968 41969 #rightgap { 41970 padding-right: var(--media-range-padding-right, var(--_media-range-padding)); 41971 } 41972 41973 #startpoint, 41974 #endpoint { 41975 position: absolute; 41976 } 41977 41978 #endpoint { 41979 right: 0; 41980 } 41981 41982 #container { 41983 ${/* Not using the CSS `padding` prop makes it easier for slide open volume ranges so the width can be zero. */ 41984""} 41985 width: var(--media-range-track-width, 100%); 41986 transform: translate(var(--media-range-track-translate-x, 0px), var(--media-range-track-translate-y, 0px)); 41987 position: relative; 41988 height: 100%; 41989 display: flex; 41990 align-items: center; 41991 min-width: 40px; 41992 } 41993 41994 #range { 41995 ${/* The input range acts as a hover and hit zone for input events. */ 41996""} 41997 display: var(--media-time-range-hover-display, block); 41998 bottom: var(--media-time-range-hover-bottom, -7px); 41999 height: var(--media-time-range-hover-height, max(100% + 7px, 25px)); 42000 width: 100%; 42001 position: absolute; 42002 cursor: pointer; 42003 42004 -webkit-appearance: none; ${/* Hides the slider so that custom slider can be made */ 42005""} 42006 -webkit-tap-highlight-color: transparent; 42007 background: transparent; ${/* Otherwise white in Chrome */ 42008""} 42009 margin: 0; 42010 z-index: 1; 42011 } 42012 42013 @media (hover: hover) { 42014 #range { 42015 bottom: var(--media-time-range-hover-bottom, -5px); 42016 height: var(--media-time-range-hover-height, max(100% + 5px, 20px)); 42017 } 42018 } 42019 42020 ${/* Special styling for WebKit/Blink */ 42021""} 42022 ${/* Make thumb width/height small so it has no effect on range click position. */ 42023""} 42024 #range::-webkit-slider-thumb { 42025 -webkit-appearance: none; 42026 background: transparent; 42027 width: .1px; 42028 height: .1px; 42029 } 42030 42031 ${/* The thumb is not positioned relative to the track in Firefox */ 42032""} 42033 #range::-moz-range-thumb { 42034 background: transparent; 42035 border: transparent; 42036 width: .1px; 42037 height: .1px; 42038 } 42039 42040 #appearance { 42041 height: var(--media-range-track-height, 4px); 42042 display: flex; 42043 flex-direction: column; 42044 justify-content: center; 42045 width: 100%; 42046 position: absolute; 42047 ${/* Required for Safari to stop glitching track height on hover */ 42048""} 42049 will-change: transform; 42050 } 42051 42052 #track { 42053 background: var(--media-range-track-background, rgb(255 255 255 / .2)); 42054 border-radius: var(--media-range-track-border-radius, 1px); 42055 border: var(--media-range-track-border, none); 42056 outline: var(--media-range-track-outline); 42057 outline-offset: var(--media-range-track-outline-offset); 42058 backdrop-filter: var(--media-range-track-backdrop-filter); 42059 -webkit-backdrop-filter: var(--media-range-track-backdrop-filter); 42060 box-shadow: var(--media-range-track-box-shadow, none); 42061 position: absolute; 42062 width: 100%; 42063 height: 100%; 42064 overflow: hidden; 42065 } 42066 42067 #progress, 42068 #pointer { 42069 position: absolute; 42070 height: 100%; 42071 will-change: width; 42072 } 42073 42074 #progress { 42075 background: var(--media-range-bar-color, var(--media-primary-color, rgb(238 238 238))); 42076 transition: var(--media-range-track-transition); 42077 } 42078 42079 #pointer { 42080 background: var(--media-range-track-pointer-background); 42081 border-right: var(--media-range-track-pointer-border-right); 42082 transition: visibility .25s, opacity .25s; 42083 visibility: hidden; 42084 opacity: 0; 42085 } 42086 42087 @media (hover: hover) { 42088 :host(:hover) #pointer { 42089 transition: visibility .5s, opacity .5s; 42090 visibility: visible; 42091 opacity: 1; 42092 } 42093 } 42094 42095 #thumb { 42096 width: var(--media-range-thumb-width, 10px); 42097 height: var(--media-range-thumb-height, 10px); 42098 margin-left: calc(var(--media-range-thumb-width, 10px) / -2); 42099 border: var(--media-range-thumb-border, none); 42100 border-radius: var(--media-range-thumb-border-radius, 10px); 42101 background: var(--media-range-thumb-background, var(--media-primary-color, rgb(238 238 238))); 42102 box-shadow: var(--media-range-thumb-box-shadow, 1px 1px 1px transparent); 42103 transition: var(--media-range-thumb-transition); 42104 transform: var(--media-range-thumb-transform, none); 42105 opacity: var(--media-range-thumb-opacity, 1); 42106 position: absolute; 42107 left: 0; 42108 cursor: pointer; 42109 } 42110 42111 :host([disabled]) #thumb { 42112 background-color: #777; 42113 } 42114 42115 .segments #appearance { 42116 height: var(--media-range-segment-hover-height, 7px); 42117 } 42118 42119 #track { 42120 clip-path: url(#segments-clipping); 42121 } 42122 42123 #segments { 42124 --segments-gap: var(--media-range-segments-gap, 2px); 42125 position: absolute; 42126 width: 100%; 42127 height: 100%; 42128 } 42129 42130 #segments-clipping { 42131 transform: translateX(calc(var(--segments-gap) / 2)); 42132 } 42133 42134 #segments-clipping:empty { 42135 display: none; 42136 } 42137 42138 #segments-clipping rect { 42139 height: var(--media-range-track-height, 4px); 42140 y: calc((var(--media-range-segment-hover-height, 7px) - var(--media-range-track-height, 4px)) / 2); 42141 transition: var(--media-range-segment-transition, transform .1s ease-in-out); 42142 transform: var(--media-range-segment-transform, scaleY(1)); 42143 transform-origin: center; 42144 } 42145 </style> 42146 <div id="leftgap"></div> 42147 <div id="container"> 42148 <div id="startpoint"></div> 42149 <div id="endpoint"></div> 42150 <div id="appearance"> 42151 <div id="track" part="track"> 42152 <div id="pointer"></div> 42153 <div id="progress" part="progress"></div> 42154 </div> 42155 <div id="thumb" part="thumb"></div> 42156 <svg id="segments"><clipPath id="segments-clipping"></clipPath></svg> 42157 </div> 42158 <input id="range" type="range" min="0" max="1" step="any" value="0"> 42159 </div> 42160 <div id="rightgap"></div> 42161`; 42162var MediaChromeRange = class extends GlobalThis.HTMLElement { 42163 constructor() { 42164 super(); 42165 __privateAdd7(this, _updateActiveSegment); 42166 __privateAdd7(this, _enableUserEvents); 42167 __privateAdd7(this, _disableUserEvents); 42168 __privateAdd7(this, _handlePointerDown); 42169 __privateAdd7(this, _handlePointerEnter); 42170 __privateAdd7(this, _handlePointerUp2); 42171 __privateAdd7(this, _handlePointerLeave); 42172 __privateAdd7(this, _handlePointerMove2); 42173 __privateAdd7(this, _mediaController3, void 0); 42174 __privateAdd7(this, _isInputTarget, void 0); 42175 __privateAdd7(this, _startpoint, void 0); 42176 __privateAdd7(this, _endpoint, void 0); 42177 __privateAdd7(this, _cssRules, {}); 42178 __privateAdd7(this, _segments, []); 42179 __privateAdd7(this, _onFocusIn, () => { 42180 if (this.range.matches(":focus-visible")) { 42181 const { style } = getOrInsertCSSRule(this.shadowRoot, ":host"); 42182 style.setProperty( 42183 "--_focus-visible-box-shadow", 42184 "var(--_focus-box-shadow)" 42185 ); 42186 } 42187 }); 42188 __privateAdd7(this, _onFocusOut, () => { 42189 const { style } = getOrInsertCSSRule(this.shadowRoot, ":host"); 42190 style.removeProperty("--_focus-visible-box-shadow"); 42191 }); 42192 __privateAdd7(this, _updateComputedStyles, () => { 42193 const clipping = this.shadowRoot.querySelector("#segments-clipping"); 42194 if (clipping) 42195 clipping.parentNode.append(clipping); 42196 }); 42197 if (!this.shadowRoot) { 42198 this.attachShadow({ mode: "open" }); 42199 this.shadowRoot.appendChild(template5.content.cloneNode(true)); 42200 } 42201 this.container = this.shadowRoot.querySelector("#container"); 42202 __privateSet7(this, _startpoint, this.shadowRoot.querySelector("#startpoint")); 42203 __privateSet7(this, _endpoint, this.shadowRoot.querySelector("#endpoint")); 42204 this.range = this.shadowRoot.querySelector("#range"); 42205 this.appearance = this.shadowRoot.querySelector("#appearance"); 42206 } 42207 static get observedAttributes() { 42208 return [ 42209 "disabled", 42210 "aria-disabled", 42211 MediaStateReceiverAttributes.MEDIA_CONTROLLER 42212 ]; 42213 } 42214 attributeChangedCallback(attrName, oldValue, newValue) { 42215 var _a3, _b, _c, _d, _e5; 42216 if (attrName === MediaStateReceiverAttributes.MEDIA_CONTROLLER) { 42217 if (oldValue) { 42218 (_b = (_a3 = __privateGet7(this, _mediaController3)) == null ? void 0 : _a3.unassociateElement) == null ? void 0 : _b.call(_a3, this); 42219 __privateSet7(this, _mediaController3, null); 42220 } 42221 if (newValue && this.isConnected) { 42222 __privateSet7(this, _mediaController3, (_c = this.getRootNode()) == null ? void 0 : _c.getElementById(newValue)); 42223 (_e5 = (_d = __privateGet7(this, _mediaController3)) == null ? void 0 : _d.associateElement) == null ? void 0 : _e5.call(_d, this); 42224 } 42225 } else if (attrName === "disabled" || attrName === "aria-disabled" && oldValue !== newValue) { 42226 if (newValue == null) { 42227 this.range.removeAttribute(attrName); 42228 __privateMethod5(this, _enableUserEvents, enableUserEvents_fn).call(this); 42229 } else { 42230 this.range.setAttribute(attrName, newValue); 42231 __privateMethod5(this, _disableUserEvents, disableUserEvents_fn).call(this); 42232 } 42233 } 42234 } 42235 connectedCallback() { 42236 var _a3, _b, _c; 42237 const { style } = getOrInsertCSSRule(this.shadowRoot, ":host"); 42238 style.setProperty( 42239 "display", 42240 `var(--media-control-display, var(--${this.localName}-display, inline-flex))` 42241 ); 42242 __privateGet7(this, _cssRules).pointer = getOrInsertCSSRule(this.shadowRoot, "#pointer"); 42243 __privateGet7(this, _cssRules).progress = getOrInsertCSSRule(this.shadowRoot, "#progress"); 42244 __privateGet7(this, _cssRules).thumb = getOrInsertCSSRule(this.shadowRoot, "#thumb"); 42245 __privateGet7(this, _cssRules).activeSegment = getOrInsertCSSRule( 42246 this.shadowRoot, 42247 "#segments-clipping rect:nth-child(0)" 42248 ); 42249 const mediaControllerId = this.getAttribute( 42250 MediaStateReceiverAttributes.MEDIA_CONTROLLER 42251 ); 42252 if (mediaControllerId) { 42253 __privateSet7(this, _mediaController3, (_a3 = this.getRootNode()) == null ? void 0 : _a3.getElementById( 42254 mediaControllerId 42255 )); 42256 (_c = (_b = __privateGet7(this, _mediaController3)) == null ? void 0 : _b.associateElement) == null ? void 0 : _c.call(_b, this); 42257 } 42258 this.updateBar(); 42259 this.shadowRoot.addEventListener("focusin", __privateGet7(this, _onFocusIn)); 42260 this.shadowRoot.addEventListener("focusout", __privateGet7(this, _onFocusOut)); 42261 __privateMethod5(this, _enableUserEvents, enableUserEvents_fn).call(this); 42262 observeResize(this.container, __privateGet7(this, _updateComputedStyles)); 42263 } 42264 disconnectedCallback() { 42265 var _a3, _b; 42266 __privateMethod5(this, _disableUserEvents, disableUserEvents_fn).call(this); 42267 (_b = (_a3 = __privateGet7(this, _mediaController3)) == null ? void 0 : _a3.unassociateElement) == null ? void 0 : _b.call(_a3, this); 42268 __privateSet7(this, _mediaController3, null); 42269 this.shadowRoot.removeEventListener("focusin", __privateGet7(this, _onFocusIn)); 42270 this.shadowRoot.removeEventListener("focusout", __privateGet7(this, _onFocusOut)); 42271 unobserveResize(this.container, __privateGet7(this, _updateComputedStyles)); 42272 } 42273 updatePointerBar(evt) { 42274 var _a3; 42275 (_a3 = __privateGet7(this, _cssRules).pointer) == null ? void 0 : _a3.style.setProperty( 42276 "width", 42277 `${this.getPointerRatio(evt) * 100}%` 42278 ); 42279 } 42280 updateBar() { 42281 var _a3, _b; 42282 const rangePercent = this.range.valueAsNumber * 100; 42283 (_a3 = __privateGet7(this, _cssRules).progress) == null ? void 0 : _a3.style.setProperty("width", `${rangePercent}%`); 42284 (_b = __privateGet7(this, _cssRules).thumb) == null ? void 0 : _b.style.setProperty("left", `${rangePercent}%`); 42285 } 42286 updateSegments(segments) { 42287 const clipping = this.shadowRoot.querySelector("#segments-clipping"); 42288 clipping.textContent = ""; 42289 this.container.classList.toggle("segments", !!(segments == null ? void 0 : segments.length)); 42290 if (!(segments == null ? void 0 : segments.length)) 42291 return; 42292 const normalized = [ 42293 .../* @__PURE__ */ new Set([ 42294 +this.range.min, 42295 ...segments.flatMap((s) => [s.start, s.end]), 42296 +this.range.max 42297 ]) 42298 ]; 42299 __privateSet7(this, _segments, [...normalized]); 42300 const lastMarker = normalized.pop(); 42301 for (const [i3, marker] of normalized.entries()) { 42302 const [isFirst, isLast] = [i3 === 0, i3 === normalized.length - 1]; 42303 const x2 = isFirst ? "calc(var(--segments-gap) / -1)" : `${marker * 100}%`; 42304 const x22 = isLast ? lastMarker : normalized[i3 + 1]; 42305 const width = `calc(${(x22 - marker) * 100}%${isFirst || isLast ? "" : ` - var(--segments-gap)`})`; 42306 const segmentEl = Document2.createElementNS( 42307 "http://www.w3.org/2000/svg", 42308 "rect" 42309 ); 42310 const cssRule = getOrInsertCSSRule( 42311 this.shadowRoot, 42312 `#segments-clipping rect:nth-child(${i3 + 1})` 42313 ); 42314 cssRule.style.setProperty("x", x2); 42315 cssRule.style.setProperty("width", width); 42316 clipping.append(segmentEl); 42317 } 42318 } 42319 getPointerRatio(evt) { 42320 const pointerRatio = getPointProgressOnLine( 42321 evt.clientX, 42322 evt.clientY, 42323 __privateGet7(this, _startpoint).getBoundingClientRect(), 42324 __privateGet7(this, _endpoint).getBoundingClientRect() 42325 ); 42326 return Math.max(0, Math.min(1, pointerRatio)); 42327 } 42328 get dragging() { 42329 return this.hasAttribute("dragging"); 42330 } 42331 handleEvent(evt) { 42332 switch (evt.type) { 42333 case "pointermove": 42334 __privateMethod5(this, _handlePointerMove2, handlePointerMove_fn2).call(this, evt); 42335 break; 42336 case "input": 42337 this.updateBar(); 42338 break; 42339 case "pointerenter": 42340 __privateMethod5(this, _handlePointerEnter, handlePointerEnter_fn).call(this, evt); 42341 break; 42342 case "pointerdown": 42343 __privateMethod5(this, _handlePointerDown, handlePointerDown_fn).call(this, evt); 42344 break; 42345 case "pointerup": 42346 __privateMethod5(this, _handlePointerUp2, handlePointerUp_fn2).call(this); 42347 break; 42348 case "pointerleave": 42349 __privateMethod5(this, _handlePointerLeave, handlePointerLeave_fn).call(this); 42350 break; 42351 } 42352 } 42353 get keysUsed() { 42354 return ["ArrowUp", "ArrowRight", "ArrowDown", "ArrowLeft"]; 42355 } 42356}; 42357_mediaController3 = /* @__PURE__ */ new WeakMap(); 42358_isInputTarget = /* @__PURE__ */ new WeakMap(); 42359_startpoint = /* @__PURE__ */ new WeakMap(); 42360_endpoint = /* @__PURE__ */ new WeakMap(); 42361_cssRules = /* @__PURE__ */ new WeakMap(); 42362_segments = /* @__PURE__ */ new WeakMap(); 42363_onFocusIn = /* @__PURE__ */ new WeakMap(); 42364_onFocusOut = /* @__PURE__ */ new WeakMap(); 42365_updateComputedStyles = /* @__PURE__ */ new WeakMap(); 42366_updateActiveSegment = /* @__PURE__ */ new WeakSet(); 42367updateActiveSegment_fn = function(evt) { 42368 const rule = __privateGet7(this, _cssRules).activeSegment; 42369 if (!rule) 42370 return; 42371 const pointerRatio = this.getPointerRatio(evt); 42372 const segmentIndex = __privateGet7(this, _segments).findIndex((start, i3, arr) => { 42373 const end = arr[i3 + 1]; 42374 return end != null && pointerRatio >= start && pointerRatio <= end; 42375 }); 42376 const selectorText = `#segments-clipping rect:nth-child(${segmentIndex + 1})`; 42377 if (rule.selectorText != selectorText || !rule.style.transform) { 42378 rule.selectorText = selectorText; 42379 rule.style.setProperty( 42380 "transform", 42381 "var(--media-range-segment-hover-transform, scaleY(2))" 42382 ); 42383 } 42384}; 42385_enableUserEvents = /* @__PURE__ */ new WeakSet(); 42386enableUserEvents_fn = function() { 42387 if (this.hasAttribute("disabled")) 42388 return; 42389 this.addEventListener("input", this); 42390 this.addEventListener("pointerdown", this); 42391 this.addEventListener("pointerenter", this); 42392}; 42393_disableUserEvents = /* @__PURE__ */ new WeakSet(); 42394disableUserEvents_fn = function() { 42395 var _a3, _b; 42396 this.removeEventListener("input", this); 42397 this.removeEventListener("pointerdown", this); 42398 this.removeEventListener("pointerenter", this); 42399 (_a3 = GlobalThis.window) == null ? void 0 : _a3.removeEventListener("pointerup", this); 42400 (_b = GlobalThis.window) == null ? void 0 : _b.removeEventListener("pointermove", this); 42401}; 42402_handlePointerDown = /* @__PURE__ */ new WeakSet(); 42403handlePointerDown_fn = function(evt) { 42404 var _a3; 42405 __privateSet7(this, _isInputTarget, evt.composedPath().includes(this.range)); 42406 (_a3 = GlobalThis.window) == null ? void 0 : _a3.addEventListener("pointerup", this); 42407}; 42408_handlePointerEnter = /* @__PURE__ */ new WeakSet(); 42409handlePointerEnter_fn = function(evt) { 42410 var _a3; 42411 if (evt.pointerType !== "mouse") 42412 __privateMethod5(this, _handlePointerDown, handlePointerDown_fn).call(this, evt); 42413 this.addEventListener("pointerleave", this); 42414 (_a3 = GlobalThis.window) == null ? void 0 : _a3.addEventListener("pointermove", this); 42415}; 42416_handlePointerUp2 = /* @__PURE__ */ new WeakSet(); 42417handlePointerUp_fn2 = function() { 42418 var _a3; 42419 (_a3 = GlobalThis.window) == null ? void 0 : _a3.removeEventListener("pointerup", this); 42420 this.toggleAttribute("dragging", false); 42421 this.range.disabled = this.hasAttribute("disabled"); 42422}; 42423_handlePointerLeave = /* @__PURE__ */ new WeakSet(); 42424handlePointerLeave_fn = function() { 42425 var _a3, _b; 42426 this.removeEventListener("pointerleave", this); 42427 (_a3 = GlobalThis.window) == null ? void 0 : _a3.removeEventListener("pointermove", this); 42428 this.toggleAttribute("dragging", false); 42429 this.range.disabled = this.hasAttribute("disabled"); 42430 (_b = __privateGet7(this, _cssRules).activeSegment) == null ? void 0 : _b.style.removeProperty("transform"); 42431}; 42432_handlePointerMove2 = /* @__PURE__ */ new WeakSet(); 42433handlePointerMove_fn2 = function(evt) { 42434 this.toggleAttribute( 42435 "dragging", 42436 evt.buttons === 1 || evt.pointerType !== "mouse" 42437 ); 42438 this.updatePointerBar(evt); 42439 __privateMethod5(this, _updateActiveSegment, updateActiveSegment_fn).call(this, evt); 42440 if (this.dragging && (evt.pointerType !== "mouse" || !__privateGet7(this, _isInputTarget))) { 42441 this.range.disabled = true; 42442 this.range.valueAsNumber = this.getPointerRatio(evt); 42443 this.range.dispatchEvent( 42444 new Event("input", { bubbles: true, composed: true }) 42445 ); 42446 } 42447}; 42448if (!GlobalThis.customElements.get("media-chrome-range")) { 42449 GlobalThis.customElements.define("media-chrome-range", MediaChromeRange); 42450} 42451
vendor: 3,536 bytes, lines 42452-42549
42452// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-control-bar.js 42453var __accessCheck8 = (obj, member, msg) => { 42454 if (!member.has(obj)) 42455 throw TypeError("Cannot " + msg); 42456}; 42457var __privateGet8 = (obj, member, getter) => { 42458 __accessCheck8(obj, member, "read from private field"); 42459 return getter ? getter.call(obj) : member.get(obj); 42460}; 42461var __privateAdd8 = (obj, member, value) => { 42462 if (member.has(obj)) 42463 throw TypeError("Cannot add the same private member more than once"); 42464 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 42465}; 42466var __privateSet8 = (obj, member, value, setter) => { 42467 __accessCheck8(obj, member, "write to private field"); 42468 setter ? setter.call(obj, value) : member.set(obj, value); 42469 return value; 42470}; 42471var _mediaController4; 42472var template6 = Document2.createElement("template"); 42473template6.innerHTML = /*html*/ 42474` 42475 <style> 42476 :host { 42477 ${/* Need position to display above video for some reason */ 42478""} 42479 box-sizing: border-box; 42480 display: var(--media-control-display, var(--media-control-bar-display, inline-flex)); 42481 color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238))); 42482 --media-loading-indicator-icon-height: 44px; 42483 } 42484 42485 ::slotted(media-time-range), 42486 ::slotted(media-volume-range) { 42487 min-height: 100%; 42488 } 42489 42490 ::slotted(media-time-range), 42491 ::slotted(media-clip-selector) { 42492 flex-grow: 1; 42493 } 42494 42495 ::slotted([role="menu"]) { 42496 position: absolute; 42497 } 42498 </style> 42499 42500 <slot></slot> 42501`; 42502var MediaControlBar = class extends GlobalThis.HTMLElement { 42503 constructor() { 42504 super(); 42505 __privateAdd8(this, _mediaController4, void 0); 42506 if (!this.shadowRoot) { 42507 this.attachShadow({ mode: "open" }); 42508 this.shadowRoot.appendChild(template6.content.cloneNode(true)); 42509 } 42510 } 42511 static get observedAttributes() { 42512 return [MediaStateReceiverAttributes.MEDIA_CONTROLLER]; 42513 } 42514 attributeChangedCallback(attrName, oldValue, newValue) { 42515 var _a3, _b, _c, _d, _e5; 42516 if (attrName === MediaStateReceiverAttributes.MEDIA_CONTROLLER) { 42517 if (oldValue) { 42518 (_b = (_a3 = __privateGet8(this, _mediaController4)) == null ? void 0 : _a3.unassociateElement) == null ? void 0 : _b.call(_a3, this); 42519 __privateSet8(this, _mediaController4, null); 42520 } 42521 if (newValue && this.isConnected) { 42522 __privateSet8(this, _mediaController4, (_c = this.getRootNode()) == null ? void 0 : _c.getElementById(newValue)); 42523 (_e5 = (_d = __privateGet8(this, _mediaController4)) == null ? void 0 : _d.associateElement) == null ? void 0 : _e5.call(_d, this); 42524 } 42525 } 42526 } 42527 connectedCallback() { 42528 var _a3, _b, _c; 42529 const mediaControllerId = this.getAttribute( 42530 MediaStateReceiverAttributes.MEDIA_CONTROLLER 42531 ); 42532 if (mediaControllerId) { 42533 __privateSet8(this, _mediaController4, (_a3 = this.getRootNode()) == null ? void 0 : _a3.getElementById( 42534 mediaControllerId 42535 )); 42536 (_c = (_b = __privateGet8(this, _mediaController4)) == null ? void 0 : _b.associateElement) == null ? void 0 : _c.call(_b, this); 42537 } 42538 } 42539 disconnectedCallback() { 42540 var _a3, _b; 42541 (_b = (_a3 = __privateGet8(this, _mediaController4)) == null ? void 0 : _a3.unassociateElement) == null ? void 0 : _b.call(_a3, this); 42542 __privateSet8(this, _mediaController4, null); 42543 } 42544}; 42545_mediaController4 = /* @__PURE__ */ new WeakMap(); 42546if (!GlobalThis.customElements.get("media-control-bar")) { 42547 GlobalThis.customElements.define("media-control-bar", MediaControlBar); 42548} 42549
vendor: 4,274 bytes, lines 42550-42665
42550// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-text-display.js 42551var __accessCheck9 = (obj, member, msg) => { 42552 if (!member.has(obj)) 42553 throw TypeError("Cannot " + msg); 42554}; 42555var __privateGet9 = (obj, member, getter) => { 42556 __accessCheck9(obj, member, "read from private field"); 42557 return getter ? getter.call(obj) : member.get(obj); 42558}; 42559var __privateAdd9 = (obj, member, value) => { 42560 if (member.has(obj)) 42561 throw TypeError("Cannot add the same private member more than once"); 42562 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 42563}; 42564var __privateSet9 = (obj, member, value, setter) => { 42565 __accessCheck9(obj, member, "write to private field"); 42566 setter ? setter.call(obj, value) : member.set(obj, value); 42567 return value; 42568}; 42569var _mediaController5; 42570var template7 = Document2.createElement("template"); 42571template7.innerHTML = /*html*/ 42572` 42573 <style> 42574 :host { 42575 font: var(--media-font, 42576 var(--media-font-weight, normal) 42577 var(--media-font-size, 14px) / 42578 var(--media-text-content-height, var(--media-control-height, 24px)) 42579 var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif)); 42580 color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238))); 42581 background: var(--media-text-background, var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)))); 42582 padding: var(--media-control-padding, 10px); 42583 display: inline-flex; 42584 justify-content: center; 42585 align-items: center; 42586 vertical-align: middle; 42587 box-sizing: border-box; 42588 text-align: center; 42589 pointer-events: auto; 42590 } 42591 42592 ${/* 42593 Only show outline when keyboard focusing. 42594 https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo 42595*/ 42596""} 42597 :host(:focus-visible) { 42598 box-shadow: inset 0 0 0 2px rgb(27 127 204 / .9); 42599 outline: 0; 42600 } 42601 42602 ${/* 42603* hide default focus ring, particularly when using mouse 42604*/ 42605""} 42606 :host(:where(:focus)) { 42607 box-shadow: none; 42608 outline: 0; 42609 } 42610 </style> 42611 <slot></slot> 42612`; 42613var MediaTextDisplay = class extends GlobalThis.HTMLElement { 42614 constructor() { 42615 super(); 42616 __privateAdd9(this, _mediaController5, void 0); 42617 if (!this.shadowRoot) { 42618 this.attachShadow({ mode: "open" }); 42619 this.shadowRoot.appendChild(template7.content.cloneNode(true)); 42620 } 42621 } 42622 static get observedAttributes() { 42623 return [MediaStateReceiverAttributes.MEDIA_CONTROLLER]; 42624 } 42625 attributeChangedCallback(attrName, oldValue, newValue) { 42626 var _a3, _b, _c, _d, _e5; 42627 if (attrName === MediaStateReceiverAttributes.MEDIA_CONTROLLER) { 42628 if (oldValue) { 42629 (_b = (_a3 = __privateGet9(this, _mediaController5)) == null ? void 0 : _a3.unassociateElement) == null ? void 0 : _b.call(_a3, this); 42630 __privateSet9(this, _mediaController5, null); 42631 } 42632 if (newValue && this.isConnected) { 42633 __privateSet9(this, _mediaController5, (_c = this.getRootNode()) == null ? void 0 : _c.getElementById(newValue)); 42634 (_e5 = (_d = __privateGet9(this, _mediaController5)) == null ? void 0 : _d.associateElement) == null ? void 0 : _e5.call(_d, this); 42635 } 42636 } 42637 } 42638 connectedCallback() { 42639 var _a3, _b, _c; 42640 const { style } = getOrInsertCSSRule(this.shadowRoot, ":host"); 42641 style.setProperty( 42642 "display", 42643 `var(--media-control-display, var(--${this.localName}-display, inline-flex))` 42644 ); 42645 const mediaControllerId = this.getAttribute( 42646 MediaStateReceiverAttributes.MEDIA_CONTROLLER 42647 ); 42648 if (mediaControllerId) { 42649 __privateSet9(this, _mediaController5, (_a3 = this.getRootNode()) == null ? void 0 : _a3.getElementById( 42650 mediaControllerId 42651 )); 42652 (_c = (_b = __privateGet9(this, _mediaController5)) == null ? void 0 : _b.associateElement) == null ? void 0 : _c.call(_b, this); 42653 } 42654 } 42655 disconnectedCallback() { 42656 var _a3, _b; 42657 (_b = (_a3 = __privateGet9(this, _mediaController5)) == null ? void 0 : _a3.unassociateElement) == null ? void 0 : _b.call(_a3, this); 42658 __privateSet9(this, _mediaController5, null); 42659 } 42660}; 42661_mediaController5 = /* @__PURE__ */ new WeakMap(); 42662if (!GlobalThis.customElements.get("media-text-display")) { 42663 GlobalThis.customElements.define("media-text-display", MediaTextDisplay); 42664} 42665
vendor: 1,897 bytes, lines 42666-42719
42666// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-duration-display.js 42667var __accessCheck10 = (obj, member, msg) => { 42668 if (!member.has(obj)) 42669 throw TypeError("Cannot " + msg); 42670}; 42671var __privateGet10 = (obj, member, getter) => { 42672 __accessCheck10(obj, member, "read from private field"); 42673 return getter ? getter.call(obj) : member.get(obj); 42674}; 42675var __privateAdd10 = (obj, member, value) => { 42676 if (member.has(obj)) 42677 throw TypeError("Cannot add the same private member more than once"); 42678 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 42679}; 42680var __privateSet10 = (obj, member, value, setter) => { 42681 __accessCheck10(obj, member, "write to private field"); 42682 setter ? setter.call(obj, value) : member.set(obj, value); 42683 return value; 42684}; 42685var _slot; 42686var MediaDurationDisplay = class extends MediaTextDisplay { 42687 constructor() { 42688 super(); 42689 __privateAdd10(this, _slot, void 0); 42690 __privateSet10(this, _slot, this.shadowRoot.querySelector("slot")); 42691 __privateGet10(this, _slot).textContent = formatTime(0); 42692 } 42693 static get observedAttributes() { 42694 return [...super.observedAttributes, MediaUIAttributes.MEDIA_DURATION]; 42695 } 42696 attributeChangedCallback(attrName, oldValue, newValue) { 42697 if (attrName === MediaUIAttributes.MEDIA_DURATION) { 42698 __privateGet10(this, _slot).textContent = formatTime(+newValue); 42699 } 42700 super.attributeChangedCallback(attrName, oldValue, newValue); 42701 } 42702 /** 42703 * @type {number | undefined} In seconds 42704 */ 42705 get mediaDuration() { 42706 return getNumericAttr(this, MediaUIAttributes.MEDIA_DURATION); 42707 } 42708 set mediaDuration(time) { 42709 setNumericAttr(this, MediaUIAttributes.MEDIA_DURATION, time); 42710 } 42711}; 42712_slot = /* @__PURE__ */ new WeakMap(); 42713if (!GlobalThis.customElements.get("media-duration-display")) { 42714 GlobalThis.customElements.define( 42715 "media-duration-display", 42716 MediaDurationDisplay 42717 ); 42718} 42719
vendor: 3,378 bytes, lines 42720-42815
42720// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-fullscreen-button.js 42721var enterFullscreenIcon = `<svg aria-hidden="true" viewBox="0 0 26 24"> 42722 <path d="M16 3v2.5h3.5V9H22V3h-6ZM4 9h2.5V5.5H10V3H4v6Zm15.5 9.5H16V21h6v-6h-2.5v3.5ZM6.5 15H4v6h6v-2.5H6.5V15Z"/> 42723</svg>`; 42724var exitFullscreenIcon = `<svg aria-hidden="true" viewBox="0 0 26 24"> 42725 <path d="M18.5 6.5V3H16v6h6V6.5h-3.5ZM16 21h2.5v-3.5H22V15h-6v6ZM4 17.5h3.5V21H10v-6H4v2.5Zm3.5-11H4V9h6V3H7.5v3.5Z"/> 42726</svg>`; 42727var slotTemplate4 = Document2.createElement("template"); 42728slotTemplate4.innerHTML = /*html*/ 42729` 42730 <style> 42731 :host([${MediaUIAttributes.MEDIA_IS_FULLSCREEN}]) slot[name=icon] slot:not([name=exit]) { 42732 display: none !important; 42733 } 42734 42735 ${/* Double negative, but safer if display doesn't equal 'block' */ 42736""} 42737 :host(:not([${MediaUIAttributes.MEDIA_IS_FULLSCREEN}])) slot[name=icon] slot:not([name=enter]) { 42738 display: none !important; 42739 } 42740 42741 :host([${MediaUIAttributes.MEDIA_IS_FULLSCREEN}]) slot[name=tooltip-enter], 42742 :host(:not([${MediaUIAttributes.MEDIA_IS_FULLSCREEN}])) slot[name=tooltip-exit] { 42743 display: none; 42744 } 42745 </style> 42746 42747 <slot name="icon"> 42748 <slot name="enter">${enterFullscreenIcon}</slot> 42749 <slot name="exit">${exitFullscreenIcon}</slot> 42750 </slot> 42751`; 42752var tooltipContent4 = ( 42753 /*html*/ 42754 ` 42755 <slot name="tooltip-enter">${tooltipLabels.ENTER_FULLSCREEN}</slot> 42756 <slot name="tooltip-exit">${tooltipLabels.EXIT_FULLSCREEN}</slot> 42757` 42758); 42759var updateAriaLabel3 = (el) => { 42760 const label = el.mediaIsFullscreen ? verbs.EXIT_FULLSCREEN() : verbs.ENTER_FULLSCREEN(); 42761 el.setAttribute("aria-label", label); 42762}; 42763var MediaFullscreenButton = class extends MediaChromeButton { 42764 static get observedAttributes() { 42765 return [ 42766 ...super.observedAttributes, 42767 MediaUIAttributes.MEDIA_IS_FULLSCREEN, 42768 MediaUIAttributes.MEDIA_FULLSCREEN_UNAVAILABLE 42769 ]; 42770 } 42771 constructor(options2 = {}) { 42772 super({ slotTemplate: slotTemplate4, tooltipContent: tooltipContent4, ...options2 }); 42773 } 42774 connectedCallback() { 42775 super.connectedCallback(); 42776 updateAriaLabel3(this); 42777 } 42778 attributeChangedCallback(attrName, oldValue, newValue) { 42779 super.attributeChangedCallback(attrName, oldValue, newValue); 42780 if (attrName === MediaUIAttributes.MEDIA_IS_FULLSCREEN) { 42781 updateAriaLabel3(this); 42782 } 42783 } 42784 /** 42785 * @type {string | undefined} Fullscreen unavailability state 42786 */ 42787 get mediaFullscreenUnavailable() { 42788 return getStringAttr(this, MediaUIAttributes.MEDIA_FULLSCREEN_UNAVAILABLE); 42789 } 42790 set mediaFullscreenUnavailable(value) { 42791 setStringAttr(this, MediaUIAttributes.MEDIA_FULLSCREEN_UNAVAILABLE, value); 42792 } 42793 /** 42794 * @type {boolean} Whether fullscreen is available 42795 */ 42796 get mediaIsFullscreen() { 42797 return getBooleanAttr(this, MediaUIAttributes.MEDIA_IS_FULLSCREEN); 42798 } 42799 set mediaIsFullscreen(value) { 42800 setBooleanAttr(this, MediaUIAttributes.MEDIA_IS_FULLSCREEN, value); 42801 } 42802 handleClick() { 42803 const eventName = this.mediaIsFullscreen ? MediaUIEvents.MEDIA_EXIT_FULLSCREEN_REQUEST : MediaUIEvents.MEDIA_ENTER_FULLSCREEN_REQUEST; 42804 this.dispatchEvent( 42805 new GlobalThis.CustomEvent(eventName, { composed: true, bubbles: true }) 42806 ); 42807 } 42808}; 42809if (!GlobalThis.customElements.get("media-fullscreen-button")) { 42810 GlobalThis.customElements.define( 42811 "media-fullscreen-button", 42812 MediaFullscreenButton 42813 ); 42814} 42815
vendor: 3,334 bytes, lines 42816-42916
42816// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-live-button.js 42817var { MEDIA_TIME_IS_LIVE, MEDIA_PAUSED } = MediaUIAttributes; 42818var { MEDIA_SEEK_TO_LIVE_REQUEST, MEDIA_PLAY_REQUEST } = MediaUIEvents; 42819var indicatorSVG = '<svg viewBox="0 0 6 12"><circle cx="3" cy="6" r="2"></circle></svg>'; 42820var slotTemplate5 = Document2.createElement("template"); 42821slotTemplate5.innerHTML = /*html*/ 42822` 42823 <style> 42824 :host { --media-tooltip-display: none; } 42825 42826 slot[name=indicator] > *, 42827 :host ::slotted([slot=indicator]) { 42828 ${/* Override styles for icon-only buttons */ 42829""} 42830 min-width: auto; 42831 fill: var(--media-live-button-icon-color, rgb(140, 140, 140)); 42832 color: var(--media-live-button-icon-color, rgb(140, 140, 140)); 42833 } 42834 42835 :host([${MEDIA_TIME_IS_LIVE}]:not([${MEDIA_PAUSED}])) slot[name=indicator] > *, 42836 :host([${MEDIA_TIME_IS_LIVE}]:not([${MEDIA_PAUSED}])) ::slotted([slot=indicator]) { 42837 fill: var(--media-live-button-indicator-color, rgb(255, 0, 0)); 42838 color: var(--media-live-button-indicator-color, rgb(255, 0, 0)); 42839 } 42840 42841 :host([${MEDIA_TIME_IS_LIVE}]:not([${MEDIA_PAUSED}])) { 42842 cursor: not-allowed; 42843 } 42844 42845 </style> 42846 42847 <slot name="indicator">${indicatorSVG}</slot> 42848 ${/* 42849 A new line between spacer and text creates inconsistent spacing 42850 between slotted items and default slots. 42851*/ 42852""} 42853 <slot name="spacer"> </slot><slot name="text">LIVE</slot> 42854`; 42855var updateAriaAttributes = (el) => { 42856 const isPausedOrNotLive = el.mediaPaused || !el.mediaTimeIsLive; 42857 const label = isPausedOrNotLive ? verbs.SEEK_LIVE() : verbs.PLAYING_LIVE(); 42858 el.setAttribute("aria-label", label); 42859 isPausedOrNotLive ? el.removeAttribute("aria-disabled") : el.setAttribute("aria-disabled", "true"); 42860}; 42861var MediaLiveButton = class extends MediaChromeButton { 42862 static get observedAttributes() { 42863 return [...super.observedAttributes, MEDIA_PAUSED, MEDIA_TIME_IS_LIVE]; 42864 } 42865 constructor(options2 = {}) { 42866 super({ slotTemplate: slotTemplate5, ...options2 }); 42867 } 42868 connectedCallback() { 42869 updateAriaAttributes(this); 42870 super.connectedCallback(); 42871 } 42872 attributeChangedCallback(attrName, oldValue, newValue) { 42873 super.attributeChangedCallback(attrName, oldValue, newValue); 42874 updateAriaAttributes(this); 42875 } 42876 /** 42877 * @type {boolean} Is the media paused 42878 */ 42879 get mediaPaused() { 42880 return getBooleanAttr(this, MediaUIAttributes.MEDIA_PAUSED); 42881 } 42882 set mediaPaused(value) { 42883 setBooleanAttr(this, MediaUIAttributes.MEDIA_PAUSED, value); 42884 } 42885 /** 42886 * @type {boolean} Is the media playback currently live 42887 */ 42888 get mediaTimeIsLive() { 42889 return getBooleanAttr(this, MediaUIAttributes.MEDIA_TIME_IS_LIVE); 42890 } 42891 set mediaTimeIsLive(value) { 42892 setBooleanAttr(this, MediaUIAttributes.MEDIA_TIME_IS_LIVE, value); 42893 } 42894 handleClick() { 42895 if (!this.mediaPaused && this.mediaTimeIsLive) 42896 return; 42897 this.dispatchEvent( 42898 new GlobalThis.CustomEvent(MEDIA_SEEK_TO_LIVE_REQUEST, { 42899 composed: true, 42900 bubbles: true 42901 }) 42902 ); 42903 if (this.hasAttribute(MEDIA_PAUSED)) { 42904 this.dispatchEvent( 42905 new GlobalThis.CustomEvent(MEDIA_PLAY_REQUEST, { 42906 composed: true, 42907 bubbles: true 42908 }) 42909 ); 42910 } 42911 } 42912}; 42913if (!GlobalThis.customElements.get("media-live-button")) { 42914 GlobalThis.customElements.define("media-live-button", MediaLiveButton); 42915} 42916
vendor: 6,230 bytes, lines 42917-43098
42917// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-loading-indicator.js 42918var __accessCheck11 = (obj, member, msg) => { 42919 if (!member.has(obj)) 42920 throw TypeError("Cannot " + msg); 42921}; 42922var __privateGet11 = (obj, member, getter) => { 42923 __accessCheck11(obj, member, "read from private field"); 42924 return getter ? getter.call(obj) : member.get(obj); 42925}; 42926var __privateAdd11 = (obj, member, value) => { 42927 if (member.has(obj)) 42928 throw TypeError("Cannot add the same private member more than once"); 42929 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 42930}; 42931var __privateSet11 = (obj, member, value, setter) => { 42932 __accessCheck11(obj, member, "write to private field"); 42933 setter ? setter.call(obj, value) : member.set(obj, value); 42934 return value; 42935}; 42936var _mediaController6; 42937var _delay; 42938var Attributes5 = { 42939 LOADING_DELAY: "loadingdelay" 42940}; 42941var DEFAULT_LOADING_DELAY = 500; 42942var template8 = Document2.createElement("template"); 42943var loadingIndicatorIcon = ` 42944<svg aria-hidden="true" viewBox="0 0 100 100"> 42945 <path d="M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50"> 42946 <animateTransform 42947 attributeName="transform" 42948 attributeType="XML" 42949 type="rotate" 42950 dur="1s" 42951 from="0 50 50" 42952 to="360 50 50" 42953 repeatCount="indefinite" /> 42954 </path> 42955</svg> 42956`; 42957template8.innerHTML = /*html*/ 42958` 42959<style> 42960:host { 42961 display: var(--media-control-display, var(--media-loading-indicator-display, inline-block)); 42962 vertical-align: middle; 42963 box-sizing: border-box; 42964 --_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${DEFAULT_LOADING_DELAY}ms); 42965} 42966 42967#status { 42968 color: rgba(0,0,0,0); 42969 width: 0px; 42970 height: 0px; 42971} 42972 42973:host slot[name=icon] > *, 42974:host ::slotted([slot=icon]) { 42975 opacity: var(--media-loading-indicator-opacity, 0); 42976 transition: opacity 0.15s; 42977} 42978 42979:host([${MediaUIAttributes.MEDIA_LOADING}]:not([${MediaUIAttributes.MEDIA_PAUSED}])) slot[name=icon] > *, 42980:host([${MediaUIAttributes.MEDIA_LOADING}]:not([${MediaUIAttributes.MEDIA_PAUSED}])) ::slotted([slot=icon]) { 42981 opacity: var(--media-loading-indicator-opacity, 1); 42982 transition: opacity 0.15s var(--_loading-indicator-delay); 42983} 42984 42985:host #status { 42986 visibility: var(--media-loading-indicator-opacity, hidden); 42987 transition: visibility 0.15s; 42988} 42989 42990:host([${MediaUIAttributes.MEDIA_LOADING}]:not([${MediaUIAttributes.MEDIA_PAUSED}])) #status { 42991 visibility: var(--media-loading-indicator-opacity, visible); 42992 transition: visibility 0.15s var(--_loading-indicator-delay); 42993} 42994 42995svg, img, ::slotted(svg), ::slotted(img) { 42996 width: var(--media-loading-indicator-icon-width); 42997 height: var(--media-loading-indicator-icon-height, 100px); 42998 fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238))); 42999 vertical-align: middle; 43000} 43001</style> 43002 43003<slot name="icon">${loadingIndicatorIcon}</slot> 43004<div id="status" role="status" aria-live="polite">${nouns.MEDIA_LOADING()}</div> 43005`; 43006var MediaLoadingIndicator = class extends GlobalThis.HTMLElement { 43007 constructor() { 43008 super(); 43009 __privateAdd11(this, _mediaController6, void 0); 43010 __privateAdd11(this, _delay, DEFAULT_LOADING_DELAY); 43011 if (!this.shadowRoot) { 43012 const shadow = this.attachShadow({ mode: "open" }); 43013 const indicatorHTML = template8.content.cloneNode(true); 43014 shadow.appendChild(indicatorHTML); 43015 } 43016 } 43017 static get observedAttributes() { 43018 return [ 43019 MediaStateReceiverAttributes.MEDIA_CONTROLLER, 43020 MediaUIAttributes.MEDIA_PAUSED, 43021 MediaUIAttributes.MEDIA_LOADING, 43022 Attributes5.LOADING_DELAY 43023 ]; 43024 } 43025 attributeChangedCallback(attrName, oldValue, newValue) { 43026 var _a3, _b, _c, _d, _e5; 43027 if (attrName === Attributes5.LOADING_DELAY && oldValue !== newValue) { 43028 this.loadingDelay = Number(newValue); 43029 } else if (attrName === MediaStateReceiverAttributes.MEDIA_CONTROLLER) { 43030 if (oldValue) { 43031 (_b = (_a3 = __privateGet11(this, _mediaController6)) == null ? void 0 : _a3.unassociateElement) == null ? void 0 : _b.call(_a3, this); 43032 __privateSet11(this, _mediaController6, null); 43033 } 43034 if (newValue && this.isConnected) { 43035 __privateSet11(this, _mediaController6, (_c = this.getRootNode()) == null ? void 0 : _c.getElementById(newValue)); 43036 (_e5 = (_d = __privateGet11(this, _mediaController6)) == null ? void 0 : _d.associateElement) == null ? void 0 : _e5.call(_d, this); 43037 } 43038 } 43039 } 43040 connectedCallback() { 43041 var _a3, _b, _c; 43042 const mediaControllerId = this.getAttribute( 43043 MediaStateReceiverAttributes.MEDIA_CONTROLLER 43044 ); 43045 if (mediaControllerId) { 43046 __privateSet11(this, _mediaController6, (_a3 = this.getRootNode()) == null ? void 0 : _a3.getElementById( 43047 mediaControllerId 43048 )); 43049 (_c = (_b = __privateGet11(this, _mediaController6)) == null ? void 0 : _b.associateElement) == null ? void 0 : _c.call(_b, this); 43050 } 43051 } 43052 disconnectedCallback() { 43053 var _a3, _b; 43054 (_b = (_a3 = __privateGet11(this, _mediaController6)) == null ? void 0 : _a3.unassociateElement) == null ? void 0 : _b.call(_a3, this); 43055 __privateSet11(this, _mediaController6, null); 43056 } 43057 /** 43058 * Delay in ms 43059 */ 43060 get loadingDelay() { 43061 return __privateGet11(this, _delay); 43062 } 43063 set loadingDelay(delay2) { 43064 __privateSet11(this, _delay, delay2); 43065 const { style } = getOrInsertCSSRule(this.shadowRoot, ":host"); 43066 style.setProperty( 43067 "--_loading-indicator-delay", 43068 `var(--media-loading-indicator-transition-delay, ${delay2}ms)` 43069 ); 43070 } 43071 /** 43072 * Is the media paused 43073 */ 43074 get mediaPaused() { 43075 return getBooleanAttr(this, MediaUIAttributes.MEDIA_PAUSED); 43076 } 43077 set mediaPaused(value) { 43078 setBooleanAttr(this, MediaUIAttributes.MEDIA_PAUSED, value); 43079 } 43080 /** 43081 * Is the media loading 43082 */ 43083 get mediaLoading() { 43084 return getBooleanAttr(this, MediaUIAttributes.MEDIA_LOADING); 43085 } 43086 set mediaLoading(value) { 43087 setBooleanAttr(this, MediaUIAttributes.MEDIA_LOADING, value); 43088 } 43089}; 43090_mediaController6 = /* @__PURE__ */ new WeakMap(); 43091_delay = /* @__PURE__ */ new WeakMap(); 43092if (!GlobalThis.customElements.get("media-loading-indicator")) { 43093 GlobalThis.customElements.define( 43094 "media-loading-indicator", 43095 MediaLoadingIndicator 43096 ); 43097} 43098
vendor: 3,551 bytes, lines 43099-43194
43099// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-mute-button.js 43100var { MEDIA_VOLUME_LEVEL } = MediaUIAttributes; 43101var offIcon = `<svg aria-hidden="true" viewBox="0 0 24 24"> 43102 <path d="M16.5 12A4.5 4.5 0 0 0 14 8v2.18l2.45 2.45a4.22 4.22 0 0 0 .05-.63Zm2.5 0a6.84 6.84 0 0 1-.54 2.64L20 16.15A8.8 8.8 0 0 0 21 12a9 9 0 0 0-7-8.77v2.06A7 7 0 0 1 19 12ZM4.27 3 3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25A6.92 6.92 0 0 1 14 18.7v2.06A9 9 0 0 0 17.69 19l2 2.05L21 19.73l-9-9L4.27 3ZM12 4 9.91 6.09 12 8.18V4Z"/> 43103</svg>`; 43104var lowIcon = `<svg aria-hidden="true" viewBox="0 0 24 24"> 43105 <path d="M3 9v6h4l5 5V4L7 9H3Zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.47 4.47 0 0 0 2.5-4Z"/> 43106</svg>`; 43107var highIcon = `<svg aria-hidden="true" viewBox="0 0 24 24"> 43108 <path d="M3 9v6h4l5 5V4L7 9H3Zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.47 4.47 0 0 0 2.5-4ZM14 3.23v2.06a7 7 0 0 1 0 13.42v2.06a9 9 0 0 0 0-17.54Z"/> 43109</svg>`; 43110var slotTemplate6 = Document2.createElement("template"); 43111slotTemplate6.innerHTML = /*html*/ 43112` 43113 <style> 43114 ${/* Default to High slot/icon. */ 43115""} 43116 :host(:not([${MEDIA_VOLUME_LEVEL}])) slot[name=icon] slot:not([name=high]), 43117 :host([${MEDIA_VOLUME_LEVEL}=high]) slot[name=icon] slot:not([name=high]) { 43118 display: none !important; 43119 } 43120 43121 :host([${MEDIA_VOLUME_LEVEL}=off]) slot[name=icon] slot:not([name=off]) { 43122 display: none !important; 43123 } 43124 43125 :host([${MEDIA_VOLUME_LEVEL}=low]) slot[name=icon] slot:not([name=low]) { 43126 display: none !important; 43127 } 43128 43129 :host([${MEDIA_VOLUME_LEVEL}=medium]) slot[name=icon] slot:not([name=medium]) { 43130 display: none !important; 43131 } 43132 43133 :host(:not([${MEDIA_VOLUME_LEVEL}=off])) slot[name=tooltip-unmute], 43134 :host([${MEDIA_VOLUME_LEVEL}=off]) slot[name=tooltip-mute] { 43135 display: none; 43136 } 43137 </style> 43138 43139 <slot name="icon"> 43140 <slot name="off">${offIcon}</slot> 43141 <slot name="low">${lowIcon}</slot> 43142 <slot name="medium">${lowIcon}</slot> 43143 <slot name="high">${highIcon}</slot> 43144 </slot> 43145`; 43146var tooltipContent5 = ( 43147 /*html*/ 43148 ` 43149 <slot name="tooltip-mute">${tooltipLabels.MUTE}</slot> 43150 <slot name="tooltip-unmute">${tooltipLabels.UNMUTE}</slot> 43151` 43152); 43153var updateAriaLabel4 = (el) => { 43154 const muted = el.mediaVolumeLevel === "off"; 43155 const label = muted ? verbs.UNMUTE() : verbs.MUTE(); 43156 el.setAttribute("aria-label", label); 43157}; 43158var MediaMuteButton = class extends MediaChromeButton { 43159 static get observedAttributes() { 43160 return [...super.observedAttributes, MediaUIAttributes.MEDIA_VOLUME_LEVEL]; 43161 } 43162 constructor(options2 = {}) { 43163 super({ slotTemplate: slotTemplate6, tooltipContent: tooltipContent5, ...options2 }); 43164 } 43165 connectedCallback() { 43166 updateAriaLabel4(this); 43167 super.connectedCallback(); 43168 } 43169 attributeChangedCallback(attrName, oldValue, newValue) { 43170 if (attrName === MediaUIAttributes.MEDIA_VOLUME_LEVEL) { 43171 updateAriaLabel4(this); 43172 } 43173 super.attributeChangedCallback(attrName, oldValue, newValue); 43174 } 43175 /** 43176 * @type {string | undefined} 43177 */ 43178 get mediaVolumeLevel() { 43179 return getStringAttr(this, MediaUIAttributes.MEDIA_VOLUME_LEVEL); 43180 } 43181 set mediaVolumeLevel(value) { 43182 setStringAttr(this, MediaUIAttributes.MEDIA_VOLUME_LEVEL, value); 43183 } 43184 handleClick() { 43185 const eventName = this.mediaVolumeLevel === "off" ? MediaUIEvents.MEDIA_UNMUTE_REQUEST : MediaUIEvents.MEDIA_MUTE_REQUEST; 43186 this.dispatchEvent( 43187 new GlobalThis.CustomEvent(eventName, { composed: true, bubbles: true }) 43188 ); 43189 } 43190}; 43191if (!GlobalThis.customElements.get("media-mute-button")) { 43192 GlobalThis.customElements.define("media-mute-button", MediaMuteButton); 43193} 43194
vendor: 2,926 bytes, lines 43195-43284
43195// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-pip-button.js 43196var pipIcon = `<svg aria-hidden="true" viewBox="0 0 28 24"> 43197 <path d="M24 3H4a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h20a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1Zm-1 16H5V5h18v14Zm-3-8h-7v5h7v-5Z"/> 43198</svg>`; 43199var slotTemplate7 = Document2.createElement("template"); 43200slotTemplate7.innerHTML = /*html*/ 43201` 43202 <style> 43203 :host([${MediaUIAttributes.MEDIA_IS_PIP}]) slot[name=icon] slot:not([name=exit]) { 43204 display: none !important; 43205 } 43206 43207 ${/* Double negative, but safer if display doesn't equal 'block' */ 43208""} 43209 :host(:not([${MediaUIAttributes.MEDIA_IS_PIP}])) slot[name=icon] slot:not([name=enter]) { 43210 display: none !important; 43211 } 43212 43213 :host([${MediaUIAttributes.MEDIA_IS_PIP}]) slot[name=tooltip-enter], 43214 :host(:not([${MediaUIAttributes.MEDIA_IS_PIP}])) slot[name=tooltip-exit] { 43215 display: none; 43216 } 43217 </style> 43218 43219 <slot name="icon"> 43220 <slot name="enter">${pipIcon}</slot> 43221 <slot name="exit">${pipIcon}</slot> 43222 </slot> 43223`; 43224var tooltipContent6 = ( 43225 /*html*/ 43226 ` 43227 <slot name="tooltip-enter">${tooltipLabels.ENTER_PIP}</slot> 43228 <slot name="tooltip-exit">${tooltipLabels.EXIT_PIP}</slot> 43229` 43230); 43231var updateAriaLabel5 = (el) => { 43232 const label = el.mediaIsPip ? verbs.EXIT_PIP() : verbs.ENTER_PIP(); 43233 el.setAttribute("aria-label", label); 43234}; 43235var MediaPipButton = class extends MediaChromeButton { 43236 static get observedAttributes() { 43237 return [ 43238 ...super.observedAttributes, 43239 MediaUIAttributes.MEDIA_IS_PIP, 43240 MediaUIAttributes.MEDIA_PIP_UNAVAILABLE 43241 ]; 43242 } 43243 constructor(options2 = {}) { 43244 super({ slotTemplate: slotTemplate7, tooltipContent: tooltipContent6, ...options2 }); 43245 } 43246 connectedCallback() { 43247 updateAriaLabel5(this); 43248 super.connectedCallback(); 43249 } 43250 attributeChangedCallback(attrName, oldValue, newValue) { 43251 if (attrName === MediaUIAttributes.MEDIA_IS_PIP) { 43252 updateAriaLabel5(this); 43253 } 43254 super.attributeChangedCallback(attrName, oldValue, newValue); 43255 } 43256 /** 43257 * @type {string | undefined} Pip unavailability state 43258 */ 43259 get mediaPipUnavailable() { 43260 return getStringAttr(this, MediaUIAttributes.MEDIA_PIP_UNAVAILABLE); 43261 } 43262 set mediaPipUnavailable(value) { 43263 setStringAttr(this, MediaUIAttributes.MEDIA_PIP_UNAVAILABLE, value); 43264 } 43265 /** 43266 * @type {boolean} Is the media currently playing picture-in-picture 43267 */ 43268 get mediaIsPip() { 43269 return getBooleanAttr(this, MediaUIAttributes.MEDIA_IS_PIP); 43270 } 43271 set mediaIsPip(value) { 43272 setBooleanAttr(this, MediaUIAttributes.MEDIA_IS_PIP, value); 43273 } 43274 handleClick() { 43275 const eventName = this.mediaIsPip ? MediaUIEvents.MEDIA_EXIT_PIP_REQUEST : MediaUIEvents.MEDIA_ENTER_PIP_REQUEST; 43276 this.dispatchEvent( 43277 new GlobalThis.CustomEvent(eventName, { composed: true, bubbles: true }) 43278 ); 43279 } 43280}; 43281if (!GlobalThis.customElements.get("media-pip-button")) { 43282 GlobalThis.customElements.define("media-pip-button", MediaPipButton); 43283} 43284
vendor: 3,628 bytes, lines 43285-43395
43285// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-playback-rate-button.js 43286var __accessCheck12 = (obj, member, msg) => { 43287 if (!member.has(obj)) 43288 throw TypeError("Cannot " + msg); 43289}; 43290var __privateGet12 = (obj, member, getter) => { 43291 __accessCheck12(obj, member, "read from private field"); 43292 return getter ? getter.call(obj) : member.get(obj); 43293}; 43294var __privateAdd12 = (obj, member, value) => { 43295 if (member.has(obj)) 43296 throw TypeError("Cannot add the same private member more than once"); 43297 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 43298}; 43299var _rates; 43300var Attributes6 = { 43301 RATES: "rates" 43302}; 43303var DEFAULT_RATES = [1, 1.2, 1.5, 1.7, 2]; 43304var DEFAULT_RATE = 1; 43305var slotTemplate8 = Document2.createElement("template"); 43306slotTemplate8.innerHTML = /*html*/ 43307` 43308 <style> 43309 :host { 43310 min-width: 5ch; 43311 padding: var(--media-button-padding, var(--media-control-padding, 10px 5px)); 43312 } 43313 </style> 43314 <slot name="icon"></slot> 43315`; 43316var MediaPlaybackRateButton = class extends MediaChromeButton { 43317 constructor(options2 = {}) { 43318 super({ 43319 slotTemplate: slotTemplate8, 43320 tooltipContent: tooltipLabels.PLAYBACK_RATE, 43321 ...options2 43322 }); 43323 __privateAdd12(this, _rates, new AttributeTokenList(this, Attributes6.RATES, { 43324 defaultValue: DEFAULT_RATES 43325 })); 43326 this.container = this.shadowRoot.querySelector('slot[name="icon"]'); 43327 this.container.innerHTML = `${DEFAULT_RATE}x`; 43328 } 43329 static get observedAttributes() { 43330 return [ 43331 ...super.observedAttributes, 43332 MediaUIAttributes.MEDIA_PLAYBACK_RATE, 43333 Attributes6.RATES 43334 ]; 43335 } 43336 attributeChangedCallback(attrName, oldValue, newValue) { 43337 super.attributeChangedCallback(attrName, oldValue, newValue); 43338 if (attrName === Attributes6.RATES) { 43339 __privateGet12(this, _rates).value = newValue; 43340 } 43341 if (attrName === MediaUIAttributes.MEDIA_PLAYBACK_RATE) { 43342 const newPlaybackRate = newValue ? +newValue : Number.NaN; 43343 const playbackRate = !Number.isNaN(newPlaybackRate) ? newPlaybackRate : DEFAULT_RATE; 43344 this.container.innerHTML = `${playbackRate}x`; 43345 this.setAttribute("aria-label", nouns.PLAYBACK_RATE({ playbackRate })); 43346 } 43347 } 43348 /** 43349 * @type { AttributeTokenList | Array<number> | undefined} Will return a DOMTokenList. 43350 * Setting a value will accept an array of numbers. 43351 */ 43352 get rates() { 43353 return __privateGet12(this, _rates); 43354 } 43355 set rates(value) { 43356 if (!value) { 43357 __privateGet12(this, _rates).value = ""; 43358 } else if (Array.isArray(value)) { 43359 __privateGet12(this, _rates).value = value.join(" "); 43360 } 43361 } 43362 /** 43363 * @type {number} The current playback rate 43364 */ 43365 get mediaPlaybackRate() { 43366 return getNumericAttr( 43367 this, 43368 MediaUIAttributes.MEDIA_PLAYBACK_RATE, 43369 DEFAULT_RATE 43370 ); 43371 } 43372 set mediaPlaybackRate(value) { 43373 setNumericAttr(this, MediaUIAttributes.MEDIA_PLAYBACK_RATE, value); 43374 } 43375 handleClick() { 43376 var _a3, _b; 43377 const availableRates = Array.from(this.rates.values(), (str) => +str).sort( 43378 (a2, b3) => a2 - b3 43379 ); 43380 const detail = (_b = (_a3 = availableRates.find((r10) => r10 > this.mediaPlaybackRate)) != null ? _a3 : availableRates[0]) != null ? _b : DEFAULT_RATE; 43381 const evt = new GlobalThis.CustomEvent( 43382 MediaUIEvents.MEDIA_PLAYBACK_RATE_REQUEST, 43383 { composed: true, bubbles: true, detail } 43384 ); 43385 this.dispatchEvent(evt); 43386 } 43387}; 43388_rates = /* @__PURE__ */ new WeakMap(); 43389if (!GlobalThis.customElements.get("media-playback-rate-button")) { 43390 GlobalThis.customElements.define( 43391 "media-playback-rate-button", 43392 MediaPlaybackRateButton 43393 ); 43394} 43395
vendor: 2,463 bytes, lines 43396-43474
43396// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-play-button.js 43397var playIcon = `<svg aria-hidden="true" viewBox="0 0 24 24"> 43398 <path d="m6 21 15-9L6 3v18Z"/> 43399</svg>`; 43400var pauseIcon = `<svg aria-hidden="true" viewBox="0 0 24 24"> 43401 <path d="M6 20h4V4H6v16Zm8-16v16h4V4h-4Z"/> 43402</svg>`; 43403var slotTemplate9 = Document2.createElement("template"); 43404slotTemplate9.innerHTML = /*html*/ 43405` 43406 <style> 43407 :host([${MediaUIAttributes.MEDIA_PAUSED}]) slot[name=pause], 43408 :host(:not([${MediaUIAttributes.MEDIA_PAUSED}])) slot[name=play] { 43409 display: none !important; 43410 } 43411 43412 :host([${MediaUIAttributes.MEDIA_PAUSED}]) slot[name=tooltip-pause], 43413 :host(:not([${MediaUIAttributes.MEDIA_PAUSED}])) slot[name=tooltip-play] { 43414 display: none; 43415 } 43416 </style> 43417 43418 <slot name="icon"> 43419 <slot name="play">${playIcon}</slot> 43420 <slot name="pause">${pauseIcon}</slot> 43421 </slot> 43422`; 43423var tooltipContent7 = ( 43424 /*html*/ 43425 ` 43426 <slot name="tooltip-play">${tooltipLabels.PLAY}</slot> 43427 <slot name="tooltip-pause">${tooltipLabels.PAUSE}</slot> 43428` 43429); 43430var updateAriaLabel6 = (el) => { 43431 const label = el.mediaPaused ? verbs.PLAY() : verbs.PAUSE(); 43432 el.setAttribute("aria-label", label); 43433}; 43434var MediaPlayButton = class extends MediaChromeButton { 43435 static get observedAttributes() { 43436 return [ 43437 ...super.observedAttributes, 43438 MediaUIAttributes.MEDIA_PAUSED, 43439 MediaUIAttributes.MEDIA_ENDED 43440 ]; 43441 } 43442 constructor(options2 = {}) { 43443 super({ slotTemplate: slotTemplate9, tooltipContent: tooltipContent7, ...options2 }); 43444 } 43445 connectedCallback() { 43446 updateAriaLabel6(this); 43447 super.connectedCallback(); 43448 } 43449 attributeChangedCallback(attrName, oldValue, newValue) { 43450 if (attrName === MediaUIAttributes.MEDIA_PAUSED) { 43451 updateAriaLabel6(this); 43452 } 43453 super.attributeChangedCallback(attrName, oldValue, newValue); 43454 } 43455 /** 43456 * Is the media paused 43457 */ 43458 get mediaPaused() { 43459 return getBooleanAttr(this, MediaUIAttributes.MEDIA_PAUSED); 43460 } 43461 set mediaPaused(value) { 43462 setBooleanAttr(this, MediaUIAttributes.MEDIA_PAUSED, value); 43463 } 43464 handleClick() { 43465 const eventName = this.mediaPaused ? MediaUIEvents.MEDIA_PLAY_REQUEST : MediaUIEvents.MEDIA_PAUSE_REQUEST; 43466 this.dispatchEvent( 43467 new GlobalThis.CustomEvent(eventName, { composed: true, bubbles: true }) 43468 ); 43469 } 43470}; 43471if (!GlobalThis.customElements.get("media-play-button")) { 43472 GlobalThis.customElements.define("media-play-button", MediaPlayButton); 43473} 43474
vendor: 2,498 bytes, lines 43475-43561
43475// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-poster-image.js 43476var Attributes7 = { 43477 PLACEHOLDER_SRC: "placeholdersrc", 43478 SRC: "src" 43479}; 43480var template9 = Document2.createElement("template"); 43481template9.innerHTML = /*html*/ 43482` 43483 <style> 43484 :host { 43485 pointer-events: none; 43486 display: var(--media-poster-image-display, inline-block); 43487 box-sizing: border-box; 43488 } 43489 43490 img { 43491 max-width: 100%; 43492 max-height: 100%; 43493 min-width: 100%; 43494 min-height: 100%; 43495 background-repeat: no-repeat; 43496 background-position: var(--media-poster-image-background-position, var(--media-object-position, center)); 43497 background-size: var(--media-poster-image-background-size, var(--media-object-fit, contain)); 43498 object-fit: var(--media-object-fit, contain); 43499 object-position: var(--media-object-position, center); 43500 } 43501 </style> 43502 43503 <img part="poster img" aria-hidden="true" id="image"/> 43504`; 43505var unsetBackgroundImage = (el) => { 43506 el.style.removeProperty("background-image"); 43507}; 43508var setBackgroundImage = (el, image) => { 43509 el.style["background-image"] = `url('${image}')`; 43510}; 43511var MediaPosterImage = class extends GlobalThis.HTMLElement { 43512 static get observedAttributes() { 43513 return [Attributes7.PLACEHOLDER_SRC, Attributes7.SRC]; 43514 } 43515 constructor() { 43516 super(); 43517 if (!this.shadowRoot) { 43518 this.attachShadow({ mode: "open" }); 43519 this.shadowRoot.appendChild(template9.content.cloneNode(true)); 43520 } 43521 this.image = this.shadowRoot.querySelector("#image"); 43522 } 43523 attributeChangedCallback(attrName, oldValue, newValue) { 43524 if (attrName === Attributes7.SRC) { 43525 if (newValue == null) { 43526 this.image.removeAttribute(Attributes7.SRC); 43527 } else { 43528 this.image.setAttribute(Attributes7.SRC, newValue); 43529 } 43530 } 43531 if (attrName === Attributes7.PLACEHOLDER_SRC) { 43532 if (newValue == null) { 43533 unsetBackgroundImage(this.image); 43534 } else { 43535 setBackgroundImage(this.image, newValue); 43536 } 43537 } 43538 } 43539 /** 43540 * 43541 */ 43542 get placeholderSrc() { 43543 return getStringAttr(this, Attributes7.PLACEHOLDER_SRC); 43544 } 43545 set placeholderSrc(value) { 43546 setStringAttr(this, Attributes7.SRC, value); 43547 } 43548 /** 43549 * 43550 */ 43551 get src() { 43552 return getStringAttr(this, Attributes7.SRC); 43553 } 43554 set src(value) { 43555 setStringAttr(this, Attributes7.SRC, value); 43556 } 43557}; 43558if (!GlobalThis.customElements.get("media-poster-image")) { 43559 GlobalThis.customElements.define("media-poster-image", MediaPosterImage); 43560} 43561
vendor: 2,177 bytes, lines 43562-43624
43562// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-preview-chapter-display.js 43563var __accessCheck13 = (obj, member, msg) => { 43564 if (!member.has(obj)) 43565 throw TypeError("Cannot " + msg); 43566}; 43567var __privateGet13 = (obj, member, getter) => { 43568 __accessCheck13(obj, member, "read from private field"); 43569 return getter ? getter.call(obj) : member.get(obj); 43570}; 43571var __privateAdd13 = (obj, member, value) => { 43572 if (member.has(obj)) 43573 throw TypeError("Cannot add the same private member more than once"); 43574 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 43575}; 43576var __privateSet12 = (obj, member, value, setter) => { 43577 __accessCheck13(obj, member, "write to private field"); 43578 setter ? setter.call(obj, value) : member.set(obj, value); 43579 return value; 43580}; 43581var _slot2; 43582var MediaPreviewChapterDisplay = class extends MediaTextDisplay { 43583 constructor() { 43584 super(); 43585 __privateAdd13(this, _slot2, void 0); 43586 __privateSet12(this, _slot2, this.shadowRoot.querySelector("slot")); 43587 } 43588 static get observedAttributes() { 43589 return [ 43590 ...super.observedAttributes, 43591 MediaUIAttributes.MEDIA_PREVIEW_CHAPTER 43592 ]; 43593 } 43594 attributeChangedCallback(attrName, oldValue, newValue) { 43595 super.attributeChangedCallback(attrName, oldValue, newValue); 43596 if (attrName === MediaUIAttributes.MEDIA_PREVIEW_CHAPTER) { 43597 if (newValue !== oldValue && newValue != null) { 43598 __privateGet13(this, _slot2).textContent = newValue; 43599 if (newValue !== "") { 43600 this.setAttribute("aria-valuetext", `chapter: ${newValue}`); 43601 } else { 43602 this.removeAttribute("aria-valuetext"); 43603 } 43604 } 43605 } 43606 } 43607 /** 43608 * @type {string | undefined} Timeline preview chapter 43609 */ 43610 get mediaPreviewChapter() { 43611 return getStringAttr(this, MediaUIAttributes.MEDIA_PREVIEW_CHAPTER); 43612 } 43613 set mediaPreviewChapter(value) { 43614 setStringAttr(this, MediaUIAttributes.MEDIA_PREVIEW_CHAPTER, value); 43615 } 43616}; 43617_slot2 = /* @__PURE__ */ new WeakMap(); 43618if (!GlobalThis.customElements.get("media-preview-chapter-display")) { 43619 GlobalThis.customElements.define( 43620 "media-preview-chapter-display", 43621 MediaPreviewChapterDisplay 43622 ); 43623} 43624
vendor: 5,958 bytes, lines 43625-43788
43625// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-preview-thumbnail.js 43626var __accessCheck14 = (obj, member, msg) => { 43627 if (!member.has(obj)) 43628 throw TypeError("Cannot " + msg); 43629}; 43630var __privateGet14 = (obj, member, getter) => { 43631 __accessCheck14(obj, member, "read from private field"); 43632 return getter ? getter.call(obj) : member.get(obj); 43633}; 43634var __privateAdd14 = (obj, member, value) => { 43635 if (member.has(obj)) 43636 throw TypeError("Cannot add the same private member more than once"); 43637 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 43638}; 43639var __privateSet13 = (obj, member, value, setter) => { 43640 __accessCheck14(obj, member, "write to private field"); 43641 setter ? setter.call(obj, value) : member.set(obj, value); 43642 return value; 43643}; 43644var _mediaController7; 43645var template10 = Document2.createElement("template"); 43646template10.innerHTML = /*html*/ 43647` 43648 <style> 43649 :host { 43650 box-sizing: border-box; 43651 display: var(--media-control-display, var(--media-preview-thumbnail-display, inline-block)); 43652 overflow: hidden; 43653 } 43654 43655 img { 43656 display: none; 43657 position: relative; 43658 } 43659 </style> 43660 <img crossorigin loading="eager" decoding="async"> 43661`; 43662var MediaPreviewThumbnail = class extends GlobalThis.HTMLElement { 43663 constructor() { 43664 super(); 43665 __privateAdd14(this, _mediaController7, void 0); 43666 if (!this.shadowRoot) { 43667 this.attachShadow({ mode: "open" }); 43668 this.shadowRoot.appendChild(template10.content.cloneNode(true)); 43669 } 43670 } 43671 static get observedAttributes() { 43672 return [ 43673 MediaStateReceiverAttributes.MEDIA_CONTROLLER, 43674 MediaUIAttributes.MEDIA_PREVIEW_IMAGE, 43675 MediaUIAttributes.MEDIA_PREVIEW_COORDS 43676 ]; 43677 } 43678 connectedCallback() { 43679 var _a3, _b, _c; 43680 const mediaControllerId = this.getAttribute( 43681 MediaStateReceiverAttributes.MEDIA_CONTROLLER 43682 ); 43683 if (mediaControllerId) { 43684 __privateSet13( 43685 this, 43686 _mediaController7, 43687 // @ts-ignore 43688 (_a3 = this.getRootNode()) == null ? void 0 : _a3.getElementById(mediaControllerId) 43689 ); 43690 (_c = (_b = __privateGet14(this, _mediaController7)) == null ? void 0 : _b.associateElement) == null ? void 0 : _c.call(_b, this); 43691 } 43692 } 43693 disconnectedCallback() { 43694 var _a3, _b; 43695 (_b = (_a3 = __privateGet14(this, _mediaController7)) == null ? void 0 : _a3.unassociateElement) == null ? void 0 : _b.call(_a3, this); 43696 __privateSet13(this, _mediaController7, null); 43697 } 43698 attributeChangedCallback(attrName, oldValue, newValue) { 43699 var _a3, _b, _c, _d, _e5; 43700 if ([ 43701 MediaUIAttributes.MEDIA_PREVIEW_IMAGE, 43702 MediaUIAttributes.MEDIA_PREVIEW_COORDS 43703 ].includes(attrName)) { 43704 this.update(); 43705 } 43706 if (attrName === MediaStateReceiverAttributes.MEDIA_CONTROLLER) { 43707 if (oldValue) { 43708 (_b = (_a3 = __privateGet14(this, _mediaController7)) == null ? void 0 : _a3.unassociateElement) == null ? void 0 : _b.call(_a3, this); 43709 __privateSet13(this, _mediaController7, null); 43710 } 43711 if (newValue && this.isConnected) { 43712 __privateSet13(this, _mediaController7, (_c = this.getRootNode()) == null ? void 0 : _c.getElementById(newValue)); 43713 (_e5 = (_d = __privateGet14(this, _mediaController7)) == null ? void 0 : _d.associateElement) == null ? void 0 : _e5.call(_d, this); 43714 } 43715 } 43716 } 43717 /** 43718 * @type {string | undefined} The url of the preview image 43719 */ 43720 get mediaPreviewImage() { 43721 return getStringAttr(this, MediaUIAttributes.MEDIA_PREVIEW_IMAGE); 43722 } 43723 set mediaPreviewImage(value) { 43724 setStringAttr(this, MediaUIAttributes.MEDIA_PREVIEW_IMAGE, value); 43725 } 43726 /** 43727 * @type {Array<number> | undefined} Fixed length array [x, y, width, height] or undefined 43728 */ 43729 get mediaPreviewCoords() { 43730 const attrVal = this.getAttribute(MediaUIAttributes.MEDIA_PREVIEW_COORDS); 43731 if (!attrVal) 43732 return void 0; 43733 return attrVal.split(/\s+/).map((coord) => +coord); 43734 } 43735 set mediaPreviewCoords(value) { 43736 if (!value) { 43737 this.removeAttribute(MediaUIAttributes.MEDIA_PREVIEW_COORDS); 43738 return; 43739 } 43740 this.setAttribute(MediaUIAttributes.MEDIA_PREVIEW_COORDS, value.join(" ")); 43741 } 43742 update() { 43743 const coords = this.mediaPreviewCoords; 43744 const previewImage = this.mediaPreviewImage; 43745 if (!(coords && previewImage)) 43746 return; 43747 const [x2, y4, w4, h3] = coords; 43748 const src = previewImage.split("#")[0]; 43749 const computedStyle = getComputedStyle(this); 43750 const { maxWidth, maxHeight, minWidth, minHeight } = computedStyle; 43751 const maxRatio = Math.min(parseInt(maxWidth) / w4, parseInt(maxHeight) / h3); 43752 const minRatio = Math.max(parseInt(minWidth) / w4, parseInt(minHeight) / h3); 43753 const isScalingDown = maxRatio < 1; 43754 const scale2 = isScalingDown ? maxRatio : minRatio > 1 ? minRatio : 1; 43755 const { style } = getOrInsertCSSRule(this.shadowRoot, ":host"); 43756 const imgStyle = getOrInsertCSSRule(this.shadowRoot, "img").style; 43757 const img = this.shadowRoot.querySelector("img"); 43758 const extremum = isScalingDown ? "min" : "max"; 43759 style.setProperty(`${extremum}-width`, "initial", "important"); 43760 style.setProperty(`${extremum}-height`, "initial", "important"); 43761 style.width = `${w4 * scale2}px`; 43762 style.height = `${h3 * scale2}px`; 43763 const resize2 = () => { 43764 imgStyle.width = `${this.imgWidth * scale2}px`; 43765 imgStyle.height = `${this.imgHeight * scale2}px`; 43766 imgStyle.display = "block"; 43767 }; 43768 if (img.src !== src) { 43769 img.onload = () => { 43770 this.imgWidth = img.naturalWidth; 43771 this.imgHeight = img.naturalHeight; 43772 resize2(); 43773 }; 43774 img.src = src; 43775 resize2(); 43776 } 43777 resize2(); 43778 imgStyle.transform = `translate(-${x2 * scale2}px, -${y4 * scale2}px)`; 43779 } 43780}; 43781_mediaController7 = /* @__PURE__ */ new WeakMap(); 43782if (!GlobalThis.customElements.get("media-preview-thumbnail")) { 43783 GlobalThis.customElements.define( 43784 "media-preview-thumbnail", 43785 MediaPreviewThumbnail 43786 ); 43787} 43788
vendor: 1,960 bytes, lines 43789-43842
43789// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-preview-time-display.js 43790var __accessCheck15 = (obj, member, msg) => { 43791 if (!member.has(obj)) 43792 throw TypeError("Cannot " + msg); 43793}; 43794var __privateGet15 = (obj, member, getter) => { 43795 __accessCheck15(obj, member, "read from private field"); 43796 return getter ? getter.call(obj) : member.get(obj); 43797}; 43798var __privateAdd15 = (obj, member, value) => { 43799 if (member.has(obj)) 43800 throw TypeError("Cannot add the same private member more than once"); 43801 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 43802}; 43803var __privateSet14 = (obj, member, value, setter) => { 43804 __accessCheck15(obj, member, "write to private field"); 43805 setter ? setter.call(obj, value) : member.set(obj, value); 43806 return value; 43807}; 43808var _slot3; 43809var MediaPreviewTimeDisplay = class extends MediaTextDisplay { 43810 constructor() { 43811 super(); 43812 __privateAdd15(this, _slot3, void 0); 43813 __privateSet14(this, _slot3, this.shadowRoot.querySelector("slot")); 43814 __privateGet15(this, _slot3).textContent = formatTime(0); 43815 } 43816 static get observedAttributes() { 43817 return [...super.observedAttributes, MediaUIAttributes.MEDIA_PREVIEW_TIME]; 43818 } 43819 attributeChangedCallback(attrName, oldValue, newValue) { 43820 super.attributeChangedCallback(attrName, oldValue, newValue); 43821 if (attrName === MediaUIAttributes.MEDIA_PREVIEW_TIME && newValue != null) { 43822 __privateGet15(this, _slot3).textContent = formatTime(parseFloat(newValue)); 43823 } 43824 } 43825 /** 43826 * Timeline preview time 43827 */ 43828 get mediaPreviewTime() { 43829 return getNumericAttr(this, MediaUIAttributes.MEDIA_PREVIEW_TIME); 43830 } 43831 set mediaPreviewTime(value) { 43832 setNumericAttr(this, MediaUIAttributes.MEDIA_PREVIEW_TIME, value); 43833 } 43834}; 43835_slot3 = /* @__PURE__ */ new WeakMap(); 43836if (!GlobalThis.customElements.get("media-preview-time-display")) { 43837 GlobalThis.customElements.define( 43838 "media-preview-time-display", 43839 MediaPreviewTimeDisplay 43840 ); 43841} 43842
vendor: 2,764 bytes, lines 43843-43932
43843// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-seek-backward-button.js 43844var Attributes8 = { 43845 SEEK_OFFSET: "seekoffset" 43846}; 43847var DEFAULT_SEEK_OFFSET2 = 30; 43848var backwardIcon = `<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(2.18 19.87)">${DEFAULT_SEEK_OFFSET2}</text><path d="M10 6V3L4.37 7 10 10.94V8a5.54 5.54 0 0 1 1.9 10.48v2.12A7.5 7.5 0 0 0 10 6Z"/></svg>`; 43849var slotTemplate10 = Document2.createElement("template"); 43850slotTemplate10.innerHTML = ` 43851 <slot name="icon">${backwardIcon}</slot> 43852`; 43853var DEFAULT_TIME = 0; 43854var MediaSeekBackwardButton = class extends MediaChromeButton { 43855 static get observedAttributes() { 43856 return [ 43857 ...super.observedAttributes, 43858 MediaUIAttributes.MEDIA_CURRENT_TIME, 43859 Attributes8.SEEK_OFFSET 43860 ]; 43861 } 43862 constructor(options2 = {}) { 43863 super({ 43864 slotTemplate: slotTemplate10, 43865 tooltipContent: tooltipLabels.SEEK_BACKWARD, 43866 ...options2 43867 }); 43868 } 43869 connectedCallback() { 43870 this.seekOffset = getNumericAttr( 43871 this, 43872 Attributes8.SEEK_OFFSET, 43873 DEFAULT_SEEK_OFFSET2 43874 ); 43875 super.connectedCallback(); 43876 } 43877 attributeChangedCallback(attrName, _oldValue, newValue) { 43878 if (attrName === Attributes8.SEEK_OFFSET) { 43879 this.seekOffset = getNumericAttr( 43880 this, 43881 Attributes8.SEEK_OFFSET, 43882 DEFAULT_SEEK_OFFSET2 43883 ); 43884 } 43885 super.attributeChangedCallback(attrName, _oldValue, newValue); 43886 } 43887 // Own props 43888 /** 43889 * Seek amount in seconds 43890 */ 43891 get seekOffset() { 43892 return getNumericAttr(this, Attributes8.SEEK_OFFSET, DEFAULT_SEEK_OFFSET2); 43893 } 43894 set seekOffset(value) { 43895 setNumericAttr(this, Attributes8.SEEK_OFFSET, value); 43896 this.setAttribute( 43897 "aria-label", 43898 verbs.SEEK_BACK_N_SECS({ seekOffset: this.seekOffset }) 43899 ); 43900 updateIconText(getSlotted(this, "icon"), this.seekOffset); 43901 } 43902 // Props derived from Media UI Attributes 43903 /** 43904 * The current time in seconds 43905 */ 43906 get mediaCurrentTime() { 43907 return getNumericAttr( 43908 this, 43909 MediaUIAttributes.MEDIA_CURRENT_TIME, 43910 DEFAULT_TIME 43911 ); 43912 } 43913 set mediaCurrentTime(time) { 43914 setNumericAttr(this, MediaUIAttributes.MEDIA_CURRENT_TIME, time); 43915 } 43916 handleClick() { 43917 const detail = Math.max(this.mediaCurrentTime - this.seekOffset, 0); 43918 const evt = new GlobalThis.CustomEvent(MediaUIEvents.MEDIA_SEEK_REQUEST, { 43919 composed: true, 43920 bubbles: true, 43921 detail 43922 }); 43923 this.dispatchEvent(evt); 43924 } 43925}; 43926if (!GlobalThis.customElements.get("media-seek-backward-button")) { 43927 GlobalThis.customElements.define( 43928 "media-seek-backward-button", 43929 MediaSeekBackwardButton 43930 ); 43931} 43932
vendor: 2,747 bytes, lines 43933-44022
43933// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-seek-forward-button.js 43934var Attributes9 = { 43935 SEEK_OFFSET: "seekoffset" 43936}; 43937var DEFAULT_SEEK_OFFSET3 = 30; 43938var forwardIcon = `<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(8.9 19.87)">${DEFAULT_SEEK_OFFSET3}</text><path d="M10 6V3l5.61 4L10 10.94V8a5.54 5.54 0 0 0-1.9 10.48v2.12A7.5 7.5 0 0 1 10 6Z"/></svg>`; 43939var slotTemplate11 = Document2.createElement("template"); 43940slotTemplate11.innerHTML = ` 43941 <slot name="icon">${forwardIcon}</slot> 43942`; 43943var DEFAULT_TIME2 = 0; 43944var MediaSeekForwardButton = class extends MediaChromeButton { 43945 static get observedAttributes() { 43946 return [ 43947 ...super.observedAttributes, 43948 MediaUIAttributes.MEDIA_CURRENT_TIME, 43949 Attributes9.SEEK_OFFSET 43950 ]; 43951 } 43952 constructor(options2 = {}) { 43953 super({ 43954 slotTemplate: slotTemplate11, 43955 tooltipContent: tooltipLabels.SEEK_FORWARD, 43956 ...options2 43957 }); 43958 } 43959 connectedCallback() { 43960 this.seekOffset = getNumericAttr( 43961 this, 43962 Attributes9.SEEK_OFFSET, 43963 DEFAULT_SEEK_OFFSET3 43964 ); 43965 super.connectedCallback(); 43966 } 43967 attributeChangedCallback(attrName, _oldValue, newValue) { 43968 if (attrName === Attributes9.SEEK_OFFSET) { 43969 this.seekOffset = getNumericAttr( 43970 this, 43971 Attributes9.SEEK_OFFSET, 43972 DEFAULT_SEEK_OFFSET3 43973 ); 43974 } 43975 super.attributeChangedCallback(attrName, _oldValue, newValue); 43976 } 43977 // Own props 43978 /** 43979 * Seek amount in seconds 43980 */ 43981 get seekOffset() { 43982 return getNumericAttr(this, Attributes9.SEEK_OFFSET, DEFAULT_SEEK_OFFSET3); 43983 } 43984 set seekOffset(value) { 43985 setNumericAttr(this, Attributes9.SEEK_OFFSET, value); 43986 this.setAttribute( 43987 "aria-label", 43988 verbs.SEEK_FORWARD_N_SECS({ seekOffset: this.seekOffset }) 43989 ); 43990 updateIconText(getSlotted(this, "icon"), this.seekOffset); 43991 } 43992 // Props derived from Media UI Attributes 43993 /** 43994 * The current time in seconds 43995 */ 43996 get mediaCurrentTime() { 43997 return getNumericAttr( 43998 this, 43999 MediaUIAttributes.MEDIA_CURRENT_TIME, 44000 DEFAULT_TIME2 44001 ); 44002 } 44003 set mediaCurrentTime(time) { 44004 setNumericAttr(this, MediaUIAttributes.MEDIA_CURRENT_TIME, time); 44005 } 44006 handleClick() { 44007 const detail = this.mediaCurrentTime + this.seekOffset; 44008 const evt = new GlobalThis.CustomEvent(MediaUIEvents.MEDIA_SEEK_REQUEST, { 44009 composed: true, 44010 bubbles: true, 44011 detail 44012 }); 44013 this.dispatchEvent(evt); 44014 } 44015}; 44016if (!GlobalThis.customElements.get("media-seek-forward-button")) { 44017 GlobalThis.customElements.define( 44018 "media-seek-forward-button", 44019 MediaSeekForwardButton 44020 ); 44021} 44022
vendor: 7,367 bytes, lines 44023-44251
44023// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-time-display.js 44024var __accessCheck16 = (obj, member, msg) => { 44025 if (!member.has(obj)) 44026 throw TypeError("Cannot " + msg); 44027}; 44028var __privateGet16 = (obj, member, getter) => { 44029 __accessCheck16(obj, member, "read from private field"); 44030 return getter ? getter.call(obj) : member.get(obj); 44031}; 44032var __privateAdd16 = (obj, member, value) => { 44033 if (member.has(obj)) 44034 throw TypeError("Cannot add the same private member more than once"); 44035 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 44036}; 44037var __privateSet15 = (obj, member, value, setter) => { 44038 __accessCheck16(obj, member, "write to private field"); 44039 setter ? setter.call(obj, value) : member.set(obj, value); 44040 return value; 44041}; 44042var _slot4; 44043var Attributes10 = { 44044 REMAINING: "remaining", 44045 SHOW_DURATION: "showduration", 44046 NO_TOGGLE: "notoggle" 44047}; 44048var CombinedAttributes = [ 44049 ...Object.values(Attributes10), 44050 MediaUIAttributes.MEDIA_CURRENT_TIME, 44051 MediaUIAttributes.MEDIA_DURATION, 44052 MediaUIAttributes.MEDIA_SEEKABLE 44053]; 44054var ButtonPressedKeys2 = ["Enter", " "]; 44055var DEFAULT_TIMES_SEP = " / "; 44056var formatTimesLabel = (el, { timesSep = DEFAULT_TIMES_SEP } = {}) => { 44057 var _a3, _b; 44058 const showRemaining = el.hasAttribute(Attributes10.REMAINING); 44059 const showDuration = el.hasAttribute(Attributes10.SHOW_DURATION); 44060 const currentTime = (_a3 = el.mediaCurrentTime) != null ? _a3 : 0; 44061 const [, seekableEnd] = (_b = el.mediaSeekable) != null ? _b : []; 44062 let endTime = 0; 44063 if (Number.isFinite(el.mediaDuration)) { 44064 endTime = el.mediaDuration; 44065 } else if (Number.isFinite(seekableEnd)) { 44066 endTime = seekableEnd; 44067 } 44068 const timeLabel = showRemaining ? formatTime(0 - (endTime - currentTime)) : formatTime(currentTime); 44069 if (!showDuration) 44070 return timeLabel; 44071 return `${timeLabel}${timesSep}${formatTime(endTime)}`; 44072}; 44073var DEFAULT_MISSING_TIME_PHRASE = "video not loaded, unknown time."; 44074var updateAriaValueText = (el) => { 44075 var _a3; 44076 const currentTime = el.mediaCurrentTime; 44077 const [, seekableEnd] = (_a3 = el.mediaSeekable) != null ? _a3 : []; 44078 let endTime = null; 44079 if (Number.isFinite(el.mediaDuration)) { 44080 endTime = el.mediaDuration; 44081 } else if (Number.isFinite(seekableEnd)) { 44082 endTime = seekableEnd; 44083 } 44084 if (currentTime == null || endTime === null) { 44085 el.setAttribute("aria-valuetext", DEFAULT_MISSING_TIME_PHRASE); 44086 return; 44087 } 44088 const showRemaining = el.hasAttribute(Attributes10.REMAINING); 44089 const showDuration = el.hasAttribute(Attributes10.SHOW_DURATION); 44090 const currentTimePhrase = showRemaining ? formatAsTimePhrase(0 - (endTime - currentTime)) : formatAsTimePhrase(currentTime); 44091 if (!showDuration) { 44092 el.setAttribute("aria-valuetext", currentTimePhrase); 44093 return; 44094 } 44095 const totalTimePhrase = formatAsTimePhrase(endTime); 44096 const fullPhrase = `${currentTimePhrase} of ${totalTimePhrase}`; 44097 el.setAttribute("aria-valuetext", fullPhrase); 44098}; 44099var MediaTimeDisplay = class extends MediaTextDisplay { 44100 constructor() { 44101 super(); 44102 __privateAdd16(this, _slot4, void 0); 44103 __privateSet15(this, _slot4, this.shadowRoot.querySelector("slot")); 44104 __privateGet16(this, _slot4).innerHTML = `${formatTimesLabel(this)}`; 44105 } 44106 static get observedAttributes() { 44107 return [...super.observedAttributes, ...CombinedAttributes, "disabled"]; 44108 } 44109 connectedCallback() { 44110 const { style } = getOrInsertCSSRule( 44111 this.shadowRoot, 44112 ":host(:hover:not([notoggle]))" 44113 ); 44114 style.setProperty("cursor", "pointer"); 44115 style.setProperty( 44116 "background", 44117 "var(--media-control-hover-background, rgba(50 50 70 / .7))" 44118 ); 44119 if (!this.hasAttribute("disabled")) { 44120 this.enable(); 44121 } 44122 this.setAttribute("role", "progressbar"); 44123 this.setAttribute("aria-label", nouns.PLAYBACK_TIME()); 44124 const keyUpHandler = (evt) => { 44125 const { key } = evt; 44126 if (!ButtonPressedKeys2.includes(key)) { 44127 this.removeEventListener("keyup", keyUpHandler); 44128 return; 44129 } 44130 this.toggleTimeDisplay(); 44131 }; 44132 this.addEventListener("keydown", (evt) => { 44133 const { metaKey, altKey, key } = evt; 44134 if (metaKey || altKey || !ButtonPressedKeys2.includes(key)) { 44135 this.removeEventListener("keyup", keyUpHandler); 44136 return; 44137 } 44138 this.addEventListener("keyup", keyUpHandler); 44139 }); 44140 this.addEventListener("click", this.toggleTimeDisplay); 44141 super.connectedCallback(); 44142 } 44143 toggleTimeDisplay() { 44144 if (this.noToggle) { 44145 return; 44146 } 44147 if (this.hasAttribute("remaining")) { 44148 this.removeAttribute("remaining"); 44149 } else { 44150 this.setAttribute("remaining", ""); 44151 } 44152 } 44153 disconnectedCallback() { 44154 this.disable(); 44155 super.disconnectedCallback(); 44156 } 44157 attributeChangedCallback(attrName, oldValue, newValue) { 44158 if (CombinedAttributes.includes(attrName)) { 44159 this.update(); 44160 } else if (attrName === "disabled" && newValue !== oldValue) { 44161 if (newValue == null) { 44162 this.enable(); 44163 } else { 44164 this.disable(); 44165 } 44166 } 44167 super.attributeChangedCallback(attrName, oldValue, newValue); 44168 } 44169 enable() { 44170 this.tabIndex = 0; 44171 } 44172 disable() { 44173 this.tabIndex = -1; 44174 } 44175 // Own props 44176 /** 44177 * Whether to show the remaining time 44178 */ 44179 get remaining() { 44180 return getBooleanAttr(this, Attributes10.REMAINING); 44181 } 44182 set remaining(show) { 44183 setBooleanAttr(this, Attributes10.REMAINING, show); 44184 } 44185 /** 44186 * Whether to show the duration 44187 */ 44188 get showDuration() { 44189 return getBooleanAttr(this, Attributes10.SHOW_DURATION); 44190 } 44191 set showDuration(show) { 44192 setBooleanAttr(this, Attributes10.SHOW_DURATION, show); 44193 } 44194 /** 44195 * Disable the default behavior that toggles between current and remaining time 44196 */ 44197 get noToggle() { 44198 return getBooleanAttr(this, Attributes10.NO_TOGGLE); 44199 } 44200 set noToggle(noToggle) { 44201 setBooleanAttr(this, Attributes10.NO_TOGGLE, noToggle); 44202 } 44203 // Props derived from media UI attributes 44204 /** 44205 * Get the duration 44206 */ 44207 get mediaDuration() { 44208 return getNumericAttr(this, MediaUIAttributes.MEDIA_DURATION); 44209 } 44210 set mediaDuration(time) { 44211 setNumericAttr(this, MediaUIAttributes.MEDIA_DURATION, time); 44212 } 44213 /** 44214 * The current time in seconds 44215 */ 44216 get mediaCurrentTime() { 44217 return getNumericAttr(this, MediaUIAttributes.MEDIA_CURRENT_TIME); 44218 } 44219 set mediaCurrentTime(time) { 44220 setNumericAttr(this, MediaUIAttributes.MEDIA_CURRENT_TIME, time); 44221 } 44222 /** 44223 * Range of values that can be seeked to. 44224 * An array of two numbers [start, end] 44225 */ 44226 get mediaSeekable() { 44227 const seekable = this.getAttribute(MediaUIAttributes.MEDIA_SEEKABLE); 44228 if (!seekable) 44229 return void 0; 44230 return seekable.split(":").map((time) => +time); 44231 } 44232 set mediaSeekable(range) { 44233 if (range == null) { 44234 this.removeAttribute(MediaUIAttributes.MEDIA_SEEKABLE); 44235 return; 44236 } 44237 this.setAttribute(MediaUIAttributes.MEDIA_SEEKABLE, range.join(":")); 44238 } 44239 update() { 44240 const timesLabel = formatTimesLabel(this); 44241 updateAriaValueText(this); 44242 if (timesLabel !== __privateGet16(this, _slot4).innerHTML) { 44243 __privateGet16(this, _slot4).innerHTML = timesLabel; 44244 } 44245 } 44246}; 44247_slot4 = /* @__PURE__ */ new WeakMap(); 44248if (!GlobalThis.customElements.get("media-time-display")) { 44249 GlobalThis.customElements.define("media-time-display", MediaTimeDisplay); 44250} 44251
vendor: 4,345 bytes, lines 44252-44359
44252// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/utils/range-animation.js 44253var __accessCheck17 = (obj, member, msg) => { 44254 if (!member.has(obj)) 44255 throw TypeError("Cannot " + msg); 44256}; 44257var __privateGet17 = (obj, member, getter) => { 44258 __accessCheck17(obj, member, "read from private field"); 44259 return getter ? getter.call(obj) : member.get(obj); 44260}; 44261var __privateAdd17 = (obj, member, value) => { 44262 if (member.has(obj)) 44263 throw TypeError("Cannot add the same private member more than once"); 44264 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 44265}; 44266var __privateSet16 = (obj, member, value, setter) => { 44267 __accessCheck17(obj, member, "write to private field"); 44268 setter ? setter.call(obj, value) : member.set(obj, value); 44269 return value; 44270}; 44271var __privateWrapper = (obj, member, setter, getter) => ({ 44272 set _(value) { 44273 __privateSet16(obj, member, value, setter); 44274 }, 44275 get _() { 44276 return __privateGet17(obj, member, getter); 44277 } 44278}); 44279var _range; 44280var _startTime; 44281var _previousTime; 44282var _deltaTime; 44283var _frameCount; 44284var _updateTimestamp; 44285var _updateStartValue; 44286var _lastRangeIncrease; 44287var _id; 44288var _animate; 44289var RangeAnimation = class { 44290 constructor(range, callback, fps) { 44291 __privateAdd17(this, _range, void 0); 44292 __privateAdd17(this, _startTime, void 0); 44293 __privateAdd17(this, _previousTime, void 0); 44294 __privateAdd17(this, _deltaTime, void 0); 44295 __privateAdd17(this, _frameCount, void 0); 44296 __privateAdd17(this, _updateTimestamp, void 0); 44297 __privateAdd17(this, _updateStartValue, void 0); 44298 __privateAdd17(this, _lastRangeIncrease, void 0); 44299 __privateAdd17(this, _id, 0); 44300 __privateAdd17(this, _animate, (now2 = performance.now()) => { 44301 __privateSet16(this, _id, requestAnimationFrame(__privateGet17(this, _animate))); 44302 __privateSet16(this, _deltaTime, performance.now() - __privateGet17(this, _previousTime)); 44303 const fpsInterval = 1e3 / this.fps; 44304 if (__privateGet17(this, _deltaTime) > fpsInterval) { 44305 __privateSet16(this, _previousTime, now2 - __privateGet17(this, _deltaTime) % fpsInterval); 44306 const fps2 = 1e3 / ((now2 - __privateGet17(this, _startTime)) / ++__privateWrapper(this, _frameCount)._); 44307 const delta = (now2 - __privateGet17(this, _updateTimestamp)) / 1e3 / this.duration; 44308 let value = __privateGet17(this, _updateStartValue) + delta * this.playbackRate; 44309 const increase = value - __privateGet17(this, _range).valueAsNumber; 44310 if (increase > 0) { 44311 __privateSet16(this, _lastRangeIncrease, this.playbackRate / this.duration / fps2); 44312 } else { 44313 __privateSet16(this, _lastRangeIncrease, 0.995 * __privateGet17(this, _lastRangeIncrease)); 44314 value = __privateGet17(this, _range).valueAsNumber + __privateGet17(this, _lastRangeIncrease); 44315 } 44316 this.callback(value); 44317 } 44318 }); 44319 __privateSet16(this, _range, range); 44320 this.callback = callback; 44321 this.fps = fps; 44322 } 44323 start() { 44324 if (__privateGet17(this, _id) !== 0) 44325 return; 44326 __privateSet16(this, _previousTime, performance.now()); 44327 __privateSet16(this, _startTime, __privateGet17(this, _previousTime)); 44328 __privateSet16(this, _frameCount, 0); 44329 __privateGet17(this, _animate).call(this); 44330 } 44331 stop() { 44332 if (__privateGet17(this, _id) === 0) 44333 return; 44334 cancelAnimationFrame(__privateGet17(this, _id)); 44335 __privateSet16(this, _id, 0); 44336 } 44337 update({ start, duration, playbackRate }) { 44338 const increase = start - __privateGet17(this, _range).valueAsNumber; 44339 const durationDelta = Math.abs(duration - this.duration); 44340 if (increase > 0 || increase < -0.03 || durationDelta >= 0.5) { 44341 this.callback(start); 44342 } 44343 __privateSet16(this, _updateStartValue, start); 44344 __privateSet16(this, _updateTimestamp, performance.now()); 44345 this.duration = duration; 44346 this.playbackRate = playbackRate; 44347 } 44348}; 44349_range = /* @__PURE__ */ new WeakMap(); 44350_startTime = /* @__PURE__ */ new WeakMap(); 44351_previousTime = /* @__PURE__ */ new WeakMap(); 44352_deltaTime = /* @__PURE__ */ new WeakMap(); 44353_frameCount = /* @__PURE__ */ new WeakMap(); 44354_updateTimestamp = /* @__PURE__ */ new WeakMap(); 44355_updateStartValue = /* @__PURE__ */ new WeakMap(); 44356_lastRangeIncrease = /* @__PURE__ */ new WeakMap(); 44357_id = /* @__PURE__ */ new WeakMap(); 44358_animate = /* @__PURE__ */ new WeakMap(); 44359
vendor: 28,237 bytes, lines 44360-45083
44360// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-time-range.js 44361var __accessCheck18 = (obj, member, msg) => { 44362 if (!member.has(obj)) 44363 throw TypeError("Cannot " + msg); 44364}; 44365var __privateGet18 = (obj, member, getter) => { 44366 __accessCheck18(obj, member, "read from private field"); 44367 return getter ? getter.call(obj) : member.get(obj); 44368}; 44369var __privateAdd18 = (obj, member, value) => { 44370 if (member.has(obj)) 44371 throw TypeError("Cannot add the same private member more than once"); 44372 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 44373}; 44374var __privateSet17 = (obj, member, value, setter) => { 44375 __accessCheck18(obj, member, "write to private field"); 44376 setter ? setter.call(obj, value) : member.set(obj, value); 44377 return value; 44378}; 44379var __privateMethod6 = (obj, member, method) => { 44380 __accessCheck18(obj, member, "access private method"); 44381 return method; 44382}; 44383var _rootNode; 44384var _animation; 44385var _boxes; 44386var _previewTime; 44387var _previewBox; 44388var _currentBox; 44389var _boxPaddingLeft; 44390var _boxPaddingRight; 44391var _mediaChaptersCues; 44392var _toggleRangeAnimation; 44393var toggleRangeAnimation_fn; 44394var _shouldRangeAnimate; 44395var shouldRangeAnimate_fn; 44396var _updateRange; 44397var _getElementRects; 44398var getElementRects_fn; 44399var _getBoxPosition; 44400var getBoxPosition_fn; 44401var _getBoxShiftPosition; 44402var getBoxShiftPosition_fn; 44403var _handlePointerMove3; 44404var handlePointerMove_fn3; 44405var _previewRequest; 44406var previewRequest_fn; 44407var _seekRequest; 44408var seekRequest_fn; 44409var DEFAULT_MISSING_TIME_PHRASE2 = "video not loaded, unknown time."; 44410var updateAriaValueText2 = (el) => { 44411 const range = el.range; 44412 const currentTimePhrase = formatAsTimePhrase(+calcTimeFromRangeValue(el)); 44413 const totalTimePhrase = formatAsTimePhrase(+el.mediaSeekableEnd); 44414 const fullPhrase = !(currentTimePhrase && totalTimePhrase) ? DEFAULT_MISSING_TIME_PHRASE2 : `${currentTimePhrase} of ${totalTimePhrase}`; 44415 range.setAttribute("aria-valuetext", fullPhrase); 44416}; 44417var template11 = Document2.createElement("template"); 44418template11.innerHTML = /*html*/ 44419` 44420 <style> 44421 :host { 44422 --media-box-border-radius: 4px; 44423 --media-box-padding-left: 10px; 44424 --media-box-padding-right: 10px; 44425 --media-preview-border-radius: var(--media-box-border-radius); 44426 --media-box-arrow-offset: var(--media-box-border-radius); 44427 --_control-background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7))); 44428 --_preview-background: var(--media-preview-background, var(--_control-background)); 44429 44430 ${/* 1% rail width trick was off in Safari, contain: layout seems to 44431prevent the horizontal overflow as well. */ 44432""} 44433 contain: layout; 44434 } 44435 44436 #buffered { 44437 background: var(--media-time-range-buffered-color, rgb(255 255 255 / .4)); 44438 position: absolute; 44439 height: 100%; 44440 will-change: width; 44441 } 44442 44443 #preview-rail, 44444 #current-rail { 44445 width: 100%; 44446 position: absolute; 44447 left: 0; 44448 bottom: 100%; 44449 pointer-events: none; 44450 will-change: transform; 44451 } 44452 44453 [part~="box"] { 44454 width: min-content; 44455 ${/* absolute position is needed here so the box doesn't overflow the bounds */ 44456""} 44457 position: absolute; 44458 bottom: 100%; 44459 flex-direction: column; 44460 align-items: center; 44461 transform: translateX(-50%); 44462 } 44463 44464 [part~="current-box"] { 44465 display: var(--media-current-box-display, var(--media-box-display, flex)); 44466 margin: var(--media-current-box-margin, var(--media-box-margin, 0 0 5px)); 44467 visibility: hidden; 44468 } 44469 44470 [part~="preview-box"] { 44471 display: var(--media-preview-box-display, var(--media-box-display, flex)); 44472 margin: var(--media-preview-box-margin, var(--media-box-margin, 0 0 5px)); 44473 transition-property: var(--media-preview-transition-property, visibility, opacity); 44474 transition-duration: var(--media-preview-transition-duration-out, .25s); 44475 transition-delay: var(--media-preview-transition-delay-out, 0s); 44476 visibility: hidden; 44477 opacity: 0; 44478 } 44479 44480 :host(:is([${MediaUIAttributes.MEDIA_PREVIEW_IMAGE}], [${MediaUIAttributes.MEDIA_PREVIEW_TIME}])[dragging]) [part~="preview-box"] { 44481 transition-duration: var(--media-preview-transition-duration-in, .5s); 44482 transition-delay: var(--media-preview-transition-delay-in, .25s); 44483 visibility: visible; 44484 opacity: 1; 44485 } 44486 44487 @media (hover: hover) { 44488 :host(:is([${MediaUIAttributes.MEDIA_PREVIEW_IMAGE}], [${MediaUIAttributes.MEDIA_PREVIEW_TIME}]):hover) [part~="preview-box"] { 44489 transition-duration: var(--media-preview-transition-duration-in, .5s); 44490 transition-delay: var(--media-preview-transition-delay-in, .25s); 44491 visibility: visible; 44492 opacity: 1; 44493 } 44494 } 44495 44496 media-preview-thumbnail, 44497 ::slotted(media-preview-thumbnail) { 44498 visibility: hidden; 44499 ${/* delay changing these CSS props until the preview box transition is ended */ 44500""} 44501 transition: visibility 0s .25s; 44502 transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s)); 44503 background: var(--media-preview-thumbnail-background, var(--_preview-background)); 44504 box-shadow: var(--media-preview-thumbnail-box-shadow, 0 0 4px rgb(0 0 0 / .2)); 44505 max-width: var(--media-preview-thumbnail-max-width, 180px); 44506 max-height: var(--media-preview-thumbnail-max-height, 160px); 44507 min-width: var(--media-preview-thumbnail-min-width, 120px); 44508 min-height: var(--media-preview-thumbnail-min-height, 80px); 44509 border: var(--media-preview-thumbnail-border); 44510 border-radius: var(--media-preview-thumbnail-border-radius, 44511 var(--media-preview-border-radius) var(--media-preview-border-radius) 0 0); 44512 } 44513 44514 :host([${MediaUIAttributes.MEDIA_PREVIEW_IMAGE}][dragging]) media-preview-thumbnail, 44515 :host([${MediaUIAttributes.MEDIA_PREVIEW_IMAGE}][dragging]) ::slotted(media-preview-thumbnail) { 44516 transition-delay: var(--media-preview-transition-delay-in, .25s); 44517 visibility: visible; 44518 } 44519 44520 @media (hover: hover) { 44521 :host([${MediaUIAttributes.MEDIA_PREVIEW_IMAGE}]:hover) media-preview-thumbnail, 44522 :host([${MediaUIAttributes.MEDIA_PREVIEW_IMAGE}]:hover) ::slotted(media-preview-thumbnail) { 44523 transition-delay: var(--media-preview-transition-delay-in, .25s); 44524 visibility: visible; 44525 } 44526 44527 :host([${MediaUIAttributes.MEDIA_PREVIEW_TIME}]:hover) { 44528 --media-time-range-hover-display: block; 44529 } 44530 } 44531 44532 media-preview-chapter-display, 44533 ::slotted(media-preview-chapter-display) { 44534 font-size: var(--media-font-size, 13px); 44535 line-height: 17px; 44536 min-width: 0; 44537 visibility: hidden; 44538 ${/* delay changing these CSS props until the preview box transition is ended */ 44539""} 44540 transition: min-width 0s, border-radius 0s, margin 0s, padding 0s, visibility 0s; 44541 transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s)); 44542 background: var(--media-preview-chapter-background, var(--_preview-background)); 44543 border-radius: var(--media-preview-chapter-border-radius, 44544 var(--media-preview-border-radius) var(--media-preview-border-radius) 44545 var(--media-preview-border-radius) var(--media-preview-border-radius)); 44546 padding: var(--media-preview-chapter-padding, 3.5px 9px); 44547 margin: var(--media-preview-chapter-margin, 0 0 5px); 44548 text-shadow: var(--media-preview-chapter-text-shadow, 0 0 4px rgb(0 0 0 / .75)); 44549 } 44550 44551 :host([${MediaUIAttributes.MEDIA_PREVIEW_IMAGE}]) media-preview-chapter-display, 44552 :host([${MediaUIAttributes.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-chapter-display) { 44553 transition-delay: var(--media-preview-transition-delay-in, .25s); 44554 border-radius: var(--media-preview-chapter-border-radius, 0); 44555 padding: var(--media-preview-chapter-padding, 3.5px 9px 0); 44556 margin: var(--media-preview-chapter-margin, 0); 44557 min-width: 100%; 44558 } 44559 44560 media-preview-chapter-display[${MediaUIAttributes.MEDIA_PREVIEW_CHAPTER}], 44561 ::slotted(media-preview-chapter-display[${MediaUIAttributes.MEDIA_PREVIEW_CHAPTER}]) { 44562 visibility: visible; 44563 } 44564 44565 media-preview-chapter-display:not([aria-valuetext]), 44566 ::slotted(media-preview-chapter-display:not([aria-valuetext])) { 44567 display: none; 44568 } 44569 44570 media-preview-time-display, 44571 ::slotted(media-preview-time-display), 44572 media-time-display, 44573 ::slotted(media-time-display) { 44574 font-size: var(--media-font-size, 13px); 44575 line-height: 17px; 44576 min-width: 0; 44577 ${/* delay changing these CSS props until the preview box transition is ended */ 44578""} 44579 transition: min-width 0s, border-radius 0s; 44580 transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s)); 44581 background: var(--media-preview-time-background, var(--_preview-background)); 44582 border-radius: var(--media-preview-time-border-radius, 44583 var(--media-preview-border-radius) var(--media-preview-border-radius) 44584 var(--media-preview-border-radius) var(--media-preview-border-radius)); 44585 padding: var(--media-preview-time-padding, 3.5px 9px); 44586 margin: var(--media-preview-time-margin, 0); 44587 text-shadow: var(--media-preview-time-text-shadow, 0 0 4px rgb(0 0 0 / .75)); 44588 transform: translateX(min( 44589 max(calc(50% - var(--_box-width) / 2), 44590 calc(var(--_box-shift, 0))), 44591 calc(var(--_box-width) / 2 - 50%) 44592 )); 44593 } 44594 44595 :host([${MediaUIAttributes.MEDIA_PREVIEW_IMAGE}]) media-preview-time-display, 44596 :host([${MediaUIAttributes.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-time-display) { 44597 transition-delay: var(--media-preview-transition-delay-in, .25s); 44598 border-radius: var(--media-preview-time-border-radius, 44599 0 0 var(--media-preview-border-radius) var(--media-preview-border-radius)); 44600 min-width: 100%; 44601 } 44602 44603 :host([${MediaUIAttributes.MEDIA_PREVIEW_TIME}]:hover) { 44604 --media-time-range-hover-display: block; 44605 } 44606 44607 [part~="arrow"], 44608 ::slotted([part~="arrow"]) { 44609 display: var(--media-box-arrow-display, inline-block); 44610 transform: translateX(min( 44611 max(calc(50% - var(--_box-width) / 2 + var(--media-box-arrow-offset)), 44612 calc(var(--_box-shift, 0))), 44613 calc(var(--_box-width) / 2 - 50% - var(--media-box-arrow-offset)) 44614 )); 44615 ${/* border-color has to come before border-top-color! */ 44616""} 44617 border-color: transparent; 44618 border-top-color: var(--media-box-arrow-background, var(--_control-background)); 44619 border-width: var(--media-box-arrow-border-width, 44620 var(--media-box-arrow-height, 5px) var(--media-box-arrow-width, 6px) 0); 44621 border-style: solid; 44622 justify-content: center; 44623 height: 0; 44624 } 44625 </style> 44626 <div id="preview-rail"> 44627 <slot name="preview" part="box preview-box"> 44628 <media-preview-thumbnail></media-preview-thumbnail> 44629 <media-preview-chapter-display></media-preview-chapter-display> 44630 <media-preview-time-display></media-preview-time-display> 44631 <slot name="preview-arrow"><div part="arrow"></div></slot> 44632 </slot> 44633 </div> 44634 <div id="current-rail"> 44635 <slot name="current" part="box current-box"> 44636 ${/* Example: add the current time w/ arrow to the playhead 44637<media-time-display slot="current"></media-time-display> 44638<div part="arrow" slot="current"></div> */ 44639""} 44640 </slot> 44641 </div> 44642`; 44643var calcRangeValueFromTime = (el, time = el.mediaCurrentTime) => { 44644 const startTime = Number.isFinite(el.mediaSeekableStart) ? el.mediaSeekableStart : 0; 44645 const endTime = Number.isFinite(el.mediaDuration) ? el.mediaDuration : el.mediaSeekableEnd; 44646 if (Number.isNaN(endTime)) 44647 return 0; 44648 const value = (time - startTime) / (endTime - startTime); 44649 return Math.max(0, Math.min(value, 1)); 44650}; 44651var calcTimeFromRangeValue = (el, value = el.range.valueAsNumber) => { 44652 const startTime = Number.isFinite(el.mediaSeekableStart) ? el.mediaSeekableStart : 0; 44653 const endTime = Number.isFinite(el.mediaDuration) ? el.mediaDuration : el.mediaSeekableEnd; 44654 if (Number.isNaN(endTime)) 44655 return 0; 44656 return value * (endTime - startTime) + startTime; 44657}; 44658var MediaTimeRange = class extends MediaChromeRange { 44659 constructor() { 44660 super(); 44661 __privateAdd18(this, _toggleRangeAnimation); 44662 __privateAdd18(this, _shouldRangeAnimate); 44663 __privateAdd18(this, _getElementRects); 44664 __privateAdd18(this, _getBoxPosition); 44665 __privateAdd18(this, _getBoxShiftPosition); 44666 __privateAdd18(this, _handlePointerMove3); 44667 __privateAdd18(this, _previewRequest); 44668 __privateAdd18(this, _seekRequest); 44669 __privateAdd18(this, _rootNode, void 0); 44670 __privateAdd18(this, _animation, void 0); 44671 __privateAdd18(this, _boxes, void 0); 44672 __privateAdd18(this, _previewTime, void 0); 44673 __privateAdd18(this, _previewBox, void 0); 44674 __privateAdd18(this, _currentBox, void 0); 44675 __privateAdd18(this, _boxPaddingLeft, void 0); 44676 __privateAdd18(this, _boxPaddingRight, void 0); 44677 __privateAdd18(this, _mediaChaptersCues, void 0); 44678 __privateAdd18(this, _updateRange, (value) => { 44679 if (this.dragging) 44680 return; 44681 if (isValidNumber(value)) { 44682 this.range.valueAsNumber = value; 44683 } 44684 this.updateBar(); 44685 }); 44686 this.container.appendChild(template11.content.cloneNode(true)); 44687 const track = this.shadowRoot.querySelector("#track"); 44688 track.insertAdjacentHTML("afterbegin", '<div id="buffered" part="buffered"></div>'); 44689 __privateSet17(this, _boxes, this.shadowRoot.querySelectorAll('[part~="box"]')); 44690 __privateSet17(this, _previewBox, this.shadowRoot.querySelector('[part~="preview-box"]')); 44691 __privateSet17(this, _currentBox, this.shadowRoot.querySelector('[part~="current-box"]')); 44692 const computedStyle = getComputedStyle(this); 44693 __privateSet17(this, _boxPaddingLeft, parseInt( 44694 computedStyle.getPropertyValue("--media-box-padding-left") 44695 )); 44696 __privateSet17(this, _boxPaddingRight, parseInt( 44697 computedStyle.getPropertyValue("--media-box-padding-right") 44698 )); 44699 __privateSet17(this, _animation, new RangeAnimation(this.range, __privateGet18(this, _updateRange), 60)); 44700 } 44701 static get observedAttributes() { 44702 return [ 44703 ...super.observedAttributes, 44704 MediaUIAttributes.MEDIA_PAUSED, 44705 MediaUIAttributes.MEDIA_DURATION, 44706 MediaUIAttributes.MEDIA_SEEKABLE, 44707 MediaUIAttributes.MEDIA_CURRENT_TIME, 44708 MediaUIAttributes.MEDIA_PREVIEW_IMAGE, 44709 MediaUIAttributes.MEDIA_PREVIEW_TIME, 44710 MediaUIAttributes.MEDIA_PREVIEW_CHAPTER, 44711 MediaUIAttributes.MEDIA_BUFFERED, 44712 MediaUIAttributes.MEDIA_PLAYBACK_RATE, 44713 MediaUIAttributes.MEDIA_LOADING, 44714 MediaUIAttributes.MEDIA_ENDED 44715 ]; 44716 } 44717 connectedCallback() { 44718 var _a3; 44719 super.connectedCallback(); 44720 this.range.setAttribute("aria-label", nouns.SEEK()); 44721 __privateMethod6(this, _toggleRangeAnimation, toggleRangeAnimation_fn).call(this); 44722 __privateSet17(this, _rootNode, this.getRootNode()); 44723 (_a3 = __privateGet18(this, _rootNode)) == null ? void 0 : _a3.addEventListener("transitionstart", this); 44724 } 44725 disconnectedCallback() { 44726 var _a3; 44727 super.disconnectedCallback(); 44728 __privateMethod6(this, _toggleRangeAnimation, toggleRangeAnimation_fn).call(this); 44729 (_a3 = __privateGet18(this, _rootNode)) == null ? void 0 : _a3.removeEventListener("transitionstart", this); 44730 __privateSet17(this, _rootNode, null); 44731 } 44732 attributeChangedCallback(attrName, oldValue, newValue) { 44733 super.attributeChangedCallback(attrName, oldValue, newValue); 44734 if (oldValue == newValue) 44735 return; 44736 if (attrName === MediaUIAttributes.MEDIA_CURRENT_TIME || attrName === MediaUIAttributes.MEDIA_PAUSED || attrName === MediaUIAttributes.MEDIA_ENDED || attrName === MediaUIAttributes.MEDIA_LOADING || attrName === MediaUIAttributes.MEDIA_DURATION || attrName === MediaUIAttributes.MEDIA_SEEKABLE) { 44737 __privateGet18(this, _animation).update({ 44738 start: calcRangeValueFromTime(this), 44739 duration: this.mediaSeekableEnd - this.mediaSeekableStart, 44740 playbackRate: this.mediaPlaybackRate 44741 }); 44742 __privateMethod6(this, _toggleRangeAnimation, toggleRangeAnimation_fn).call(this); 44743 updateAriaValueText2(this); 44744 } else if (attrName === MediaUIAttributes.MEDIA_BUFFERED) { 44745 this.updateBufferedBar(); 44746 } 44747 if (attrName === MediaUIAttributes.MEDIA_DURATION || attrName === MediaUIAttributes.MEDIA_SEEKABLE) { 44748 this.mediaChaptersCues = __privateGet18(this, _mediaChaptersCues); 44749 this.updateBar(); 44750 } 44751 } 44752 get mediaChaptersCues() { 44753 return __privateGet18(this, _mediaChaptersCues); 44754 } 44755 set mediaChaptersCues(value) { 44756 var _a3; 44757 __privateSet17(this, _mediaChaptersCues, value); 44758 this.updateSegments( 44759 (_a3 = __privateGet18(this, _mediaChaptersCues)) == null ? void 0 : _a3.map((c3) => ({ 44760 start: calcRangeValueFromTime(this, c3.startTime), 44761 end: calcRangeValueFromTime(this, c3.endTime) 44762 })) 44763 ); 44764 } 44765 /** 44766 * Is the media paused 44767 */ 44768 get mediaPaused() { 44769 return getBooleanAttr(this, MediaUIAttributes.MEDIA_PAUSED); 44770 } 44771 set mediaPaused(value) { 44772 setBooleanAttr(this, MediaUIAttributes.MEDIA_PAUSED, value); 44773 } 44774 /** 44775 * Is the media loading 44776 */ 44777 get mediaLoading() { 44778 return getBooleanAttr(this, MediaUIAttributes.MEDIA_LOADING); 44779 } 44780 set mediaLoading(value) { 44781 setBooleanAttr(this, MediaUIAttributes.MEDIA_LOADING, value); 44782 } 44783 /** 44784 * 44785 */ 44786 get mediaDuration() { 44787 return getNumericAttr(this, MediaUIAttributes.MEDIA_DURATION); 44788 } 44789 set mediaDuration(value) { 44790 setNumericAttr(this, MediaUIAttributes.MEDIA_DURATION, value); 44791 } 44792 /** 44793 * 44794 */ 44795 get mediaCurrentTime() { 44796 return getNumericAttr(this, MediaUIAttributes.MEDIA_CURRENT_TIME); 44797 } 44798 set mediaCurrentTime(value) { 44799 setNumericAttr(this, MediaUIAttributes.MEDIA_CURRENT_TIME, value); 44800 } 44801 /** 44802 * 44803 */ 44804 get mediaPlaybackRate() { 44805 return getNumericAttr(this, MediaUIAttributes.MEDIA_PLAYBACK_RATE, 1); 44806 } 44807 set mediaPlaybackRate(value) { 44808 setNumericAttr(this, MediaUIAttributes.MEDIA_PLAYBACK_RATE, value); 44809 } 44810 /** 44811 * An array of ranges, each range being an array of two numbers. 44812 * e.g. [[1, 2], [3, 4]] 44813 */ 44814 get mediaBuffered() { 44815 const buffered = this.getAttribute(MediaUIAttributes.MEDIA_BUFFERED); 44816 if (!buffered) 44817 return []; 44818 return buffered.split(" ").map((timePair) => timePair.split(":").map((timeStr) => +timeStr)); 44819 } 44820 set mediaBuffered(list) { 44821 if (!list) { 44822 this.removeAttribute(MediaUIAttributes.MEDIA_BUFFERED); 44823 return; 44824 } 44825 const strVal = list.map((tuple) => tuple.join(":")).join(" "); 44826 this.setAttribute(MediaUIAttributes.MEDIA_BUFFERED, strVal); 44827 } 44828 /** 44829 * Range of values that can be seeked to 44830 * An array of two numbers [start, end] 44831 */ 44832 get mediaSeekable() { 44833 const seekable = this.getAttribute(MediaUIAttributes.MEDIA_SEEKABLE); 44834 if (!seekable) 44835 return void 0; 44836 return seekable.split(":").map((time) => +time); 44837 } 44838 set mediaSeekable(range) { 44839 if (range == null) { 44840 this.removeAttribute(MediaUIAttributes.MEDIA_SEEKABLE); 44841 return; 44842 } 44843 this.setAttribute(MediaUIAttributes.MEDIA_SEEKABLE, range.join(":")); 44844 } 44845 /** 44846 * 44847 */ 44848 get mediaSeekableEnd() { 44849 var _a3; 44850 const [, end = this.mediaDuration] = (_a3 = this.mediaSeekable) != null ? _a3 : []; 44851 return end; 44852 } 44853 get mediaSeekableStart() { 44854 var _a3; 44855 const [start = 0] = (_a3 = this.mediaSeekable) != null ? _a3 : []; 44856 return start; 44857 } 44858 /** 44859 * The url of the preview image 44860 */ 44861 get mediaPreviewImage() { 44862 return getStringAttr(this, MediaUIAttributes.MEDIA_PREVIEW_IMAGE); 44863 } 44864 set mediaPreviewImage(value) { 44865 setStringAttr(this, MediaUIAttributes.MEDIA_PREVIEW_IMAGE, value); 44866 } 44867 /** 44868 * 44869 */ 44870 get mediaPreviewTime() { 44871 return getNumericAttr(this, MediaUIAttributes.MEDIA_PREVIEW_TIME); 44872 } 44873 set mediaPreviewTime(value) { 44874 setNumericAttr(this, MediaUIAttributes.MEDIA_PREVIEW_TIME, value); 44875 } 44876 /** 44877 * 44878 */ 44879 get mediaEnded() { 44880 return getBooleanAttr(this, MediaUIAttributes.MEDIA_ENDED); 44881 } 44882 set mediaEnded(value) { 44883 setBooleanAttr(this, MediaUIAttributes.MEDIA_ENDED, value); 44884 } 44885 /* Add a buffered progress bar */ 44886 updateBar() { 44887 super.updateBar(); 44888 this.updateBufferedBar(); 44889 this.updateCurrentBox(); 44890 } 44891 updateBufferedBar() { 44892 var _a3; 44893 const buffered = this.mediaBuffered; 44894 if (!buffered.length) { 44895 return; 44896 } 44897 let relativeBufferedEnd; 44898 if (!this.mediaEnded) { 44899 const currentTime = this.mediaCurrentTime; 44900 const [, bufferedEnd = this.mediaSeekableStart] = (_a3 = buffered.find( 44901 ([start, end]) => start <= currentTime && currentTime <= end 44902 )) != null ? _a3 : []; 44903 relativeBufferedEnd = calcRangeValueFromTime(this, bufferedEnd); 44904 } else { 44905 relativeBufferedEnd = 1; 44906 } 44907 const { style } = getOrInsertCSSRule(this.shadowRoot, "#buffered"); 44908 style.setProperty("width", `${relativeBufferedEnd * 100}%`); 44909 } 44910 updateCurrentBox() { 44911 const currentSlot = this.shadowRoot.querySelector( 44912 'slot[name="current"]' 44913 ); 44914 if (!currentSlot.assignedElements().length) 44915 return; 44916 const currentRailRule = getOrInsertCSSRule( 44917 this.shadowRoot, 44918 "#current-rail" 44919 ); 44920 const currentBoxRule = getOrInsertCSSRule( 44921 this.shadowRoot, 44922 '[part~="current-box"]' 44923 ); 44924 const rects = __privateMethod6(this, _getElementRects, getElementRects_fn).call(this, __privateGet18(this, _currentBox)); 44925 const boxPos = __privateMethod6(this, _getBoxPosition, getBoxPosition_fn).call(this, rects, this.range.valueAsNumber); 44926 const boxShift = __privateMethod6(this, _getBoxShiftPosition, getBoxShiftPosition_fn).call(this, rects, this.range.valueAsNumber); 44927 currentRailRule.style.transform = `translateX(${boxPos})`; 44928 currentRailRule.style.setProperty("--_range-width", `${rects.range.width}`); 44929 currentBoxRule.style.setProperty("--_box-shift", `${boxShift}`); 44930 currentBoxRule.style.setProperty("--_box-width", `${rects.box.width}px`); 44931 currentBoxRule.style.setProperty("visibility", "initial"); 44932 } 44933 handleEvent(evt) { 44934 super.handleEvent(evt); 44935 switch (evt.type) { 44936 case "input": 44937 __privateMethod6(this, _seekRequest, seekRequest_fn).call(this); 44938 break; 44939 case "pointermove": 44940 __privateMethod6(this, _handlePointerMove3, handlePointerMove_fn3).call(this, evt); 44941 break; 44942 case "pointerup": 44943 case "pointerleave": 44944 __privateMethod6(this, _previewRequest, previewRequest_fn).call(this, null); 44945 break; 44946 case "transitionstart": 44947 if (containsComposedNode(evt.target, this)) { 44948 setTimeout(() => __privateMethod6(this, _toggleRangeAnimation, toggleRangeAnimation_fn).call(this), 0); 44949 } 44950 break; 44951 } 44952 } 44953}; 44954_rootNode = /* @__PURE__ */ new WeakMap(); 44955_animation = /* @__PURE__ */ new WeakMap(); 44956_boxes = /* @__PURE__ */ new WeakMap(); 44957_previewTime = /* @__PURE__ */ new WeakMap(); 44958_previewBox = /* @__PURE__ */ new WeakMap(); 44959_currentBox = /* @__PURE__ */ new WeakMap(); 44960_boxPaddingLeft = /* @__PURE__ */ new WeakMap(); 44961_boxPaddingRight = /* @__PURE__ */ new WeakMap(); 44962_mediaChaptersCues = /* @__PURE__ */ new WeakMap(); 44963_toggleRangeAnimation = /* @__PURE__ */ new WeakSet(); 44964toggleRangeAnimation_fn = function() { 44965 if (__privateMethod6(this, _shouldRangeAnimate, shouldRangeAnimate_fn).call(this)) { 44966 __privateGet18(this, _animation).start(); 44967 } else { 44968 __privateGet18(this, _animation).stop(); 44969 } 44970}; 44971_shouldRangeAnimate = /* @__PURE__ */ new WeakSet(); 44972shouldRangeAnimate_fn = function() { 44973 return this.isConnected && !this.mediaPaused && !this.mediaLoading && !this.mediaEnded && this.mediaSeekableEnd > 0 && isElementVisible(this); 44974}; 44975_updateRange = /* @__PURE__ */ new WeakMap(); 44976_getElementRects = /* @__PURE__ */ new WeakSet(); 44977getElementRects_fn = function(box) { 44978 var _a3; 44979 const bounds = (_a3 = this.getAttribute("bounds") ? closestComposedNode(this, `#${this.getAttribute("bounds")}`) : this.parentElement) != null ? _a3 : this; 44980 const boundsRect = bounds.getBoundingClientRect(); 44981 const rangeRect = this.range.getBoundingClientRect(); 44982 const width = box.offsetWidth; 44983 const min = -(rangeRect.left - boundsRect.left - width / 2); 44984 const max = boundsRect.right - rangeRect.left - width / 2; 44985 return { 44986 box: { width, min, max }, 44987 bounds: boundsRect, 44988 range: rangeRect 44989 }; 44990}; 44991_getBoxPosition = /* @__PURE__ */ new WeakSet(); 44992getBoxPosition_fn = function(rects, ratio) { 44993 let position2 = `${ratio * 100}%`; 44994 const { width, min, max } = rects.box; 44995 if (!width) 44996 return position2; 44997 if (!Number.isNaN(min)) { 44998 const pad = `var(--media-box-padding-left)`; 44999 const minPos = `calc(1 / var(--_range-width) * 100 * ${min}% + ${pad})`; 45000 position2 = `max(${minPos}, ${position2})`; 45001 } 45002 if (!Number.isNaN(max)) { 45003 const pad = `var(--media-box-padding-right)`; 45004 const maxPos = `calc(1 / var(--_range-width) * 100 * ${max}% - ${pad})`; 45005 position2 = `min(${position2}, ${maxPos})`; 45006 } 45007 return position2; 45008}; 45009_getBoxShiftPosition = /* @__PURE__ */ new WeakSet(); 45010getBoxShiftPosition_fn = function(rects, ratio) { 45011 const { width, min, max } = rects.box; 45012 const pointerX = ratio * rects.range.width; 45013 if (pointerX < min + __privateGet18(this, _boxPaddingLeft)) { 45014 const offset = rects.range.left - rects.bounds.left - __privateGet18(this, _boxPaddingLeft); 45015 return `${pointerX - width / 2 + offset}px`; 45016 } 45017 if (pointerX > max - __privateGet18(this, _boxPaddingRight)) { 45018 const offset = rects.bounds.right - rects.range.right - __privateGet18(this, _boxPaddingRight); 45019 return `${pointerX + width / 2 - offset - rects.range.width}px`; 45020 } 45021 return 0; 45022}; 45023_handlePointerMove3 = /* @__PURE__ */ new WeakSet(); 45024handlePointerMove_fn3 = function(evt) { 45025 const isOverBoxes = [...__privateGet18(this, _boxes)].some( 45026 (b3) => evt.composedPath().includes(b3) 45027 ); 45028 if (!this.dragging && (isOverBoxes || !evt.composedPath().includes(this))) { 45029 __privateMethod6(this, _previewRequest, previewRequest_fn).call(this, null); 45030 return; 45031 } 45032 const duration = this.mediaSeekableEnd; 45033 if (!duration) 45034 return; 45035 const previewRailRule = getOrInsertCSSRule( 45036 this.shadowRoot, 45037 "#preview-rail" 45038 ); 45039 const previewBoxRule = getOrInsertCSSRule( 45040 this.shadowRoot, 45041 '[part~="preview-box"]' 45042 ); 45043 const rects = __privateMethod6(this, _getElementRects, getElementRects_fn).call(this, __privateGet18(this, _previewBox)); 45044 let pointerRatio = (evt.clientX - rects.range.left) / rects.range.width; 45045 pointerRatio = Math.max(0, Math.min(1, pointerRatio)); 45046 const boxPos = __privateMethod6(this, _getBoxPosition, getBoxPosition_fn).call(this, rects, pointerRatio); 45047 const boxShift = __privateMethod6(this, _getBoxShiftPosition, getBoxShiftPosition_fn).call(this, rects, pointerRatio); 45048 previewRailRule.style.transform = `translateX(${boxPos})`; 45049 previewRailRule.style.setProperty("--_range-width", `${rects.range.width}`); 45050 previewBoxRule.style.setProperty("--_box-shift", `${boxShift}`); 45051 previewBoxRule.style.setProperty("--_box-width", `${rects.box.width}px`); 45052 const diff = Math.round(__privateGet18(this, _previewTime)) - Math.round(pointerRatio * duration); 45053 if (Math.abs(diff) < 1 && pointerRatio > 0.01 && pointerRatio < 0.99) 45054 return; 45055 __privateSet17(this, _previewTime, pointerRatio * duration); 45056 __privateMethod6(this, _previewRequest, previewRequest_fn).call(this, __privateGet18(this, _previewTime)); 45057}; 45058_previewRequest = /* @__PURE__ */ new WeakSet(); 45059previewRequest_fn = function(detail) { 45060 this.dispatchEvent( 45061 new GlobalThis.CustomEvent(MediaUIEvents.MEDIA_PREVIEW_REQUEST, { 45062 composed: true, 45063 bubbles: true, 45064 detail 45065 }) 45066 ); 45067}; 45068_seekRequest = /* @__PURE__ */ new WeakSet(); 45069seekRequest_fn = function() { 45070 __privateGet18(this, _animation).stop(); 45071 const detail = calcTimeFromRangeValue(this); 45072 this.dispatchEvent( 45073 new GlobalThis.CustomEvent(MediaUIEvents.MEDIA_SEEK_REQUEST, { 45074 composed: true, 45075 bubbles: true, 45076 detail 45077 }) 45078 ); 45079}; 45080if (!GlobalThis.customElements.get("media-time-range")) { 45081 GlobalThis.customElements.define("media-time-range", MediaTimeRange); 45082} 45083
vendor: 7,251 bytes, lines 45084-45279
45084// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-tooltip.js 45085var Attributes11 = { 45086 PLACEMENT: "placement", 45087 BOUNDS: "bounds" 45088}; 45089var template12 = Document2.createElement("template"); 45090template12.innerHTML = /*html*/ 45091` 45092 <style> 45093 :host { 45094 --_tooltip-background-color: var(--media-tooltip-background-color, var(--media-secondary-color, rgba(20, 20, 30, .7))); 45095 --_tooltip-background: var(--media-tooltip-background, var(--_tooltip-background-color)); 45096 --_tooltip-arrow-half-width: calc(var(--media-tooltip-arrow-width, 12px) / 2); 45097 --_tooltip-arrow-height: var(--media-tooltip-arrow-height, 5px); 45098 --_tooltip-arrow-background: var(--media-tooltip-arrow-color, var(--_tooltip-background-color)); 45099 position: relative; 45100 pointer-events: none; 45101 display: var(--media-tooltip-display, inline-flex); 45102 justify-content: center; 45103 align-items: center; 45104 box-sizing: border-box; 45105 z-index: var(--media-tooltip-z-index, 1); 45106 background: var(--_tooltip-background); 45107 color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238))); 45108 font: var(--media-font, 45109 var(--media-font-weight, 400) 45110 var(--media-font-size, 13px) / 45111 var(--media-text-content-height, var(--media-control-height, 18px)) 45112 var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif)); 45113 padding: var(--media-tooltip-padding, .35em .7em); 45114 border: var(--media-tooltip-border, none); 45115 border-radius: var(--media-tooltip-border-radius, 5px); 45116 filter: var(--media-tooltip-filter, drop-shadow(0 0 4px rgba(0, 0, 0, .2))); 45117 white-space: var(--media-tooltip-white-space, nowrap); 45118 } 45119 45120 :host([hidden]) { 45121 display: none; 45122 } 45123 45124 img, svg { 45125 display: inline-block; 45126 } 45127 45128 #arrow { 45129 position: absolute; 45130 width: 0px; 45131 height: 0px; 45132 border-style: solid; 45133 display: var(--media-tooltip-arrow-display, block); 45134 } 45135 45136 :host(:not([placement])), 45137 :host([placement="top"]) { 45138 position: absolute; 45139 bottom: calc(100% + var(--media-tooltip-distance, 12px)); 45140 left: 50%; 45141 transform: translate(calc(-50% - var(--media-tooltip-offset-x, 0px)), 0); 45142 } 45143 :host(:not([placement])) #arrow, 45144 :host([placement="top"]) #arrow { 45145 top: 100%; 45146 left: 50%; 45147 border-width: var(--_tooltip-arrow-height) var(--_tooltip-arrow-half-width) 0 var(--_tooltip-arrow-half-width); 45148 border-color: var(--_tooltip-arrow-background) transparent transparent transparent; 45149 transform: translate(calc(-50% + var(--media-tooltip-offset-x, 0px)), 0); 45150 } 45151 45152 :host([placement="right"]) { 45153 position: absolute; 45154 left: calc(100% + var(--media-tooltip-distance, 12px)); 45155 top: 50%; 45156 transform: translate(0, -50%); 45157 } 45158 :host([placement="right"]) #arrow { 45159 top: 50%; 45160 right: 100%; 45161 border-width: var(--_tooltip-arrow-half-width) var(--_tooltip-arrow-height) var(--_tooltip-arrow-half-width) 0; 45162 border-color: transparent var(--_tooltip-arrow-background) transparent transparent; 45163 transform: translate(0, -50%); 45164 } 45165 45166 :host([placement="bottom"]) { 45167 position: absolute; 45168 top: calc(100% + var(--media-tooltip-distance, 12px)); 45169 left: 50%; 45170 transform: translate(calc(-50% - var(--media-tooltip-offset-x, 0px)), 0); 45171 } 45172 :host([placement="bottom"]) #arrow { 45173 bottom: 100%; 45174 left: 50%; 45175 border-width: 0 var(--_tooltip-arrow-half-width) var(--_tooltip-arrow-height) var(--_tooltip-arrow-half-width); 45176 border-color: transparent transparent var(--_tooltip-arrow-background) transparent; 45177 transform: translate(calc(-50% + var(--media-tooltip-offset-x, 0px)), 0); 45178 } 45179 45180 :host([placement="left"]) { 45181 position: absolute; 45182 right: calc(100% + var(--media-tooltip-distance, 12px)); 45183 top: 50%; 45184 transform: translate(0, -50%); 45185 } 45186 :host([placement="left"]) #arrow { 45187 top: 50%; 45188 left: 100%; 45189 border-width: var(--_tooltip-arrow-half-width) 0 var(--_tooltip-arrow-half-width) var(--_tooltip-arrow-height); 45190 border-color: transparent transparent transparent var(--_tooltip-arrow-background); 45191 transform: translate(0, -50%); 45192 } 45193 45194 :host([placement="none"]) #arrow { 45195 display: none; 45196 } 45197 45198 </style> 45199 <slot></slot> 45200 <div id="arrow"></div> 45201`; 45202var MediaTooltip = class extends GlobalThis.HTMLElement { 45203 constructor() { 45204 super(); 45205 this.updateXOffset = () => { 45206 var _a3; 45207 if (!isElementVisible(this, { checkOpacity: false, checkVisibilityCSS: false })) 45208 return; 45209 const placement = this.placement; 45210 if (placement === "left" || placement === "right") { 45211 this.style.removeProperty("--media-tooltip-offset-x"); 45212 return; 45213 } 45214 const tooltipStyle = getComputedStyle(this); 45215 const containingEl = (_a3 = closestComposedNode(this, "#" + this.bounds)) != null ? _a3 : getMediaController(this); 45216 if (!containingEl) 45217 return; 45218 const { x: containerX, width: containerWidth } = containingEl.getBoundingClientRect(); 45219 const { x: tooltipX, width: tooltipWidth } = this.getBoundingClientRect(); 45220 const tooltipRight = tooltipX + tooltipWidth; 45221 const containerRight = containerX + containerWidth; 45222 const offsetXVal = tooltipStyle.getPropertyValue( 45223 "--media-tooltip-offset-x" 45224 ); 45225 const currOffsetX = offsetXVal ? parseFloat(offsetXVal.replace("px", "")) : 0; 45226 const marginVal = tooltipStyle.getPropertyValue( 45227 "--media-tooltip-container-margin" 45228 ); 45229 const currMargin = marginVal ? parseFloat(marginVal.replace("px", "")) : 0; 45230 const leftDiff = tooltipX - containerX + currOffsetX - currMargin; 45231 const rightDiff = tooltipRight - containerRight + currOffsetX + currMargin; 45232 if (leftDiff < 0) { 45233 this.style.setProperty("--media-tooltip-offset-x", `${leftDiff}px`); 45234 return; 45235 } 45236 if (rightDiff > 0) { 45237 this.style.setProperty("--media-tooltip-offset-x", `${rightDiff}px`); 45238 return; 45239 } 45240 this.style.removeProperty("--media-tooltip-offset-x"); 45241 }; 45242 if (!this.shadowRoot) { 45243 this.attachShadow({ mode: "open" }); 45244 this.shadowRoot.appendChild(template12.content.cloneNode(true)); 45245 } 45246 this.arrowEl = this.shadowRoot.querySelector("#arrow"); 45247 if (Object.prototype.hasOwnProperty.call(this, "placement")) { 45248 const placement = this.placement; 45249 delete this.placement; 45250 this.placement = placement; 45251 } 45252 } 45253 static get observedAttributes() { 45254 return [Attributes11.PLACEMENT, Attributes11.BOUNDS]; 45255 } 45256 /** 45257 * Get or set tooltip placement 45258 */ 45259 get placement() { 45260 return getStringAttr(this, Attributes11.PLACEMENT); 45261 } 45262 set placement(value) { 45263 setStringAttr(this, Attributes11.PLACEMENT, value); 45264 } 45265 /** 45266 * Get or set tooltip container ID selector that will constrain the tooltips 45267 * horizontal position. 45268 */ 45269 get bounds() { 45270 return getStringAttr(this, Attributes11.BOUNDS); 45271 } 45272 set bounds(value) { 45273 setStringAttr(this, Attributes11.BOUNDS, value); 45274 } 45275}; 45276if (!GlobalThis.customElements.get("media-tooltip")) { 45277 GlobalThis.customElements.define("media-tooltip", MediaTooltip); 45278} 45279
vendor: 2,320 bytes, lines 45280-45358
45280// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-volume-range.js 45281var DEFAULT_VOLUME = 1; 45282var toVolume = (el) => { 45283 if (el.mediaMuted) 45284 return 0; 45285 return el.mediaVolume; 45286}; 45287var formatAsPercentString = (value) => `${Math.round(value * 100)}%`; 45288var MediaVolumeRange = class extends MediaChromeRange { 45289 static get observedAttributes() { 45290 return [ 45291 ...super.observedAttributes, 45292 MediaUIAttributes.MEDIA_VOLUME, 45293 MediaUIAttributes.MEDIA_MUTED, 45294 MediaUIAttributes.MEDIA_VOLUME_UNAVAILABLE 45295 ]; 45296 } 45297 constructor() { 45298 super(); 45299 this.range.addEventListener("input", () => { 45300 const detail = this.range.value; 45301 const evt = new GlobalThis.CustomEvent( 45302 MediaUIEvents.MEDIA_VOLUME_REQUEST, 45303 { 45304 composed: true, 45305 bubbles: true, 45306 detail 45307 } 45308 ); 45309 this.dispatchEvent(evt); 45310 }); 45311 } 45312 connectedCallback() { 45313 super.connectedCallback(); 45314 this.range.setAttribute("aria-label", nouns.VOLUME()); 45315 } 45316 attributeChangedCallback(attrName, oldValue, newValue) { 45317 super.attributeChangedCallback(attrName, oldValue, newValue); 45318 if (attrName === MediaUIAttributes.MEDIA_VOLUME || attrName === MediaUIAttributes.MEDIA_MUTED) { 45319 this.range.valueAsNumber = toVolume(this); 45320 this.range.setAttribute( 45321 "aria-valuetext", 45322 formatAsPercentString(this.range.valueAsNumber) 45323 ); 45324 this.updateBar(); 45325 } 45326 } 45327 /** 45328 * 45329 */ 45330 get mediaVolume() { 45331 return getNumericAttr(this, MediaUIAttributes.MEDIA_VOLUME, DEFAULT_VOLUME); 45332 } 45333 set mediaVolume(value) { 45334 setNumericAttr(this, MediaUIAttributes.MEDIA_VOLUME, value); 45335 } 45336 /** 45337 * Is the media currently muted 45338 */ 45339 get mediaMuted() { 45340 return getBooleanAttr(this, MediaUIAttributes.MEDIA_MUTED); 45341 } 45342 set mediaMuted(value) { 45343 setBooleanAttr(this, MediaUIAttributes.MEDIA_MUTED, value); 45344 } 45345 /** 45346 * The volume unavailability state 45347 */ 45348 get mediaVolumeUnavailable() { 45349 return getStringAttr(this, MediaUIAttributes.MEDIA_VOLUME_UNAVAILABLE); 45350 } 45351 set mediaVolumeUnavailable(value) { 45352 setStringAttr(this, MediaUIAttributes.MEDIA_VOLUME_UNAVAILABLE, value); 45353 } 45354}; 45355if (!GlobalThis.customElements.get("media-volume-range")) { 45356 GlobalThis.customElements.define("media-volume-range", MediaVolumeRange); 45357} 45358
vendor: 57,828 bytes, lines 45359-46909
45359// node_modules/.pnpm/@[email protected]/node_modules/@mux/mux-video/dist/index.mjs 45360var di2 = Object.defineProperty; 45361var ui2 = Object.getPrototypeOf; 45362var ci2 = Reflect.get; 45363var hi2 = (e, r10, t2) => r10 in e ? di2(e, r10, { enumerable: true, configurable: true, writable: true, value: t2 }) : e[r10] = t2; 45364var E2 = (e, r10, t2) => (hi2(e, typeof r10 != "symbol" ? r10 + "" : r10, t2), t2); 45365var ge3 = (e, r10, t2) => { 45366 if (!r10.has(e)) throw TypeError("Cannot " + t2); 45367}; 45368var i = (e, r10, t2) => (ge3(e, r10, "read from private field"), t2 ? t2.call(e) : r10.get(e)); 45369var u = (e, r10, t2) => { 45370 if (r10.has(e)) throw TypeError("Cannot add the same private member more than once"); 45371 r10 instanceof WeakSet ? r10.add(e) : r10.set(e, t2); 45372}; 45373var h = (e, r10, t2, s) => (ge3(e, r10, "write to private field"), s ? s.call(e, t2) : r10.set(e, t2), t2); 45374var A3 = (e, r10, t2) => (ge3(e, r10, "access private method"), t2); 45375var Jt2 = (e, r10, t2) => ci2(ui2(e), t2, r10); 45376var Et3 = class { 45377 addEventListener() { 45378 } 45379 removeEventListener() { 45380 } 45381 dispatchEvent(r10) { 45382 return true; 45383 } 45384}; 45385if (typeof DocumentFragment == "undefined") { 45386 class e extends Et3 { 45387 } 45388 globalThis.DocumentFragment = e; 45389} 45390var wt2 = class extends Et3 { 45391}; 45392var Ee2 = class extends Et3 { 45393}; 45394var li2 = { get(e) { 45395}, define(e, r10, t2) { 45396}, getName(e) { 45397 return null; 45398}, upgrade(e) { 45399}, whenDefined(e) { 45400 return Promise.resolve(wt2); 45401} }; 45402var xt3; 45403var Te2 = class { 45404 constructor(r10, t2 = {}) { 45405 u(this, xt3, void 0); 45406 h(this, xt3, t2 == null ? void 0 : t2.detail); 45407 } 45408 get detail() { 45409 return i(this, xt3); 45410 } 45411 initCustomEvent() { 45412 } 45413}; 45414xt3 = /* @__PURE__ */ new WeakMap(); 45415function fi2(e, r10) { 45416 return new wt2(); 45417} 45418var Oe3 = { document: { createElement: fi2 }, DocumentFragment, customElements: li2, CustomEvent: Te2, EventTarget: Et3, HTMLElement: wt2, HTMLVideoElement: Ee2 }; 45419var Pe3 = typeof window == "undefined" || typeof globalThis.customElements == "undefined"; 45420var Qt2 = Pe3 ? Oe3 : globalThis; 45421var $i = Pe3 ? Oe3.document : globalThis.document; 45422var mi2 = () => { 45423 try { 45424 return "0.22.0"; 45425 } catch { 45426 } 45427 return "UNKNOWN"; 45428}; 45429var pi2 = mi2(); 45430var Ie3 = () => pi2; 45431var ve2 = ["abort", "canplay", "canplaythrough", "durationchange", "emptied", "encrypted", "ended", "error", "loadeddata", "loadedmetadata", "loadstart", "pause", "play", "playing", "progress", "ratechange", "seeked", "seeking", "stalled", "suspend", "timeupdate", "volumechange", "waiting", "waitingforkey", "resize", "enterpictureinpicture", "leavepictureinpicture", "webkitbeginfullscreen", "webkitendfullscreen", "webkitpresentationmodechanged"]; 45432function gi2(e) { 45433 return ` 45434 <style> 45435 :host { 45436 display: inline-flex; 45437 line-height: 0; 45438 flex-direction: column; 45439 justify-content: end; 45440 } 45441 45442 audio { 45443 width: 100%; 45444 } 45445 </style> 45446 <slot name="media"> 45447 <audio${Ve2(e)}></audio> 45448 </slot> 45449 <slot></slot> 45450 `; 45451} 45452function Ei2(e) { 45453 return ` 45454 <style> 45455 :host { 45456 display: inline-block; 45457 line-height: 0; 45458 } 45459 45460 video { 45461 max-width: 100%; 45462 max-height: 100%; 45463 min-width: 100%; 45464 min-height: 100%; 45465 object-fit: var(--media-object-fit, contain); 45466 object-position: var(--media-object-position, 50% 50%); 45467 } 45468 45469 video::-webkit-media-text-track-container { 45470 transform: var(--media-webkit-text-track-transform); 45471 transition: var(--media-webkit-text-track-transition); 45472 } 45473 </style> 45474 <slot name="media"> 45475 <video${Ve2(e)}></video> 45476 </slot> 45477 <slot></slot> 45478 `; 45479} 45480var we2 = (e, { tag: r10, is: t2 }) => { 45481 var l2, f, d2, T3, C4, xe3, mt4, x2, a2, m2, nt4, w4, be3, L, Ne4, O2, De4; 45482 let s = (f = (l2 = globalThis.document) == null ? void 0 : l2.createElement) == null ? void 0 : f.call(l2, r10, { is: t2 }), n2 = s ? Ti2(s) : []; 45483 return d2 = class extends e { 45484 constructor() { 45485 super(); 45486 u(this, m2); 45487 u(this, w4); 45488 u(this, L); 45489 u(this, O2); 45490 u(this, mt4, void 0); 45491 u(this, x2, void 0); 45492 u(this, a2, /* @__PURE__ */ new Map()); 45493 } 45494 static get observedAttributes() { 45495 var g, v2, P3; 45496 return A3(g = d2, C4, xe3).call(g), [...(P3 = (v2 = s == null ? void 0 : s.constructor) == null ? void 0 : v2.observedAttributes) != null ? P3 : [], "autopictureinpicture", "disablepictureinpicture", "disableremoteplayback", "autoplay", "controls", "controlslist", "crossorigin", "loop", "muted", "playsinline", "poster", "preload", "src"]; 45497 } 45498 get nativeEl() { 45499 var p3, g, v2; 45500 return A3(this, m2, nt4).call(this), (v2 = (g = (p3 = i(this, x2)) != null ? p3 : this.shadowRoot.querySelector(r10)) != null ? g : this.querySelector(":scope > [slot=media]")) != null ? v2 : this.querySelector(r10); 45501 } 45502 set nativeEl(p3) { 45503 h(this, x2, p3); 45504 } 45505 get defaultMuted() { 45506 return this.hasAttribute("muted"); 45507 } 45508 set defaultMuted(p3) { 45509 this.toggleAttribute("muted", !!p3); 45510 } 45511 get src() { 45512 return this.getAttribute("src"); 45513 } 45514 set src(p3) { 45515 this.setAttribute("src", `${p3}`); 45516 } 45517 get preload() { 45518 var p3, g; 45519 return (g = this.getAttribute("preload")) != null ? g : (p3 = this.nativeEl) == null ? void 0 : p3.preload; 45520 } 45521 set preload(p3) { 45522 this.setAttribute("preload", `${p3}`); 45523 } 45524 init() { 45525 var p3, g; 45526 if (!this.shadowRoot) { 45527 this.attachShadow({ mode: "open" }); 45528 let v2 = bi2(this.attributes); 45529 t2 && (v2.is = t2), r10 && (v2.part = r10), this.shadowRoot.innerHTML = this.constructor.getTemplateHTML(v2); 45530 } 45531 this.nativeEl.muted = this.hasAttribute("muted"); 45532 for (let v2 of n2) A3(this, L, Ne4).call(this, v2); 45533 this.shadowRoot.addEventListener("slotchange", this), A3(this, w4, be3).call(this); 45534 for (let v2 of this.constructor.Events) (g = (p3 = this.shadowRoot).addEventListener) == null || g.call(p3, v2, this, true); 45535 } 45536 handleEvent(p3) { 45537 if (p3.type === "slotchange") { 45538 A3(this, w4, be3).call(this); 45539 return; 45540 } 45541 p3.target === this.nativeEl && this.dispatchEvent(new CustomEvent(p3.type, { detail: p3.detail })); 45542 } 45543 attributeChangedCallback(p3, g, v2) { 45544 A3(this, m2, nt4).call(this), A3(this, O2, De4).call(this, p3, g, v2); 45545 } 45546 connectedCallback() { 45547 A3(this, m2, nt4).call(this); 45548 } 45549 }, T3 = /* @__PURE__ */ new WeakMap(), C4 = /* @__PURE__ */ new WeakSet(), xe3 = function() { 45550 if (i(this, T3)) return; 45551 h(this, T3, true); 45552 let p3 = new Set(this.observedAttributes); 45553 p3.delete("muted"); 45554 for (let g of n2) { 45555 if (g in this.prototype) continue; 45556 if (typeof s[g] == "function") this.prototype[g] = function(...P3) { 45557 return A3(this, m2, nt4).call(this), this.call ? this.call(g, ...P3) : this.nativeEl[g].apply(this.nativeEl, P3); 45558 }; 45559 else { 45560 let P3 = { get() { 45561 var D4, Lt4, Mt3; 45562 A3(this, m2, nt4).call(this); 45563 let _3 = g.toLowerCase(); 45564 if (p3.has(_3)) { 45565 let gt4 = this.getAttribute(_3); 45566 return gt4 === null ? false : gt4 === "" ? true : gt4; 45567 } 45568 return (Mt3 = (D4 = this.get) == null ? void 0 : D4.call(this, g)) != null ? Mt3 : (Lt4 = this.nativeEl) == null ? void 0 : Lt4[g]; 45569 } }; 45570 g !== g.toUpperCase() && (P3.set = function(_3) { 45571 A3(this, m2, nt4).call(this); 45572 let D4 = g.toLowerCase(); 45573 if (p3.has(D4)) { 45574 _3 === true || _3 === false || _3 == null ? this.toggleAttribute(D4, !!_3) : this.setAttribute(D4, _3); 45575 return; 45576 } 45577 if (this.set) { 45578 this.set(g, _3); 45579 return; 45580 } 45581 this.nativeEl[g] = _3; 45582 }), Object.defineProperty(this.prototype, g, P3); 45583 } 45584 } 45585 }, mt4 = /* @__PURE__ */ new WeakMap(), x2 = /* @__PURE__ */ new WeakMap(), a2 = /* @__PURE__ */ new WeakMap(), m2 = /* @__PURE__ */ new WeakSet(), nt4 = function() { 45586 i(this, mt4) || (h(this, mt4, true), this.init()); 45587 }, w4 = /* @__PURE__ */ new WeakSet(), be3 = function() { 45588 let p3 = new Map(i(this, a2)); 45589 this.shadowRoot.querySelector("slot:not([name])").assignedElements({ flatten: true }).filter((g) => ["track", "source"].includes(g.localName)).forEach((g) => { 45590 var P3, _3; 45591 p3.delete(g); 45592 let v2 = i(this, a2).get(g); 45593 v2 || (v2 = g.cloneNode(), i(this, a2).set(g, v2)), (_3 = (P3 = this.nativeEl).append) == null || _3.call(P3, v2), v2.localName === "track" && v2.default && (v2.kind === "chapters" || v2.kind === "metadata") && v2.track.mode === "disabled" && (v2.track.mode = "hidden"); 45594 }), p3.forEach((g) => g.remove()); 45595 }, L = /* @__PURE__ */ new WeakSet(), Ne4 = function(p3) { 45596 if (Object.prototype.hasOwnProperty.call(this, p3)) { 45597 let g = this[p3]; 45598 delete this[p3], this[p3] = g; 45599 } 45600 }, O2 = /* @__PURE__ */ new WeakSet(), De4 = function(p3, g, v2) { 45601 var P3, _3, D4, Lt4, Mt3, gt4; 45602 ["id", "class"].includes(p3) || !d2.observedAttributes.includes(p3) && this.constructor.observedAttributes.includes(p3) || (v2 === null ? (_3 = (P3 = this.nativeEl).removeAttribute) == null || _3.call(P3, p3) : ((Lt4 = (D4 = this.nativeEl).getAttribute) == null ? void 0 : Lt4.call(D4, p3)) != v2 && ((gt4 = (Mt3 = this.nativeEl).setAttribute) == null || gt4.call(Mt3, p3, v2))); 45603 }, u(d2, C4), E2(d2, "getTemplateHTML", r10.endsWith("audio") ? gi2 : Ei2), E2(d2, "shadowRootOptions", { mode: "open" }), E2(d2, "Events", ve2), u(d2, T3, void 0), d2; 45604}; 45605function Ti2(e) { 45606 let r10 = []; 45607 for (let t2 = Object.getPrototypeOf(e); t2 && t2 !== HTMLElement.prototype; t2 = Object.getPrototypeOf(t2)) r10.push(...Object.getOwnPropertyNames(t2)); 45608 return r10; 45609} 45610function Ve2(e) { 45611 let r10 = ""; 45612 for (let t2 in e) { 45613 let s = e[t2]; 45614 s === "" ? r10 += ` ${t2}` : r10 += ` ${t2}="${s}"`; 45615 } 45616 return r10; 45617} 45618function bi2(e) { 45619 let r10 = {}; 45620 for (let t2 of e) r10[t2.name] = t2.value; 45621 return r10; 45622} 45623var Le3; 45624var Zt2 = we2((Le3 = globalThis.HTMLElement) != null ? Le3 : class { 45625}, { tag: "video" }); 45626var Me3; 45627var Qi = we2((Me3 = globalThis.HTMLElement) != null ? Me3 : class { 45628}, { tag: "audio" }); 45629var V3 = /* @__PURE__ */ new WeakMap(); 45630var Tt3 = class extends Error { 45631}; 45632var te3 = class extends Error { 45633}; 45634var Ge3 = globalThis.WeakRef ? class extends Set { 45635 add(e) { 45636 super.add(new WeakRef(e)); 45637 } 45638 forEach(e) { 45639 super.forEach((r10) => { 45640 let t2 = r10.deref(); 45641 t2 && e(t2); 45642 }); 45643 } 45644} : Set; 45645function Be2(e) { 45646 var r10, t2, s; 45647 (t2 = (r10 = globalThis.chrome) == null ? void 0 : r10.cast) != null && t2.isAvailable ? (s = globalThis.cast) != null && s.framework ? e() : customElements.whenDefined("google-cast-button").then(e) : globalThis.__onGCastApiAvailable = () => { 45648 customElements.whenDefined("google-cast-button").then(e); 45649 }; 45650} 45651function Ke3() { 45652 return globalThis.chrome; 45653} 45654function qe() { 45655 var t2; 45656 let e = "https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"; 45657 if ((t2 = globalThis.chrome) != null && t2.cast || document.querySelector(`script[src="${e}"]`)) return; 45658 let r10 = document.createElement("script"); 45659 r10.src = e, document.head.append(r10); 45660} 45661function U3() { 45662 var e, r10; 45663 return (r10 = (e = globalThis.cast) == null ? void 0 : e.framework) == null ? void 0 : r10.CastContext.getInstance(); 45664} 45665function Nt3() { 45666 var e; 45667 return (e = U3()) == null ? void 0 : e.getCurrentSession(); 45668} 45669function ee3() { 45670 var e; 45671 return (e = Nt3()) == null ? void 0 : e.getSessionObj().media[0]; 45672} 45673function Fe3(e) { 45674 return new Promise((r10, t2) => { 45675 ee3().editTracksInfo(e, r10, t2); 45676 }); 45677} 45678function Ue3(e) { 45679 return new Promise((r10, t2) => { 45680 ee3().getStatus(e, r10, t2); 45681 }); 45682} 45683function ye3(e) { 45684 return U3().setOptions({ ...Ae3(), ...e }); 45685} 45686function Ae3() { 45687 return { receiverApplicationId: "CC1AD845", autoJoinPolicy: "origin_scoped", androidReceiverCompatible: false, language: "en-US", resumeSavedSession: true }; 45688} 45689var ie3 = new Ge3(); 45690var Y3 = /* @__PURE__ */ new WeakSet(); 45691var R3; 45692Be2(() => { 45693 var e, r10, t2, s; 45694 if (!((r10 = (e = globalThis.chrome) == null ? void 0 : e.cast) != null && r10.isAvailable)) { 45695 console.debug("chrome.cast.isAvailable", (s = (t2 = globalThis.chrome) == null ? void 0 : t2.cast) == null ? void 0 : s.isAvailable); 45696 return; 45697 } 45698 R3 || (R3 = cast.framework, U3().addEventListener(R3.CastContextEventType.CAST_STATE_CHANGED, (n2) => { 45699 ie3.forEach((l2) => { 45700 var f, d2; 45701 return (d2 = (f = V3.get(l2)).onCastStateChanged) == null ? void 0 : d2.call(f, n2); 45702 }); 45703 }), U3().addEventListener(R3.CastContextEventType.SESSION_STATE_CHANGED, (n2) => { 45704 ie3.forEach((l2) => { 45705 var f, d2; 45706 return (d2 = (f = V3.get(l2)).onSessionStateChanged) == null ? void 0 : d2.call(f, n2); 45707 }); 45708 }), ie3.forEach((n2) => { 45709 var l2, f; 45710 return (f = (l2 = V3.get(n2)).init) == null ? void 0 : f.call(l2); 45711 })); 45712}); 45713var Ye3 = 0; 45714var y; 45715var Dt3; 45716var I2; 45717var G3; 45718var at2; 45719var dt4; 45720var j2; 45721var se2; 45722var B3; 45723var ot3; 45724var ne3; 45725var je2; 45726var Vt3; 45727var ke3; 45728var oe2; 45729var We2; 45730var Gt2; 45731var Se3; 45732var ae2; 45733var He3; 45734var Bt2; 45735var Re2; 45736var re3 = class extends EventTarget { 45737 constructor(t2) { 45738 super(); 45739 u(this, B3); 45740 u(this, ne3); 45741 u(this, Vt3); 45742 u(this, oe2); 45743 u(this, Gt2); 45744 u(this, ae2); 45745 u(this, Bt2); 45746 u(this, y, void 0); 45747 u(this, Dt3, void 0); 45748 u(this, I2, void 0); 45749 u(this, G3, void 0); 45750 u(this, at2, "disconnected"); 45751 u(this, dt4, false); 45752 u(this, j2, /* @__PURE__ */ new Set()); 45753 u(this, se2, /* @__PURE__ */ new WeakMap()); 45754 h(this, y, t2), ie3.add(this), V3.set(this, { init: () => A3(this, Gt2, Se3).call(this), onCastStateChanged: () => A3(this, Vt3, ke3).call(this), onSessionStateChanged: () => A3(this, oe2, We2).call(this), getCastPlayer: () => i(this, B3, ot3) }), A3(this, Gt2, Se3).call(this); 45755 } 45756 get state() { 45757 return i(this, at2); 45758 } 45759 async watchAvailability(t2) { 45760 if (i(this, y).disableRemotePlayback) throw new Tt3("disableRemotePlayback attribute is present."); 45761 return i(this, se2).set(t2, ++Ye3), i(this, j2).add(t2), Ye3; 45762 } 45763 async cancelWatchAvailability(t2) { 45764 if (i(this, y).disableRemotePlayback) throw new Tt3("disableRemotePlayback attribute is present."); 45765 t2 ? i(this, j2).delete(t2) : i(this, j2).clear(); 45766 } 45767 async prompt() { 45768 var s, n2, l2, f; 45769 if (i(this, y).disableRemotePlayback) throw new Tt3("disableRemotePlayback attribute is present."); 45770 if (!((n2 = (s = globalThis.chrome) == null ? void 0 : s.cast) != null && n2.isAvailable)) throw new te3("The RemotePlayback API is disabled on this platform."); 45771 let t2 = Y3.has(i(this, y)); 45772 Y3.add(i(this, y)), ye3(i(this, y).castOptions), Object.entries(i(this, G3)).forEach(([d2, T3]) => { 45773 i(this, I2).controller.addEventListener(d2, T3); 45774 }); 45775 try { 45776 await U3().requestSession(); 45777 } catch (d2) { 45778 if (d2 === "cancel") { 45779 t2 || Y3.delete(i(this, y)); 45780 return; 45781 } 45782 throw new Error(d2); 45783 } 45784 (f = (l2 = V3.get(i(this, y))) == null ? void 0 : l2.loadOnPrompt) == null || f.call(l2); 45785 } 45786}; 45787y = /* @__PURE__ */ new WeakMap(), Dt3 = /* @__PURE__ */ new WeakMap(), I2 = /* @__PURE__ */ new WeakMap(), G3 = /* @__PURE__ */ new WeakMap(), at2 = /* @__PURE__ */ new WeakMap(), dt4 = /* @__PURE__ */ new WeakMap(), j2 = /* @__PURE__ */ new WeakMap(), se2 = /* @__PURE__ */ new WeakMap(), B3 = /* @__PURE__ */ new WeakSet(), ot3 = function() { 45788 if (Y3.has(i(this, y))) return i(this, I2); 45789}, ne3 = /* @__PURE__ */ new WeakSet(), je2 = function() { 45790 Y3.has(i(this, y)) && (Object.entries(i(this, G3)).forEach(([t2, s]) => { 45791 i(this, I2).controller.removeEventListener(t2, s); 45792 }), Y3.delete(i(this, y)), i(this, y).muted = i(this, I2).isMuted, i(this, y).currentTime = i(this, I2).savedPlayerState.currentTime, i(this, I2).savedPlayerState.isPaused === false && i(this, y).play()); 45793}, Vt3 = /* @__PURE__ */ new WeakSet(), ke3 = function() { 45794 let t2 = U3().getCastState(); 45795 if (Y3.has(i(this, y)) && t2 === "CONNECTING" && (h(this, at2, "connecting"), this.dispatchEvent(new Event("connecting"))), !i(this, dt4) && (t2 != null && t2.includes("CONNECT"))) { 45796 h(this, dt4, true); 45797 for (let s of i(this, j2)) s(true); 45798 } else if (i(this, dt4) && (!t2 || t2 === "NO_DEVICES_AVAILABLE")) { 45799 h(this, dt4, false); 45800 for (let s of i(this, j2)) s(false); 45801 } 45802}, oe2 = /* @__PURE__ */ new WeakSet(), We2 = async function() { 45803 var s; 45804 let { SESSION_RESUMED: t2 } = R3.SessionState; 45805 if (U3().getSessionState() === t2 && i(this, y).castSrc === ((s = ee3()) == null ? void 0 : s.media.contentId)) { 45806 Y3.add(i(this, y)), Object.entries(i(this, G3)).forEach(([n2, l2]) => { 45807 i(this, I2).controller.addEventListener(n2, l2); 45808 }); 45809 try { 45810 await Ue3(new chrome.cast.media.GetStatusRequest()); 45811 } catch (n2) { 45812 console.error(n2); 45813 } 45814 i(this, G3)[R3.RemotePlayerEventType.IS_PAUSED_CHANGED](), i(this, G3)[R3.RemotePlayerEventType.PLAYER_STATE_CHANGED](); 45815 } 45816}, Gt2 = /* @__PURE__ */ new WeakSet(), Se3 = function() { 45817 !R3 || i(this, Dt3) || (h(this, Dt3, true), ye3(i(this, y).castOptions), i(this, y).textTracks.addEventListener("change", () => A3(this, Bt2, Re2).call(this)), A3(this, Vt3, ke3).call(this), h(this, I2, new R3.RemotePlayer()), new R3.RemotePlayerController(i(this, I2)), h(this, G3, { [R3.RemotePlayerEventType.IS_CONNECTED_CHANGED]: ({ value: t2 }) => { 45818 t2 === true ? (h(this, at2, "connected"), this.dispatchEvent(new Event("connect"))) : (A3(this, ne3, je2).call(this), h(this, at2, "disconnected"), this.dispatchEvent(new Event("disconnect"))); 45819 }, [R3.RemotePlayerEventType.DURATION_CHANGED]: () => { 45820 i(this, y).dispatchEvent(new Event("durationchange")); 45821 }, [R3.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]: () => { 45822 i(this, y).dispatchEvent(new Event("volumechange")); 45823 }, [R3.RemotePlayerEventType.IS_MUTED_CHANGED]: () => { 45824 i(this, y).dispatchEvent(new Event("volumechange")); 45825 }, [R3.RemotePlayerEventType.CURRENT_TIME_CHANGED]: () => { 45826 var t2; 45827 (t2 = i(this, B3, ot3)) != null && t2.isMediaLoaded && i(this, y).dispatchEvent(new Event("timeupdate")); 45828 }, [R3.RemotePlayerEventType.VIDEO_INFO_CHANGED]: () => { 45829 i(this, y).dispatchEvent(new Event("resize")); 45830 }, [R3.RemotePlayerEventType.IS_PAUSED_CHANGED]: () => { 45831 i(this, y).dispatchEvent(new Event(this.paused ? "pause" : "play")); 45832 }, [R3.RemotePlayerEventType.PLAYER_STATE_CHANGED]: () => { 45833 var t2, s; 45834 ((t2 = i(this, B3, ot3)) == null ? void 0 : t2.playerState) !== chrome.cast.media.PlayerState.PAUSED && i(this, y).dispatchEvent(new Event({ [chrome.cast.media.PlayerState.PLAYING]: "playing", [chrome.cast.media.PlayerState.BUFFERING]: "waiting", [chrome.cast.media.PlayerState.IDLE]: "emptied" }[(s = i(this, B3, ot3)) == null ? void 0 : s.playerState])); 45835 }, [R3.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]: async () => { 45836 var t2; 45837 (t2 = i(this, B3, ot3)) != null && t2.isMediaLoaded && (await Promise.resolve(), A3(this, ae2, He3).call(this)); 45838 } })); 45839}, ae2 = /* @__PURE__ */ new WeakSet(), He3 = function() { 45840 A3(this, Bt2, Re2).call(this); 45841}, Bt2 = /* @__PURE__ */ new WeakSet(), Re2 = async function() { 45842 var x2, a2, m2, S3, w4; 45843 if (!i(this, B3, ot3)) return; 45844 let s = ((a2 = (x2 = i(this, I2).mediaInfo) == null ? void 0 : x2.tracks) != null ? a2 : []).filter(({ type: k3 }) => k3 === chrome.cast.media.TrackType.TEXT), n2 = [...i(this, y).textTracks].filter(({ kind: k3 }) => k3 === "subtitles" || k3 === "captions"), l2 = s.map(({ language: k3, name: L, trackId: pt4 }) => { 45845 var st3; 45846 let { mode: O2 } = (st3 = n2.find((N3) => N3.language === k3 && N3.label === L)) != null ? st3 : {}; 45847 return O2 ? { mode: O2, trackId: pt4 } : false; 45848 }).filter(Boolean), d2 = l2.filter(({ mode: k3 }) => k3 !== "showing").map(({ trackId: k3 }) => k3), T3 = l2.find(({ mode: k3 }) => k3 === "showing"), C4 = (w4 = (S3 = (m2 = Nt3()) == null ? void 0 : m2.getSessionObj().media[0]) == null ? void 0 : S3.activeTrackIds) != null ? w4 : [], F4 = C4; 45849 if (C4.length && (F4 = F4.filter((k3) => !d2.includes(k3))), T3 != null && T3.trackId && (F4 = [...F4, T3.trackId]), F4 = [...new Set(F4)], !((k3, L) => k3.length === L.length && k3.every((pt4) => L.includes(pt4)))(C4, F4)) try { 45850 let k3 = new chrome.cast.media.EditTracksInfoRequest(F4); 45851 await Fe3(k3); 45852 } catch (k3) { 45853 console.error(k3); 45854 } 45855}; 45856var $e3 = (e) => { 45857 var r10, t2, s, n2, l2, f, d2, b3, C4, ze3; 45858 return t2 = class extends e { 45859 constructor() { 45860 super(...arguments); 45861 u(this, d2); 45862 u(this, C4); 45863 u(this, s, { paused: false }); 45864 u(this, n2, Ae3()); 45865 u(this, l2, void 0); 45866 u(this, f, void 0); 45867 } 45868 get remote() { 45869 return i(this, f) ? i(this, f) : Ke3() ? (qe(), V3.set(this, { loadOnPrompt: () => A3(this, C4, ze3).call(this) }), h(this, f, new re3(this))) : super.remote; 45870 } 45871 attributeChangedCallback(a2, m2, S3) { 45872 if (super.attributeChangedCallback(a2, m2, S3), a2 === "cast-receiver" && S3) { 45873 i(this, n2).receiverApplicationId = S3; 45874 return; 45875 } 45876 if (i(this, d2, b3)) switch (a2) { 45877 case "cast-stream-type": 45878 case "cast-src": 45879 this.load(); 45880 break; 45881 } 45882 } 45883 async load() { 45884 var L, pt4; 45885 if (!i(this, d2, b3)) return super.load(); 45886 let a2 = new chrome.cast.media.MediaInfo(this.castSrc, this.castContentType); 45887 a2.customData = this.castCustomData; 45888 let m2 = [...this.querySelectorAll("track")].filter(({ kind: O2, src: st3 }) => st3 && (O2 === "subtitles" || O2 === "captions")), S3 = [], w4 = 0; 45889 m2.length && (a2.tracks = m2.map((O2) => { 45890 let st3 = ++w4; 45891 S3.length === 0 && O2.track.mode === "showing" && S3.push(st3); 45892 let N3 = new chrome.cast.media.Track(st3, chrome.cast.media.TrackType.TEXT); 45893 return N3.trackContentId = O2.src, N3.trackContentType = "text/vtt", N3.subtype = O2.kind === "captions" ? chrome.cast.media.TextTrackType.CAPTIONS : chrome.cast.media.TextTrackType.SUBTITLES, N3.name = O2.label, N3.language = O2.srclang, N3; 45894 })), this.castStreamType === "live" ? a2.streamType = chrome.cast.media.StreamType.LIVE : a2.streamType = chrome.cast.media.StreamType.BUFFERED, a2.metadata = new chrome.cast.media.GenericMediaMetadata(), a2.metadata.title = this.title, a2.metadata.images = [{ url: this.poster }]; 45895 let k3 = new chrome.cast.media.LoadRequest(a2); 45896 k3.currentTime = (L = super.currentTime) != null ? L : 0, k3.autoplay = !i(this, s).paused, k3.activeTrackIds = S3, await ((pt4 = Nt3()) == null ? void 0 : pt4.loadMedia(k3)), this.dispatchEvent(new Event("volumechange")); 45897 } 45898 play() { 45899 var a2; 45900 if (i(this, d2, b3)) { 45901 i(this, d2, b3).isPaused && ((a2 = i(this, d2, b3).controller) == null || a2.playOrPause()); 45902 return; 45903 } 45904 return super.play(); 45905 } 45906 pause() { 45907 var a2; 45908 if (i(this, d2, b3)) { 45909 i(this, d2, b3).isPaused || (a2 = i(this, d2, b3).controller) == null || a2.playOrPause(); 45910 return; 45911 } 45912 super.pause(); 45913 } 45914 get castOptions() { 45915 return i(this, n2); 45916 } 45917 get castReceiver() { 45918 var a2; 45919 return (a2 = this.getAttribute("cast-receiver")) != null ? a2 : void 0; 45920 } 45921 set castReceiver(a2) { 45922 this.castReceiver != a2 && this.setAttribute("cast-receiver", `${a2}`); 45923 } 45924 get castSrc() { 45925 var a2, m2, S3; 45926 return (S3 = (m2 = this.getAttribute("cast-src")) != null ? m2 : (a2 = this.querySelector("source")) == null ? void 0 : a2.src) != null ? S3 : this.currentSrc; 45927 } 45928 set castSrc(a2) { 45929 this.castSrc != a2 && this.setAttribute("cast-src", `${a2}`); 45930 } 45931 get castContentType() { 45932 var a2; 45933 return (a2 = this.getAttribute("cast-content-type")) != null ? a2 : void 0; 45934 } 45935 set castContentType(a2) { 45936 this.setAttribute("cast-content-type", `${a2}`); 45937 } 45938 get castStreamType() { 45939 var a2, m2; 45940 return (m2 = (a2 = this.getAttribute("cast-stream-type")) != null ? a2 : this.streamType) != null ? m2 : void 0; 45941 } 45942 set castStreamType(a2) { 45943 this.setAttribute("cast-stream-type", `${a2}`); 45944 } 45945 get castCustomData() { 45946 return i(this, l2); 45947 } 45948 set castCustomData(a2) { 45949 let m2 = typeof a2; 45950 if (!["object", "undefined"].includes(m2)) { 45951 console.error(`castCustomData must be nullish or an object but value was of type ${m2}`); 45952 return; 45953 } 45954 h(this, l2, a2); 45955 } 45956 get readyState() { 45957 if (i(this, d2, b3)) switch (i(this, d2, b3).playerState) { 45958 case chrome.cast.media.PlayerState.IDLE: 45959 return 0; 45960 case chrome.cast.media.PlayerState.BUFFERING: 45961 return 2; 45962 default: 45963 return 3; 45964 } 45965 return super.readyState; 45966 } 45967 get paused() { 45968 return i(this, d2, b3) ? i(this, d2, b3).isPaused : super.paused; 45969 } 45970 get muted() { 45971 var a2; 45972 return i(this, d2, b3) ? (a2 = i(this, d2, b3)) == null ? void 0 : a2.isMuted : super.muted; 45973 } 45974 set muted(a2) { 45975 var m2; 45976 if (i(this, d2, b3)) { 45977 (a2 && !i(this, d2, b3).isMuted || !a2 && i(this, d2, b3).isMuted) && ((m2 = i(this, d2, b3).controller) == null || m2.muteOrUnmute()); 45978 return; 45979 } 45980 super.muted = a2; 45981 } 45982 get volume() { 45983 var a2, m2; 45984 return i(this, d2, b3) ? (m2 = (a2 = i(this, d2, b3)) == null ? void 0 : a2.volumeLevel) != null ? m2 : 1 : super.volume; 45985 } 45986 set volume(a2) { 45987 var m2; 45988 if (i(this, d2, b3)) { 45989 i(this, d2, b3).volumeLevel = +a2, (m2 = i(this, d2, b3).controller) == null || m2.setVolumeLevel(); 45990 return; 45991 } 45992 super.volume = a2; 45993 } 45994 get duration() { 45995 var a2, m2, S3; 45996 return i(this, d2, b3) && ((a2 = i(this, d2, b3)) != null && a2.isMediaLoaded) ? (S3 = (m2 = i(this, d2, b3)) == null ? void 0 : m2.duration) != null ? S3 : NaN : super.duration; 45997 } 45998 get currentTime() { 45999 var a2, m2, S3; 46000 return i(this, d2, b3) && ((a2 = i(this, d2, b3)) != null && a2.isMediaLoaded) ? (S3 = (m2 = i(this, d2, b3)) == null ? void 0 : m2.currentTime) != null ? S3 : 0 : super.currentTime; 46001 } 46002 set currentTime(a2) { 46003 var m2; 46004 if (i(this, d2, b3)) { 46005 i(this, d2, b3).currentTime = a2, (m2 = i(this, d2, b3).controller) == null || m2.seek(); 46006 return; 46007 } 46008 super.currentTime = a2; 46009 } 46010 }, s = /* @__PURE__ */ new WeakMap(), n2 = /* @__PURE__ */ new WeakMap(), l2 = /* @__PURE__ */ new WeakMap(), f = /* @__PURE__ */ new WeakMap(), d2 = /* @__PURE__ */ new WeakSet(), b3 = function() { 46011 var a2, m2; 46012 return (m2 = (a2 = V3.get(this.remote)) == null ? void 0 : a2.getCastPlayer) == null ? void 0 : m2.call(a2); 46013 }, C4 = /* @__PURE__ */ new WeakSet(), ze3 = async function() { 46014 i(this, s).paused = Jt2(t2.prototype, this, "paused"), Jt2(t2.prototype, this, "pause").call(this), this.muted = Jt2(t2.prototype, this, "muted"); 46015 try { 46016 await this.load(); 46017 } catch (a2) { 46018 console.error(a2); 46019 } 46020 }, E2(t2, "observedAttributes", [...(r10 = e.observedAttributes) != null ? r10 : [], "cast-src", "cast-content-type", "cast-stream-type", "cast-receiver"]), t2; 46021}; 46022var K2 = class extends Event { 46023 constructor(t2, s) { 46024 super(t2); 46025 E2(this, "track"); 46026 this.track = s.track; 46027 } 46028}; 46029var Ce3 = /* @__PURE__ */ new WeakMap(); 46030function c(e) { 46031 var r10; 46032 return (r10 = Ce3.get(e)) != null ? r10 : vi2(e, {}); 46033} 46034function vi2(e, r10) { 46035 let t2 = Ce3.get(e); 46036 return t2 || Ce3.set(e, t2 = {}), Object.assign(t2, r10); 46037} 46038function de3(e, r10) { 46039 let t2 = e.videoTracks; 46040 c(r10).media = e, c(r10).renditionSet || (c(r10).renditionSet = /* @__PURE__ */ new Set()); 46041 let s = c(t2).trackSet; 46042 s.add(r10); 46043 let n2 = s.size - 1; 46044 n2 in ct3.prototype || Object.defineProperty(ct3.prototype, n2, { get() { 46045 return [...c(this).trackSet][n2]; 46046 } }), queueMicrotask(() => { 46047 t2.dispatchEvent(new K2("addtrack", { track: r10 })); 46048 }); 46049} 46050function ue2(e) { 46051 var s; 46052 let r10 = (s = c(e).media) == null ? void 0 : s.videoTracks; 46053 if (!r10) return; 46054 c(r10).trackSet.delete(e), queueMicrotask(() => { 46055 r10.dispatchEvent(new K2("removetrack", { track: e })); 46056 }); 46057} 46058function Xe3(e) { 46059 var s; 46060 let r10 = (s = c(e).media.videoTracks) != null ? s : [], t2 = false; 46061 for (let n2 of r10) n2 !== e && (n2.selected = false, t2 = true); 46062 if (t2) { 46063 if (c(r10).changeRequested) return; 46064 c(r10).changeRequested = true, queueMicrotask(() => { 46065 delete c(r10).changeRequested, r10.dispatchEvent(new Event("change")); 46066 }); 46067 } 46068} 46069var W2; 46070var H3; 46071var $3; 46072var ut3; 46073var Kt2; 46074var ct3 = class extends EventTarget { 46075 constructor() { 46076 super(); 46077 u(this, ut3); 46078 u(this, W2, void 0); 46079 u(this, H3, void 0); 46080 u(this, $3, void 0); 46081 c(this).trackSet = /* @__PURE__ */ new Set(); 46082 } 46083 [Symbol.iterator]() { 46084 return i(this, ut3, Kt2).values(); 46085 } 46086 get length() { 46087 return i(this, ut3, Kt2).size; 46088 } 46089 getTrackById(t2) { 46090 var s; 46091 return (s = [...i(this, ut3, Kt2)].find((n2) => n2.id === t2)) != null ? s : null; 46092 } 46093 get selectedIndex() { 46094 return [...i(this, ut3, Kt2)].findIndex((t2) => t2.selected); 46095 } 46096 get onaddtrack() { 46097 return i(this, W2); 46098 } 46099 set onaddtrack(t2) { 46100 i(this, W2) && (this.removeEventListener("addtrack", i(this, W2)), h(this, W2, void 0)), typeof t2 == "function" && (h(this, W2, t2), this.addEventListener("addtrack", t2)); 46101 } 46102 get onremovetrack() { 46103 return i(this, H3); 46104 } 46105 set onremovetrack(t2) { 46106 i(this, H3) && (this.removeEventListener("removetrack", i(this, H3)), h(this, H3, void 0)), typeof t2 == "function" && (h(this, H3, t2), this.addEventListener("removetrack", t2)); 46107 } 46108 get onchange() { 46109 return i(this, $3); 46110 } 46111 set onchange(t2) { 46112 i(this, $3) && (this.removeEventListener("change", i(this, $3)), h(this, $3, void 0)), typeof t2 == "function" && (h(this, $3, t2), this.addEventListener("change", t2)); 46113 } 46114}; 46115W2 = /* @__PURE__ */ new WeakMap(), H3 = /* @__PURE__ */ new WeakMap(), $3 = /* @__PURE__ */ new WeakMap(), ut3 = /* @__PURE__ */ new WeakSet(), Kt2 = function() { 46116 return c(this).trackSet; 46117}; 46118var q2 = class extends Event { 46119 constructor(t2, s) { 46120 super(t2); 46121 E2(this, "rendition"); 46122 this.rendition = s.rendition; 46123 } 46124}; 46125function Je3(e, r10) { 46126 let t2 = c(e).media.videoRenditions; 46127 c(r10).media = c(e).media, c(r10).track = e; 46128 let s = c(e).renditionSet; 46129 s.add(r10); 46130 let n2 = s.size - 1; 46131 n2 in ht2.prototype || Object.defineProperty(ht2.prototype, n2, { get() { 46132 return bt3(this)[n2]; 46133 } }), queueMicrotask(() => { 46134 e.selected && t2.dispatchEvent(new q2("addrendition", { rendition: r10 })); 46135 }); 46136} 46137function Qe3(e) { 46138 let r10 = c(e).media.videoRenditions, t2 = c(e).track; 46139 c(t2).renditionSet.delete(e), queueMicrotask(() => { 46140 c(e).track.selected && r10.dispatchEvent(new q2("removerendition", { rendition: e })); 46141 }); 46142} 46143function Ze2(e) { 46144 let r10 = c(e).media.videoRenditions; 46145 !r10 || c(r10).changeRequested || (c(r10).changeRequested = true, queueMicrotask(() => { 46146 delete c(r10).changeRequested, c(e).track.selected && r10.dispatchEvent(new Event("change")); 46147 })); 46148} 46149function bt3(e) { 46150 return [...c(e).media.videoTracks].filter((t2) => t2.selected).flatMap((t2) => [...c(t2).renditionSet]); 46151} 46152var z2; 46153var X3; 46154var J3; 46155var ht2 = class extends EventTarget { 46156 constructor() { 46157 super(...arguments); 46158 u(this, z2, void 0); 46159 u(this, X3, void 0); 46160 u(this, J3, void 0); 46161 } 46162 [Symbol.iterator]() { 46163 return bt3(this).values(); 46164 } 46165 get length() { 46166 return bt3(this).length; 46167 } 46168 getRenditionById(t2) { 46169 var s; 46170 return (s = bt3(this).find((n2) => `${n2.id}` == `${t2}`)) != null ? s : null; 46171 } 46172 get selectedIndex() { 46173 return bt3(this).findIndex((t2) => t2.selected); 46174 } 46175 set selectedIndex(t2) { 46176 for (let [s, n2] of bt3(this).entries()) n2.selected = s === t2; 46177 } 46178 get onaddrendition() { 46179 return i(this, z2); 46180 } 46181 set onaddrendition(t2) { 46182 i(this, z2) && (this.removeEventListener("addrendition", i(this, z2)), h(this, z2, void 0)), typeof t2 == "function" && (h(this, z2, t2), this.addEventListener("addrendition", t2)); 46183 } 46184 get onremoverendition() { 46185 return i(this, X3); 46186 } 46187 set onremoverendition(t2) { 46188 i(this, X3) && (this.removeEventListener("removerendition", i(this, X3)), h(this, X3, void 0)), typeof t2 == "function" && (h(this, X3, t2), this.addEventListener("removerendition", t2)); 46189 } 46190 get onchange() { 46191 return i(this, J3); 46192 } 46193 set onchange(t2) { 46194 i(this, J3) && (this.removeEventListener("change", i(this, J3)), h(this, J3, void 0)), typeof t2 == "function" && (h(this, J3, t2), this.addEventListener("change", t2)); 46195 } 46196}; 46197z2 = /* @__PURE__ */ new WeakMap(), X3 = /* @__PURE__ */ new WeakMap(), J3 = /* @__PURE__ */ new WeakMap(); 46198var vt3; 46199var qt2 = class { 46200 constructor() { 46201 E2(this, "src"); 46202 E2(this, "id"); 46203 E2(this, "width"); 46204 E2(this, "height"); 46205 E2(this, "bitrate"); 46206 E2(this, "frameRate"); 46207 E2(this, "codec"); 46208 u(this, vt3, false); 46209 } 46210 get selected() { 46211 return i(this, vt3); 46212 } 46213 set selected(r10) { 46214 i(this, vt3) !== r10 && (h(this, vt3, r10), Ze2(this)); 46215 } 46216}; 46217vt3 = /* @__PURE__ */ new WeakMap(); 46218var yt3; 46219var At3 = class { 46220 constructor() { 46221 E2(this, "id"); 46222 E2(this, "kind"); 46223 E2(this, "label", ""); 46224 E2(this, "language", ""); 46225 E2(this, "sourceBuffer"); 46226 u(this, yt3, false); 46227 } 46228 addRendition(r10, t2, s, n2, l2, f) { 46229 let d2 = new qt2(); 46230 return d2.src = r10, d2.width = t2, d2.height = s, d2.frameRate = f, d2.bitrate = l2, d2.codec = n2, Je3(this, d2), d2; 46231 } 46232 removeRendition(r10) { 46233 Qe3(r10); 46234 } 46235 get selected() { 46236 return i(this, yt3); 46237 } 46238 set selected(r10) { 46239 i(this, yt3) !== r10 && (h(this, yt3, r10), r10 === true && Xe3(this)); 46240 } 46241}; 46242yt3 = /* @__PURE__ */ new WeakMap(); 46243function ti(e, r10) { 46244 let t2 = c(e).media.audioRenditions; 46245 c(r10).media = c(e).media, c(r10).track = e; 46246 let s = c(e).renditionSet; 46247 s.add(r10); 46248 let n2 = s.size - 1; 46249 n2 in lt3.prototype || Object.defineProperty(lt3.prototype, n2, { get() { 46250 return kt3(this)[n2]; 46251 } }), queueMicrotask(() => { 46252 e.enabled && t2.dispatchEvent(new q2("addrendition", { rendition: r10 })); 46253 }); 46254} 46255function ei(e) { 46256 let r10 = c(e).media.audioRenditions, t2 = c(e).track; 46257 c(t2).renditionSet.delete(e), queueMicrotask(() => { 46258 c(e).track.enabled && r10.dispatchEvent(new q2("removerendition", { rendition: e })); 46259 }); 46260} 46261function ii(e) { 46262 let r10 = c(e).media.audioRenditions; 46263 !r10 || c(r10).changeRequested || (c(r10).changeRequested = true, queueMicrotask(() => { 46264 delete c(r10).changeRequested, c(e).track.enabled && r10.dispatchEvent(new Event("change")); 46265 })); 46266} 46267function kt3(e) { 46268 return [...c(e).media.audioTracks].filter((t2) => t2.enabled).flatMap((t2) => [...c(t2).renditionSet]); 46269} 46270var Q3; 46271var Z2; 46272var tt3; 46273var lt3 = class extends EventTarget { 46274 constructor() { 46275 super(...arguments); 46276 u(this, Q3, void 0); 46277 u(this, Z2, void 0); 46278 u(this, tt3, void 0); 46279 } 46280 [Symbol.iterator]() { 46281 return kt3(this).values(); 46282 } 46283 get length() { 46284 return kt3(this).length; 46285 } 46286 getRenditionById(t2) { 46287 var s; 46288 return (s = kt3(this).find((n2) => `${n2.id}` == `${t2}`)) != null ? s : null; 46289 } 46290 get selectedIndex() { 46291 return kt3(this).findIndex((t2) => t2.selected); 46292 } 46293 set selectedIndex(t2) { 46294 for (let [s, n2] of kt3(this).entries()) n2.selected = s === t2; 46295 } 46296 get onaddrendition() { 46297 return i(this, Q3); 46298 } 46299 set onaddrendition(t2) { 46300 i(this, Q3) && (this.removeEventListener("addrendition", i(this, Q3)), h(this, Q3, void 0)), typeof t2 == "function" && (h(this, Q3, t2), this.addEventListener("addrendition", t2)); 46301 } 46302 get onremoverendition() { 46303 return i(this, Z2); 46304 } 46305 set onremoverendition(t2) { 46306 i(this, Z2) && (this.removeEventListener("removerendition", i(this, Z2)), h(this, Z2, void 0)), typeof t2 == "function" && (h(this, Z2, t2), this.addEventListener("removerendition", t2)); 46307 } 46308 get onchange() { 46309 return i(this, tt3); 46310 } 46311 set onchange(t2) { 46312 i(this, tt3) && (this.removeEventListener("change", i(this, tt3)), h(this, tt3, void 0)), typeof t2 == "function" && (h(this, tt3, t2), this.addEventListener("change", t2)); 46313 } 46314}; 46315Q3 = /* @__PURE__ */ new WeakMap(), Z2 = /* @__PURE__ */ new WeakMap(), tt3 = /* @__PURE__ */ new WeakMap(); 46316var St2; 46317var Ft2 = class { 46318 constructor() { 46319 E2(this, "src"); 46320 E2(this, "id"); 46321 E2(this, "bitrate"); 46322 E2(this, "codec"); 46323 u(this, St2, false); 46324 } 46325 get selected() { 46326 return i(this, St2); 46327 } 46328 set selected(r10) { 46329 i(this, St2) !== r10 && (h(this, St2, r10), ii(this)); 46330 } 46331}; 46332St2 = /* @__PURE__ */ new WeakMap(); 46333function he3(e, r10) { 46334 let t2 = e.audioTracks; 46335 c(r10).media = e, c(r10).renditionSet || (c(r10).renditionSet = /* @__PURE__ */ new Set()); 46336 let s = c(t2).trackSet; 46337 s.add(r10); 46338 let n2 = s.size - 1; 46339 n2 in ft4.prototype || Object.defineProperty(ft4.prototype, n2, { get() { 46340 return [...c(this).trackSet][n2]; 46341 } }), queueMicrotask(() => { 46342 t2.dispatchEvent(new K2("addtrack", { track: r10 })); 46343 }); 46344} 46345function le3(e) { 46346 var s; 46347 let r10 = (s = c(e).media) == null ? void 0 : s.audioTracks; 46348 if (!r10) return; 46349 c(r10).trackSet.delete(e), queueMicrotask(() => { 46350 r10.dispatchEvent(new K2("removetrack", { track: e })); 46351 }); 46352} 46353function ri(e) { 46354 let r10 = c(e).media.audioTracks; 46355 !r10 || c(r10).changeRequested || (c(r10).changeRequested = true, queueMicrotask(() => { 46356 delete c(r10).changeRequested, r10.dispatchEvent(new Event("change")); 46357 })); 46358} 46359var et2; 46360var it3; 46361var rt2; 46362var Rt3; 46363var ce2; 46364var ft4 = class extends EventTarget { 46365 constructor() { 46366 super(); 46367 u(this, Rt3); 46368 u(this, et2, void 0); 46369 u(this, it3, void 0); 46370 u(this, rt2, void 0); 46371 c(this).trackSet = /* @__PURE__ */ new Set(); 46372 } 46373 [Symbol.iterator]() { 46374 return i(this, Rt3, ce2).values(); 46375 } 46376 get length() { 46377 return i(this, Rt3, ce2).size; 46378 } 46379 getTrackById(t2) { 46380 var s; 46381 return (s = [...i(this, Rt3, ce2)].find((n2) => n2.id === t2)) != null ? s : null; 46382 } 46383 get onaddtrack() { 46384 return i(this, et2); 46385 } 46386 set onaddtrack(t2) { 46387 i(this, et2) && (this.removeEventListener("addtrack", i(this, et2)), h(this, et2, void 0)), typeof t2 == "function" && (h(this, et2, t2), this.addEventListener("addtrack", t2)); 46388 } 46389 get onremovetrack() { 46390 return i(this, it3); 46391 } 46392 set onremovetrack(t2) { 46393 i(this, it3) && (this.removeEventListener("removetrack", i(this, it3)), h(this, it3, void 0)), typeof t2 == "function" && (h(this, it3, t2), this.addEventListener("removetrack", t2)); 46394 } 46395 get onchange() { 46396 return i(this, rt2); 46397 } 46398 set onchange(t2) { 46399 i(this, rt2) && (this.removeEventListener("change", i(this, rt2)), h(this, rt2, void 0)), typeof t2 == "function" && (h(this, rt2, t2), this.addEventListener("change", t2)); 46400 } 46401}; 46402et2 = /* @__PURE__ */ new WeakMap(), it3 = /* @__PURE__ */ new WeakMap(), rt2 = /* @__PURE__ */ new WeakMap(), Rt3 = /* @__PURE__ */ new WeakSet(), ce2 = function() { 46403 return c(this).trackSet; 46404}; 46405var Ct3; 46406var _t3 = class { 46407 constructor() { 46408 E2(this, "id"); 46409 E2(this, "kind"); 46410 E2(this, "label", ""); 46411 E2(this, "language", ""); 46412 E2(this, "sourceBuffer"); 46413 u(this, Ct3, false); 46414 } 46415 addRendition(r10, t2, s) { 46416 let n2 = new Ft2(); 46417 return n2.src = r10, n2.codec = t2, n2.bitrate = s, ti(this, n2), n2; 46418 } 46419 removeRendition(r10) { 46420 ei(r10); 46421 } 46422 get enabled() { 46423 return i(this, Ct3); 46424 } 46425 set enabled(r10) { 46426 i(this, Ct3) !== r10 && (h(this, Ct3, r10), ri(this)); 46427 } 46428}; 46429Ct3 = /* @__PURE__ */ new WeakMap(); 46430var si2 = fe3(globalThis.HTMLMediaElement, "video"); 46431var ni2 = fe3(globalThis.HTMLMediaElement, "audio"); 46432function oi2(e) { 46433 if (!(e != null && e.prototype)) return e; 46434 let r10 = fe3(e, "video"); 46435 (!r10 || `${r10}`.includes("[native code]")) && Object.defineProperty(e.prototype, "videoTracks", { get() { 46436 return yi2(this); 46437 } }); 46438 let t2 = fe3(e, "audio"); 46439 (!t2 || `${t2}`.includes("[native code]")) && Object.defineProperty(e.prototype, "audioTracks", { get() { 46440 return Ai2(this); 46441 } }), "addVideoTrack" in e.prototype || (e.prototype.addVideoTrack = function(l2, f = "", d2 = "") { 46442 let T3 = new At3(); 46443 return T3.kind = l2, T3.label = f, T3.language = d2, de3(this, T3), T3; 46444 }), "removeVideoTrack" in e.prototype || (e.prototype.removeVideoTrack = ue2), "addAudioTrack" in e.prototype || (e.prototype.addAudioTrack = function(l2, f = "", d2 = "") { 46445 let T3 = new _t3(); 46446 return T3.kind = l2, T3.label = f, T3.language = d2, he3(this, T3), T3; 46447 }), "removeAudioTrack" in e.prototype || (e.prototype.removeAudioTrack = le3), "videoRenditions" in e.prototype || Object.defineProperty(e.prototype, "videoRenditions", { get() { 46448 return s(this); 46449 } }); 46450 let s = (l2) => { 46451 let f = c(l2).videoRenditions; 46452 return f || (f = new ht2(), c(f).media = l2, c(l2).videoRenditions = f), f; 46453 }; 46454 "audioRenditions" in e.prototype || Object.defineProperty(e.prototype, "audioRenditions", { get() { 46455 return n2(this); 46456 } }); 46457 let n2 = (l2) => { 46458 let f = c(l2).audioRenditions; 46459 return f || (f = new lt3(), c(f).media = l2, c(l2).audioRenditions = f), f; 46460 }; 46461 return e; 46462} 46463function fe3(e, r10) { 46464 var t2; 46465 if (e != null && e.prototype) return (t2 = Object.getOwnPropertyDescriptor(e.prototype, `${r10}Tracks`)) == null ? void 0 : t2.get; 46466} 46467function yi2(e) { 46468 var t2; 46469 let r10 = c(e).videoTracks; 46470 if (!r10 && (r10 = new ct3(), c(e).videoTracks = r10, si2)) { 46471 let s = si2.call((t2 = e.nativeEl) != null ? t2 : e); 46472 for (let n2 of s) de3(e, n2); 46473 s.addEventListener("change", () => { 46474 r10.dispatchEvent(new Event("change")); 46475 }), s.addEventListener("addtrack", (n2) => { 46476 if ([...r10].some((l2) => l2 instanceof At3)) { 46477 for (let l2 of s) ue2(l2); 46478 return; 46479 } 46480 de3(e, n2.track); 46481 }), s.addEventListener("removetrack", (n2) => { 46482 ue2(n2.track); 46483 }); 46484 } 46485 return r10; 46486} 46487function Ai2(e) { 46488 var t2; 46489 let r10 = c(e).audioTracks; 46490 if (!r10 && (r10 = new ft4(), c(e).audioTracks = r10, ni2)) { 46491 let s = ni2.call((t2 = e.nativeEl) != null ? t2 : e); 46492 for (let n2 of s) he3(e, n2); 46493 s.addEventListener("change", () => { 46494 r10.dispatchEvent(new Event("change")); 46495 }), s.addEventListener("addtrack", (n2) => { 46496 if ([...r10].some((l2) => l2 instanceof _t3)) { 46497 for (let l2 of s) le3(l2); 46498 return; 46499 } 46500 he3(e, n2.track); 46501 }), s.addEventListener("removetrack", (n2) => { 46502 le3(n2.track); 46503 }); 46504 } 46505 return r10; 46506} 46507ve2.push("castchange", "entercast", "leavecast"); 46508var o = { BEACON_COLLECTION_DOMAIN: "beacon-collection-domain", CUSTOM_DOMAIN: "custom-domain", DEBUG: "debug", DISABLE_TRACKING: "disable-tracking", DISABLE_COOKIES: "disable-cookies", DRM_TOKEN: "drm-token", PLAYBACK_TOKEN: "playback-token", ENV_KEY: "env-key", MAX_RESOLUTION: "max-resolution", MIN_RESOLUTION: "min-resolution", RENDITION_ORDER: "rendition-order", PROGRAM_START_TIME: "program-start-time", PROGRAM_END_TIME: "program-end-time", ASSET_START_TIME: "asset-start-time", ASSET_END_TIME: "asset-end-time", METADATA_URL: "metadata-url", PLAYBACK_ID: "playback-id", PLAYER_SOFTWARE_NAME: "player-software-name", PLAYER_SOFTWARE_VERSION: "player-software-version", PREFER_CMCD: "prefer-cmcd", PREFER_PLAYBACK: "prefer-playback", START_TIME: "start-time", STREAM_TYPE: "stream-type", TARGET_LIVE_WINDOW: "target-live-window", LIVE_EDGE_OFFSET: "live-edge-offset", TYPE: "type" }; 46509var Ui = Object.values(o); 46510var Yi = Ie3(); 46511var ji = "mux-video"; 46512var M2; 46513var Ot2; 46514var Yt2; 46515var Pt3; 46516var jt2; 46517var Wt2; 46518var Ht3; 46519var $t2; 46520var zt2; 46521var It3; 46522var pe3; 46523var _e3 = class extends Zt2 { 46524 constructor() { 46525 super(); 46526 u(this, It3); 46527 u(this, M2, void 0); 46528 u(this, Ot2, void 0); 46529 u(this, Yt2, void 0); 46530 u(this, Pt3, {}); 46531 u(this, jt2, {}); 46532 u(this, Wt2, void 0); 46533 u(this, Ht3, void 0); 46534 u(this, $t2, void 0); 46535 u(this, zt2, void 0); 46536 h(this, Yt2, Nr2()); 46537 } 46538 static get observedAttributes() { 46539 var t2; 46540 return [...Ui, ...(t2 = Zt2.observedAttributes) != null ? t2 : []]; 46541 } 46542 get preferCmcd() { 46543 var t2; 46544 return (t2 = this.getAttribute(o.PREFER_CMCD)) != null ? t2 : void 0; 46545 } 46546 set preferCmcd(t2) { 46547 t2 !== this.preferCmcd && (t2 ? Ut2.includes(t2) ? this.setAttribute(o.PREFER_CMCD, t2) : console.warn(`Invalid value for preferCmcd. Must be one of ${Ut2.join()}`) : this.removeAttribute(o.PREFER_CMCD)); 46548 } 46549 get playerInitTime() { 46550 return i(this, Yt2); 46551 } 46552 get playerSoftwareName() { 46553 var t2; 46554 return (t2 = i(this, $t2)) != null ? t2 : ji; 46555 } 46556 set playerSoftwareName(t2) { 46557 h(this, $t2, t2); 46558 } 46559 get playerSoftwareVersion() { 46560 var t2; 46561 return (t2 = i(this, Ht3)) != null ? t2 : Yi; 46562 } 46563 set playerSoftwareVersion(t2) { 46564 h(this, Ht3, t2); 46565 } 46566 get _hls() { 46567 var t2; 46568 return (t2 = i(this, M2)) == null ? void 0 : t2.engine; 46569 } 46570 get mux() { 46571 var t2; 46572 return (t2 = this.nativeEl) == null ? void 0 : t2.mux; 46573 } 46574 get error() { 46575 var t2; 46576 return (t2 = Rt2(this.nativeEl)) != null ? t2 : null; 46577 } 46578 get errorTranslator() { 46579 return i(this, zt2); 46580 } 46581 set errorTranslator(t2) { 46582 h(this, zt2, t2); 46583 } 46584 get src() { 46585 return this.getAttribute("src"); 46586 } 46587 set src(t2) { 46588 t2 !== this.src && (t2 == null ? this.removeAttribute("src") : this.setAttribute("src", t2)); 46589 } 46590 get type() { 46591 var t2; 46592 return (t2 = this.getAttribute(o.TYPE)) != null ? t2 : void 0; 46593 } 46594 set type(t2) { 46595 t2 !== this.type && (t2 ? this.setAttribute(o.TYPE, t2) : this.removeAttribute(o.TYPE)); 46596 } 46597 get autoplay() { 46598 let t2 = this.getAttribute("autoplay"); 46599 return t2 === null ? false : t2 === "" ? true : t2; 46600 } 46601 set autoplay(t2) { 46602 let s = this.autoplay; 46603 t2 !== s && (t2 ? this.setAttribute("autoplay", typeof t2 == "string" ? t2 : "") : this.removeAttribute("autoplay")); 46604 } 46605 get preload() { 46606 let t2 = this.getAttribute("preload"); 46607 return t2 === "" ? "auto" : ["none", "metadata", "auto"].includes(t2) ? t2 : super.preload; 46608 } 46609 set preload(t2) { 46610 t2 != this.getAttribute("preload") && (["", "none", "metadata", "auto"].includes(t2) ? this.setAttribute("preload", t2) : this.removeAttribute("preload")); 46611 } 46612 get debug() { 46613 return this.getAttribute(o.DEBUG) != null; 46614 } 46615 set debug(t2) { 46616 t2 !== this.debug && (t2 ? this.setAttribute(o.DEBUG, "") : this.removeAttribute(o.DEBUG)); 46617 } 46618 get disableTracking() { 46619 return this.hasAttribute(o.DISABLE_TRACKING); 46620 } 46621 set disableTracking(t2) { 46622 t2 !== this.disableTracking && this.toggleAttribute(o.DISABLE_TRACKING, !!t2); 46623 } 46624 get disableCookies() { 46625 return this.hasAttribute(o.DISABLE_COOKIES); 46626 } 46627 set disableCookies(t2) { 46628 t2 !== this.disableCookies && (t2 ? this.setAttribute(o.DISABLE_COOKIES, "") : this.removeAttribute(o.DISABLE_COOKIES)); 46629 } 46630 get startTime() { 46631 let t2 = this.getAttribute(o.START_TIME); 46632 if (t2 == null) return; 46633 let s = +t2; 46634 return Number.isNaN(s) ? void 0 : s; 46635 } 46636 set startTime(t2) { 46637 t2 !== this.startTime && (t2 == null ? this.removeAttribute(o.START_TIME) : this.setAttribute(o.START_TIME, `${t2}`)); 46638 } 46639 get playbackId() { 46640 var t2; 46641 return this.hasAttribute(o.PLAYBACK_ID) ? this.getAttribute(o.PLAYBACK_ID) : (t2 = gt2(this.src)) != null ? t2 : void 0; 46642 } 46643 set playbackId(t2) { 46644 t2 !== this.playbackId && (t2 ? this.setAttribute(o.PLAYBACK_ID, t2) : this.removeAttribute(o.PLAYBACK_ID)); 46645 } 46646 get maxResolution() { 46647 var t2; 46648 return (t2 = this.getAttribute(o.MAX_RESOLUTION)) != null ? t2 : void 0; 46649 } 46650 set maxResolution(t2) { 46651 t2 !== this.maxResolution && (t2 ? this.setAttribute(o.MAX_RESOLUTION, t2) : this.removeAttribute(o.MAX_RESOLUTION)); 46652 } 46653 get minResolution() { 46654 var t2; 46655 return (t2 = this.getAttribute(o.MIN_RESOLUTION)) != null ? t2 : void 0; 46656 } 46657 set minResolution(t2) { 46658 t2 !== this.minResolution && (t2 ? this.setAttribute(o.MIN_RESOLUTION, t2) : this.removeAttribute(o.MIN_RESOLUTION)); 46659 } 46660 get renditionOrder() { 46661 var t2; 46662 return (t2 = this.getAttribute(o.RENDITION_ORDER)) != null ? t2 : void 0; 46663 } 46664 set renditionOrder(t2) { 46665 t2 !== this.renditionOrder && (t2 ? this.setAttribute(o.RENDITION_ORDER, t2) : this.removeAttribute(o.RENDITION_ORDER)); 46666 } 46667 get programStartTime() { 46668 let t2 = this.getAttribute(o.PROGRAM_START_TIME); 46669 if (t2 == null) return; 46670 let s = +t2; 46671 return Number.isNaN(s) ? void 0 : s; 46672 } 46673 set programStartTime(t2) { 46674 t2 == null ? this.removeAttribute(o.PROGRAM_START_TIME) : this.setAttribute(o.PROGRAM_START_TIME, `${t2}`); 46675 } 46676 get programEndTime() { 46677 let t2 = this.getAttribute(o.PROGRAM_END_TIME); 46678 if (t2 == null) return; 46679 let s = +t2; 46680 return Number.isNaN(s) ? void 0 : s; 46681 } 46682 set programEndTime(t2) { 46683 t2 == null ? this.removeAttribute(o.PROGRAM_END_TIME) : this.setAttribute(o.PROGRAM_END_TIME, `${t2}`); 46684 } 46685 get assetStartTime() { 46686 let t2 = this.getAttribute(o.ASSET_START_TIME); 46687 if (t2 == null) return; 46688 let s = +t2; 46689 return Number.isNaN(s) ? void 0 : s; 46690 } 46691 set assetStartTime(t2) { 46692 t2 == null ? this.removeAttribute(o.ASSET_START_TIME) : this.setAttribute(o.ASSET_START_TIME, `${t2}`); 46693 } 46694 get assetEndTime() { 46695 let t2 = this.getAttribute(o.ASSET_END_TIME); 46696 if (t2 == null) return; 46697 let s = +t2; 46698 return Number.isNaN(s) ? void 0 : s; 46699 } 46700 set assetEndTime(t2) { 46701 t2 == null ? this.removeAttribute(o.ASSET_END_TIME) : this.setAttribute(o.ASSET_END_TIME, `${t2}`); 46702 } 46703 get customDomain() { 46704 var t2; 46705 return (t2 = this.getAttribute(o.CUSTOM_DOMAIN)) != null ? t2 : void 0; 46706 } 46707 set customDomain(t2) { 46708 t2 !== this.customDomain && (t2 ? this.setAttribute(o.CUSTOM_DOMAIN, t2) : this.removeAttribute(o.CUSTOM_DOMAIN)); 46709 } 46710 get drmToken() { 46711 var t2; 46712 return (t2 = this.getAttribute(o.DRM_TOKEN)) != null ? t2 : void 0; 46713 } 46714 set drmToken(t2) { 46715 t2 !== this.drmToken && (t2 ? this.setAttribute(o.DRM_TOKEN, t2) : this.removeAttribute(o.DRM_TOKEN)); 46716 } 46717 get playbackToken() { 46718 var t2, s, n2, l2; 46719 if (this.hasAttribute(o.PLAYBACK_TOKEN)) return (t2 = this.getAttribute(o.PLAYBACK_TOKEN)) != null ? t2 : void 0; 46720 if (this.hasAttribute(o.PLAYBACK_ID)) { 46721 let [, f] = Y2((s = this.playbackId) != null ? s : ""); 46722 return (n2 = new URLSearchParams(f).get("token")) != null ? n2 : void 0; 46723 } 46724 if (this.src) return (l2 = new URLSearchParams(this.src).get("token")) != null ? l2 : void 0; 46725 } 46726 set playbackToken(t2) { 46727 t2 !== this.playbackToken && (t2 ? this.setAttribute(o.PLAYBACK_TOKEN, t2) : this.removeAttribute(o.PLAYBACK_TOKEN)); 46728 } 46729 get tokens() { 46730 let t2 = this.getAttribute(o.PLAYBACK_TOKEN), s = this.getAttribute(o.DRM_TOKEN); 46731 return { ...i(this, jt2), ...t2 != null ? { playback: t2 } : {}, ...s != null ? { drm: s } : {} }; 46732 } 46733 set tokens(t2) { 46734 h(this, jt2, t2 != null ? t2 : {}); 46735 } 46736 get ended() { 46737 return xt2(this.nativeEl, this._hls); 46738 } 46739 get envKey() { 46740 var t2; 46741 return (t2 = this.getAttribute(o.ENV_KEY)) != null ? t2 : void 0; 46742 } 46743 set envKey(t2) { 46744 t2 !== this.envKey && (t2 ? this.setAttribute(o.ENV_KEY, t2) : this.removeAttribute(o.ENV_KEY)); 46745 } 46746 get beaconCollectionDomain() { 46747 var t2; 46748 return (t2 = this.getAttribute(o.BEACON_COLLECTION_DOMAIN)) != null ? t2 : void 0; 46749 } 46750 set beaconCollectionDomain(t2) { 46751 t2 !== this.beaconCollectionDomain && (t2 ? this.setAttribute(o.BEACON_COLLECTION_DOMAIN, t2) : this.removeAttribute(o.BEACON_COLLECTION_DOMAIN)); 46752 } 46753 get streamType() { 46754 var t2; 46755 return (t2 = this.getAttribute(o.STREAM_TYPE)) != null ? t2 : Le2(this.nativeEl); 46756 } 46757 set streamType(t2) { 46758 t2 !== this.streamType && (t2 ? this.setAttribute(o.STREAM_TYPE, t2) : this.removeAttribute(o.STREAM_TYPE)); 46759 } 46760 get targetLiveWindow() { 46761 return this.hasAttribute(o.TARGET_LIVE_WINDOW) ? +this.getAttribute(o.TARGET_LIVE_WINDOW) : Ir(this.nativeEl); 46762 } 46763 set targetLiveWindow(t2) { 46764 t2 != this.targetLiveWindow && (t2 == null ? this.removeAttribute(o.TARGET_LIVE_WINDOW) : this.setAttribute(o.TARGET_LIVE_WINDOW, `${+t2}`)); 46765 } 46766 get liveEdgeStart() { 46767 var t2, s; 46768 if (this.hasAttribute(o.LIVE_EDGE_OFFSET)) { 46769 let { liveEdgeOffset: n2 } = this, l2 = (t2 = this.nativeEl.seekable.end(0)) != null ? t2 : 0, f = (s = this.nativeEl.seekable.start(0)) != null ? s : 0; 46770 return Math.max(f, l2 - n2); 46771 } 46772 return Ar2(this.nativeEl); 46773 } 46774 get liveEdgeOffset() { 46775 if (this.hasAttribute(o.LIVE_EDGE_OFFSET)) return +this.getAttribute(o.LIVE_EDGE_OFFSET); 46776 } 46777 set liveEdgeOffset(t2) { 46778 t2 != this.targetLiveWindow && (t2 == null ? this.removeAttribute(o.LIVE_EDGE_OFFSET) : this.setAttribute(o.LIVE_EDGE_OFFSET, `${+t2}`)); 46779 } 46780 get seekable() { 46781 return Fe2(this.nativeEl); 46782 } 46783 async addCuePoints(t2) { 46784 return xe(this.nativeEl, t2); 46785 } 46786 get activeCuePoint() { 46787 return ve(this.nativeEl); 46788 } 46789 get cuePoints() { 46790 return et(this.nativeEl); 46791 } 46792 async addChapters(t2) { 46793 return _e2(this.nativeEl, t2); 46794 } 46795 get activeChapter() { 46796 return ke2(this.nativeEl); 46797 } 46798 get chapters() { 46799 return tt2(this.nativeEl); 46800 } 46801 getStartDate() { 46802 return rt(this.nativeEl, this._hls); 46803 } 46804 get currentPdt() { 46805 return nt3(this.nativeEl, this._hls); 46806 } 46807 get preferPlayback() { 46808 let t2 = this.getAttribute(o.PREFER_PLAYBACK); 46809 if (t2 === q.MSE || t2 === q.NATIVE) return t2; 46810 } 46811 set preferPlayback(t2) { 46812 t2 !== this.preferPlayback && (t2 === q.MSE || t2 === q.NATIVE ? this.setAttribute(o.PREFER_PLAYBACK, t2) : this.removeAttribute(o.PREFER_PLAYBACK)); 46813 } 46814 get metadata() { 46815 return { ...this.getAttributeNames().filter((s) => s.startsWith("metadata-") && ![o.METADATA_URL].includes(s)).reduce((s, n2) => { 46816 let l2 = this.getAttribute(n2); 46817 return l2 != null && (s[n2.replace(/^metadata-/, "").replace(/-/g, "_")] = l2), s; 46818 }, {}), ...i(this, Pt3) }; 46819 } 46820 set metadata(t2) { 46821 h(this, Pt3, t2 != null ? t2 : {}), this.mux && this.mux.emit("hb", i(this, Pt3)); 46822 } 46823 get _hlsConfig() { 46824 return i(this, Wt2); 46825 } 46826 set _hlsConfig(t2) { 46827 h(this, Wt2, t2); 46828 } 46829 load() { 46830 h(this, M2, Sr(this, this.nativeEl, i(this, M2))); 46831 } 46832 unload() { 46833 vt2(this.nativeEl, i(this, M2)), h(this, M2, void 0); 46834 } 46835 attributeChangedCallback(t2, s, n2) { 46836 var f, d2; 46837 switch (Zt2.observedAttributes.includes(t2) && !["src", "autoplay", "preload"].includes(t2) && super.attributeChangedCallback(t2, s, n2), t2) { 46838 case o.PLAYER_SOFTWARE_NAME: 46839 this.playerSoftwareName = n2 != null ? n2 : void 0; 46840 break; 46841 case o.PLAYER_SOFTWARE_VERSION: 46842 this.playerSoftwareVersion = n2 != null ? n2 : void 0; 46843 break; 46844 case "src": { 46845 let T3 = !!s, C4 = !!n2; 46846 !T3 && C4 ? A3(this, It3, pe3).call(this) : T3 && !C4 ? this.unload() : T3 && C4 && (this.unload(), A3(this, It3, pe3).call(this)); 46847 break; 46848 } 46849 case "autoplay": 46850 if (n2 === s) break; 46851 (f = i(this, M2)) == null || f.setAutoplay(this.autoplay); 46852 break; 46853 case "preload": 46854 if (n2 === s) break; 46855 (d2 = i(this, M2)) == null || d2.setPreload(n2); 46856 break; 46857 case o.PLAYBACK_ID: 46858 this.src = Lr(this); 46859 break; 46860 case o.DEBUG: { 46861 let T3 = this.debug; 46862 this.mux && console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."), this._hls && (this._hls.config.debug = T3); 46863 break; 46864 } 46865 case o.METADATA_URL: 46866 n2 && fetch(n2).then((T3) => T3.json()).then((T3) => this.metadata = T3).catch(() => console.error(`Unable to load or parse metadata JSON from metadata-url ${n2}!`)); 46867 break; 46868 case o.STREAM_TYPE: 46869 (n2 == null || n2 !== s) && this.dispatchEvent(new CustomEvent("streamtypechange", { composed: true, bubbles: true })); 46870 break; 46871 case o.TARGET_LIVE_WINDOW: 46872 (n2 == null || n2 !== s) && this.dispatchEvent(new CustomEvent("targetlivewindowchange", { composed: true, bubbles: true, detail: this.targetLiveWindow })); 46873 break; 46874 default: 46875 break; 46876 } 46877 } 46878 connectedCallback() { 46879 var t2; 46880 (t2 = super.connectedCallback) == null || t2.call(this), this.nativeEl && this.src && !i(this, M2) && A3(this, It3, pe3).call(this); 46881 } 46882 disconnectedCallback() { 46883 this.unload(); 46884 } 46885}; 46886M2 = /* @__PURE__ */ new WeakMap(), Ot2 = /* @__PURE__ */ new WeakMap(), Yt2 = /* @__PURE__ */ new WeakMap(), Pt3 = /* @__PURE__ */ new WeakMap(), jt2 = /* @__PURE__ */ new WeakMap(), Wt2 = /* @__PURE__ */ new WeakMap(), Ht3 = /* @__PURE__ */ new WeakMap(), $t2 = /* @__PURE__ */ new WeakMap(), zt2 = /* @__PURE__ */ new WeakMap(), It3 = /* @__PURE__ */ new WeakSet(), pe3 = async function() { 46887 i(this, Ot2) || (await h(this, Ot2, Promise.resolve()), h(this, Ot2, null), this.load()); 46888}; 46889var Xt2; 46890var Ut3 = class extends $e3(oi2(_e3)) { 46891 constructor() { 46892 super(...arguments); 46893 u(this, Xt2, void 0); 46894 } 46895 get muxCastCustomData() { 46896 return { mux: { playbackId: this.playbackId, minResolution: this.minResolution, maxResolution: this.maxResolution, renditionOrder: this.renditionOrder, customDomain: this.customDomain, tokens: { drm: this.drmToken }, envKey: this.envKey, metadata: this.metadata, disableCookies: this.disableCookies, disableTracking: this.disableTracking, beaconCollectionDomain: this.beaconCollectionDomain, startTime: this.startTime, preferCmcd: this.preferCmcd } }; 46897 } 46898 get castCustomData() { 46899 var t2; 46900 return (t2 = i(this, Xt2)) != null ? t2 : this.muxCastCustomData; 46901 } 46902 set castCustomData(t2) { 46903 h(this, Xt2, t2); 46904 } 46905}; 46906Xt2 = /* @__PURE__ */ new WeakMap(); 46907Qt2.customElements.get("mux-video") || (Qt2.customElements.define("mux-video", Ut3), Qt2.MuxVideoElement = Ut3); 46908var Cs = Ut3; 46909
vendor: 10,508 bytes, lines 46910-47240
46910// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/utils/template-parts.js 46911var __accessCheck19 = (obj, member, msg) => { 46912 if (!member.has(obj)) 46913 throw TypeError("Cannot " + msg); 46914}; 46915var __privateGet19 = (obj, member, getter) => { 46916 __accessCheck19(obj, member, "read from private field"); 46917 return getter ? getter.call(obj) : member.get(obj); 46918}; 46919var __privateAdd19 = (obj, member, value) => { 46920 if (member.has(obj)) 46921 throw TypeError("Cannot add the same private member more than once"); 46922 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 46923}; 46924var __privateSet18 = (obj, member, value, setter) => { 46925 __accessCheck19(obj, member, "write to private field"); 46926 setter ? setter.call(obj, value) : member.set(obj, value); 46927 return value; 46928}; 46929var _parts; 46930var _processor; 46931var _items; 46932var _value; 46933var _element; 46934var _attributeName; 46935var _namespaceURI; 46936var _list; 46937var list_get; 46938var _parentNode; 46939var _nodes; 46940var ELEMENT = 1; 46941var STRING2 = 0; 46942var PART = 1; 46943var defaultProcessor = { 46944 processCallback(instance, parts, state) { 46945 if (!state) 46946 return; 46947 for (const [expression, part] of parts) { 46948 if (expression in state) { 46949 const value = state[expression]; 46950 if (typeof value === "boolean" && part instanceof AttrPart && typeof part.element[part.attributeName] === "boolean") { 46951 part.booleanValue = value; 46952 } else if (typeof value === "function" && part instanceof AttrPart) { 46953 part.element[part.attributeName] = value; 46954 } else { 46955 part.value = value; 46956 } 46957 } 46958 } 46959 } 46960}; 46961var TemplateInstance = class extends GlobalThis.DocumentFragment { 46962 constructor(template18, state, processor2 = defaultProcessor) { 46963 var _a3; 46964 super(); 46965 __privateAdd19(this, _parts, void 0); 46966 __privateAdd19(this, _processor, void 0); 46967 this.append(template18.content.cloneNode(true)); 46968 __privateSet18(this, _parts, parse2(this)); 46969 __privateSet18(this, _processor, processor2); 46970 (_a3 = processor2.createCallback) == null ? void 0 : _a3.call(processor2, this, __privateGet19(this, _parts), state); 46971 processor2.processCallback(this, __privateGet19(this, _parts), state); 46972 } 46973 update(state) { 46974 __privateGet19(this, _processor).processCallback(this, __privateGet19(this, _parts), state); 46975 } 46976}; 46977_parts = /* @__PURE__ */ new WeakMap(); 46978_processor = /* @__PURE__ */ new WeakMap(); 46979var parse2 = (element, parts = []) => { 46980 let type, value; 46981 for (const attr of element.attributes || []) { 46982 if (attr.value.includes("{{")) { 46983 const list = new AttrPartList(); 46984 for ([type, value] of tokenize2(attr.value)) { 46985 if (!type) 46986 list.append(value); 46987 else { 46988 const part = new AttrPart(element, attr.name, attr.namespaceURI); 46989 list.append(part); 46990 parts.push([value, part]); 46991 } 46992 } 46993 attr.value = list.toString(); 46994 } 46995 } 46996 for (const node2 of element.childNodes) { 46997 if (node2.nodeType === ELEMENT && !(node2 instanceof HTMLTemplateElement)) { 46998 parse2(node2, parts); 46999 } else { 47000 const data = node2.data; 47001 if (node2.nodeType === ELEMENT || data.includes("{{")) { 47002 const items = []; 47003 if (data) { 47004 for ([type, value] of tokenize2(data)) 47005 if (!type) 47006 items.push(new Text(value)); 47007 else { 47008 const part = new ChildNodePart(element); 47009 items.push(part); 47010 parts.push([value, part]); 47011 } 47012 } else if (node2 instanceof HTMLTemplateElement) { 47013 const part = new InnerTemplatePart(element, node2); 47014 items.push(part); 47015 parts.push([part.expression, part]); 47016 } 47017 node2.replaceWith( 47018 ...items.flatMap((part) => part.replacementNodes || [part]) 47019 ); 47020 } 47021 } 47022 } 47023 return parts; 47024}; 47025var mem = {}; 47026var tokenize2 = (text) => { 47027 let value = "", open = 0, tokens = mem[text], i3 = 0, c3; 47028 if (tokens) 47029 return tokens; 47030 else 47031 tokens = []; 47032 for (; c3 = text[i3]; i3++) { 47033 if (c3 === "{" && text[i3 + 1] === "{" && text[i3 - 1] !== "\\" && text[i3 + 2] && ++open == 1) { 47034 if (value) 47035 tokens.push([STRING2, value]); 47036 value = ""; 47037 i3++; 47038 } else if (c3 === "}" && text[i3 + 1] === "}" && text[i3 - 1] !== "\\" && !--open) { 47039 tokens.push([PART, value.trim()]); 47040 value = ""; 47041 i3++; 47042 } else 47043 value += c3 || ""; 47044 } 47045 if (value) 47046 tokens.push([STRING2, (open > 0 ? "{{" : "") + value]); 47047 return mem[text] = tokens; 47048}; 47049var FRAGMENT = 11; 47050var Part2 = class { 47051 get value() { 47052 return ""; 47053 } 47054 set value(val) { 47055 } 47056 toString() { 47057 return this.value; 47058 } 47059}; 47060var attrPartToList = /* @__PURE__ */ new WeakMap(); 47061var AttrPartList = class { 47062 constructor() { 47063 __privateAdd19(this, _items, []); 47064 } 47065 [Symbol.iterator]() { 47066 return __privateGet19(this, _items).values(); 47067 } 47068 get length() { 47069 return __privateGet19(this, _items).length; 47070 } 47071 item(index2) { 47072 return __privateGet19(this, _items)[index2]; 47073 } 47074 append(...items) { 47075 for (const item of items) { 47076 if (item instanceof AttrPart) { 47077 attrPartToList.set(item, this); 47078 } 47079 __privateGet19(this, _items).push(item); 47080 } 47081 } 47082 toString() { 47083 return __privateGet19(this, _items).join(""); 47084 } 47085}; 47086_items = /* @__PURE__ */ new WeakMap(); 47087var AttrPart = class extends Part2 { 47088 constructor(element, attributeName, namespaceURI) { 47089 super(); 47090 __privateAdd19(this, _list); 47091 __privateAdd19(this, _value, ""); 47092 __privateAdd19(this, _element, void 0); 47093 __privateAdd19(this, _attributeName, void 0); 47094 __privateAdd19(this, _namespaceURI, void 0); 47095 __privateSet18(this, _element, element); 47096 __privateSet18(this, _attributeName, attributeName); 47097 __privateSet18(this, _namespaceURI, namespaceURI); 47098 } 47099 get attributeName() { 47100 return __privateGet19(this, _attributeName); 47101 } 47102 get attributeNamespace() { 47103 return __privateGet19(this, _namespaceURI); 47104 } 47105 get element() { 47106 return __privateGet19(this, _element); 47107 } 47108 get value() { 47109 return __privateGet19(this, _value); 47110 } 47111 set value(newValue) { 47112 if (__privateGet19(this, _value) === newValue) 47113 return; 47114 __privateSet18(this, _value, newValue); 47115 if (!__privateGet19(this, _list, list_get) || __privateGet19(this, _list, list_get).length === 1) { 47116 if (newValue == null) { 47117 __privateGet19(this, _element).removeAttributeNS( 47118 __privateGet19(this, _namespaceURI), 47119 __privateGet19(this, _attributeName) 47120 ); 47121 } else { 47122 __privateGet19(this, _element).setAttributeNS( 47123 __privateGet19(this, _namespaceURI), 47124 __privateGet19(this, _attributeName), 47125 newValue 47126 ); 47127 } 47128 } else { 47129 __privateGet19(this, _element).setAttributeNS( 47130 __privateGet19(this, _namespaceURI), 47131 __privateGet19(this, _attributeName), 47132 __privateGet19(this, _list, list_get).toString() 47133 ); 47134 } 47135 } 47136 get booleanValue() { 47137 return __privateGet19(this, _element).hasAttributeNS( 47138 __privateGet19(this, _namespaceURI), 47139 __privateGet19(this, _attributeName) 47140 ); 47141 } 47142 set booleanValue(value) { 47143 if (!__privateGet19(this, _list, list_get) || __privateGet19(this, _list, list_get).length === 1) 47144 this.value = value ? "" : null; 47145 else 47146 throw new DOMException("Value is not fully templatized"); 47147 } 47148}; 47149_value = /* @__PURE__ */ new WeakMap(); 47150_element = /* @__PURE__ */ new WeakMap(); 47151_attributeName = /* @__PURE__ */ new WeakMap(); 47152_namespaceURI = /* @__PURE__ */ new WeakMap(); 47153_list = /* @__PURE__ */ new WeakSet(); 47154list_get = function() { 47155 return attrPartToList.get(this); 47156}; 47157var ChildNodePart = class extends Part2 { 47158 constructor(parentNode, nodes) { 47159 super(); 47160 __privateAdd19(this, _parentNode, void 0); 47161 __privateAdd19(this, _nodes, void 0); 47162 __privateSet18(this, _parentNode, parentNode); 47163 __privateSet18(this, _nodes, nodes ? [...nodes] : [new Text()]); 47164 } 47165 get replacementNodes() { 47166 return __privateGet19(this, _nodes); 47167 } 47168 get parentNode() { 47169 return __privateGet19(this, _parentNode); 47170 } 47171 get nextSibling() { 47172 return __privateGet19(this, _nodes)[__privateGet19(this, _nodes).length - 1].nextSibling; 47173 } 47174 get previousSibling() { 47175 return __privateGet19(this, _nodes)[0].previousSibling; 47176 } 47177 // FIXME: not sure why do we need string serialization here? Just because parent class has type DOMString? 47178 get value() { 47179 return __privateGet19(this, _nodes).map((node2) => node2.textContent).join(""); 47180 } 47181 set value(newValue) { 47182 this.replace(newValue); 47183 } 47184 replace(...nodes) { 47185 const normalisedNodes = nodes.flat().flatMap( 47186 (node2) => node2 == null ? [new Text()] : node2.forEach ? [...node2] : node2.nodeType === FRAGMENT ? [...node2.childNodes] : node2.nodeType ? [node2] : [new Text(node2)] 47187 ); 47188 if (!normalisedNodes.length) 47189 normalisedNodes.push(new Text()); 47190 __privateSet18(this, _nodes, swapdom( 47191 __privateGet19(this, _nodes)[0].parentNode, 47192 __privateGet19(this, _nodes), 47193 normalisedNodes, 47194 this.nextSibling 47195 )); 47196 } 47197}; 47198_parentNode = /* @__PURE__ */ new WeakMap(); 47199_nodes = /* @__PURE__ */ new WeakMap(); 47200var InnerTemplatePart = class extends ChildNodePart { 47201 constructor(parentNode, template18) { 47202 const directive = template18.getAttribute("directive") || template18.getAttribute("type"); 47203 let expression = template18.getAttribute("expression") || template18.getAttribute(directive) || ""; 47204 if (expression.startsWith("{{")) 47205 expression = expression.trim().slice(2, -2).trim(); 47206 super(parentNode); 47207 this.expression = expression; 47208 this.template = template18; 47209 this.directive = directive; 47210 } 47211}; 47212function swapdom(parent, a2, b3, end = null) { 47213 let i3 = 0, cur, next2, bi3, n2 = b3.length, m2 = a2.length; 47214 while (i3 < n2 && i3 < m2 && a2[i3] == b3[i3]) 47215 i3++; 47216 while (i3 < n2 && i3 < m2 && b3[n2 - 1] == a2[m2 - 1]) 47217 end = b3[--m2, --n2]; 47218 if (i3 == m2) 47219 while (i3 < n2) 47220 parent.insertBefore(b3[i3++], end); 47221 if (i3 == n2) 47222 while (i3 < m2) 47223 parent.removeChild(a2[i3++]); 47224 else { 47225 cur = a2[i3]; 47226 while (i3 < n2) { 47227 bi3 = b3[i3++], next2 = cur ? cur.nextSibling : end; 47228 if (cur == bi3) 47229 cur = next2; 47230 else if (i3 < n2 && b3[i3] == next2) 47231 parent.replaceChild(bi3, cur), cur = next2; 47232 else 47233 parent.insertBefore(bi3, cur); 47234 } 47235 while (cur != end) 47236 next2 = cur.nextSibling, parent.removeChild(cur), cur = next2; 47237 } 47238 return b3; 47239} 47240
vendor: 6,837 bytes, lines 47241-47467
47241// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/utils/template-processor.js 47242var pipeModifiers = { 47243 string: (value) => String(value) 47244}; 47245var PartialTemplate = class { 47246 constructor(template18) { 47247 this.template = template18; 47248 this.state = void 0; 47249 } 47250}; 47251var templates = /* @__PURE__ */ new WeakMap(); 47252var templateInstances = /* @__PURE__ */ new WeakMap(); 47253var Directives = { 47254 partial: (part, state) => { 47255 state[part.expression] = new PartialTemplate(part.template); 47256 }, 47257 if: (part, state) => { 47258 var _a3; 47259 if (evaluateExpression(part.expression, state)) { 47260 if (templates.get(part) !== part.template) { 47261 templates.set(part, part.template); 47262 const tpl = new TemplateInstance(part.template, state, processor); 47263 part.replace(tpl); 47264 templateInstances.set(part, tpl); 47265 } else { 47266 (_a3 = templateInstances.get(part)) == null ? void 0 : _a3.update(state); 47267 } 47268 } else { 47269 part.replace(""); 47270 templates.delete(part); 47271 templateInstances.delete(part); 47272 } 47273 } 47274}; 47275var DirectiveNames = Object.keys(Directives); 47276var processor = { 47277 processCallback(instance, parts, state) { 47278 var _a3, _b; 47279 if (!state) 47280 return; 47281 for (const [expression, part] of parts) { 47282 if (part instanceof InnerTemplatePart) { 47283 if (!part.directive) { 47284 const directive = DirectiveNames.find( 47285 (n2) => part.template.hasAttribute(n2) 47286 ); 47287 if (directive) { 47288 part.directive = directive; 47289 part.expression = part.template.getAttribute(directive); 47290 } 47291 } 47292 (_a3 = Directives[part.directive]) == null ? void 0 : _a3.call(Directives, part, state); 47293 continue; 47294 } 47295 let value = evaluateExpression(expression, state); 47296 if (value instanceof PartialTemplate) { 47297 if (templates.get(part) !== value.template) { 47298 templates.set(part, value.template); 47299 value = new TemplateInstance(value.template, value.state, processor); 47300 part.value = value; 47301 templateInstances.set(part, value); 47302 } else { 47303 (_b = templateInstances.get(part)) == null ? void 0 : _b.update(value.state); 47304 } 47305 continue; 47306 } 47307 if (value) { 47308 if (part instanceof AttrPart) { 47309 if (part.attributeName.startsWith("aria-")) { 47310 value = String(value); 47311 } 47312 } 47313 if (part instanceof AttrPart) { 47314 if (typeof value === "boolean") { 47315 part.booleanValue = value; 47316 } else if (typeof value === "function") { 47317 part.element[part.attributeName] = value; 47318 } else { 47319 part.value = value; 47320 } 47321 } else { 47322 part.value = value; 47323 templates.delete(part); 47324 templateInstances.delete(part); 47325 } 47326 } else { 47327 if (part instanceof AttrPart) { 47328 part.value = void 0; 47329 } else { 47330 part.value = void 0; 47331 templates.delete(part); 47332 templateInstances.delete(part); 47333 } 47334 } 47335 } 47336 } 47337}; 47338var operators = { 47339 "!": (a2) => !a2, 47340 "!!": (a2) => !!a2, 47341 "==": (a2, b3) => a2 == b3, 47342 "!=": (a2, b3) => a2 != b3, 47343 ">": (a2, b3) => a2 > b3, 47344 ">=": (a2, b3) => a2 >= b3, 47345 "<": (a2, b3) => a2 < b3, 47346 "<=": (a2, b3) => a2 <= b3, 47347 "??": (a2, b3) => a2 != null ? a2 : b3, 47348 "|": (a2, b3) => { 47349 var _a3; 47350 return (_a3 = pipeModifiers[b3]) == null ? void 0 : _a3.call(pipeModifiers, a2); 47351 } 47352}; 47353function tokenizeExpression(expr) { 47354 return tokenize3(expr, { 47355 boolean: /true|false/, 47356 number: /-?\d+\.?\d*/, 47357 string: /(["'])((?:\\.|[^\\])*?)\1/, 47358 operator: /[!=><][=!]?|\?\?|\|/, 47359 ws: /\s+/, 47360 param: /[$a-z_][$\w]*/i 47361 }).filter(({ type }) => type !== "ws"); 47362} 47363function evaluateExpression(expr, state = {}) { 47364 var _a3, _b, _c, _d, _e5, _f, _g; 47365 const tokens = tokenizeExpression(expr); 47366 if (tokens.length === 0 || tokens.some(({ type }) => !type)) { 47367 return invalidExpression(expr); 47368 } 47369 if (((_a3 = tokens[0]) == null ? void 0 : _a3.token) === ">") { 47370 const partial = state[(_b = tokens[1]) == null ? void 0 : _b.token]; 47371 if (!partial) { 47372 return invalidExpression(expr); 47373 } 47374 const partialState = { ...state }; 47375 partial.state = partialState; 47376 const args = tokens.slice(2); 47377 for (let i3 = 0; i3 < args.length; i3 += 3) { 47378 const name = (_c = args[i3]) == null ? void 0 : _c.token; 47379 const operator = (_d = args[i3 + 1]) == null ? void 0 : _d.token; 47380 const value = (_e5 = args[i3 + 2]) == null ? void 0 : _e5.token; 47381 if (name && operator === "=") { 47382 partialState[name] = getParamValue(value, state); 47383 } 47384 } 47385 return partial; 47386 } 47387 if (tokens.length === 1) { 47388 if (!isValidParam(tokens[0])) { 47389 return invalidExpression(expr); 47390 } 47391 return getParamValue(tokens[0].token, state); 47392 } 47393 if (tokens.length === 2) { 47394 const operator = (_f = tokens[0]) == null ? void 0 : _f.token; 47395 const run = operators[operator]; 47396 if (!run || !isValidParam(tokens[1])) { 47397 return invalidExpression(expr); 47398 } 47399 const a2 = getParamValue(tokens[1].token, state); 47400 return run(a2); 47401 } 47402 if (tokens.length === 3) { 47403 const operator = (_g = tokens[1]) == null ? void 0 : _g.token; 47404 const run = operators[operator]; 47405 if (!run || !isValidParam(tokens[0]) || !isValidParam(tokens[2])) { 47406 return invalidExpression(expr); 47407 } 47408 const a2 = getParamValue(tokens[0].token, state); 47409 if (operator === "|") { 47410 return run(a2, tokens[2].token); 47411 } 47412 const b3 = getParamValue(tokens[2].token, state); 47413 return run(a2, b3); 47414 } 47415} 47416function invalidExpression(expr) { 47417 console.warn(`Warning: invalid expression \`${expr}\``); 47418 return false; 47419} 47420function isValidParam({ type }) { 47421 return ["number", "boolean", "string", "param"].includes(type); 47422} 47423function getParamValue(raw, state) { 47424 const firstChar = raw[0]; 47425 const lastChar = raw.slice(-1); 47426 if (raw === "true" || raw === "false") { 47427 return raw === "true"; 47428 } 47429 if (firstChar === lastChar && [`'`, `"`].includes(firstChar)) { 47430 return raw.slice(1, -1); 47431 } 47432 if (isNumericString(raw)) { 47433 return parseFloat(raw); 47434 } 47435 return state[raw]; 47436} 47437function tokenize3(str, parsers) { 47438 let len, match2, token2; 47439 const tokens = []; 47440 while (str) { 47441 token2 = null; 47442 len = str.length; 47443 for (const key in parsers) { 47444 match2 = parsers[key].exec(str); 47445 if (match2 && match2.index < len) { 47446 token2 = { 47447 token: match2[0], 47448 type: key, 47449 matches: match2.slice(1) 47450 }; 47451 len = match2.index; 47452 } 47453 } 47454 if (len) { 47455 tokens.push({ 47456 token: str.substr(0, len), 47457 type: void 0 47458 }); 47459 } 47460 if (token2) { 47461 tokens.push(token2); 47462 } 47463 str = str.substr(len + (token2 ? token2.token.length : 0)); 47464 } 47465 return tokens; 47466} 47467
vendor: 8,033 bytes, lines 47468-47712
47468// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/media-theme-element.js 47469var __accessCheck20 = (obj, member, msg) => { 47470 if (!member.has(obj)) 47471 throw TypeError("Cannot " + msg); 47472}; 47473var __privateGet20 = (obj, member, getter) => { 47474 __accessCheck20(obj, member, "read from private field"); 47475 return getter ? getter.call(obj) : member.get(obj); 47476}; 47477var __privateAdd20 = (obj, member, value) => { 47478 if (member.has(obj)) 47479 throw TypeError("Cannot add the same private member more than once"); 47480 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 47481}; 47482var __privateSet19 = (obj, member, value, setter) => { 47483 __accessCheck20(obj, member, "write to private field"); 47484 setter ? setter.call(obj, value) : member.set(obj, value); 47485 return value; 47486}; 47487var __privateMethod7 = (obj, member, method) => { 47488 __accessCheck20(obj, member, "access private method"); 47489 return method; 47490}; 47491var _template; 47492var _prevTemplate; 47493var _prevTemplateId; 47494var _upgradeProperty; 47495var upgradeProperty_fn; 47496var _updateTemplate; 47497var updateTemplate_fn; 47498var observedMediaAttributes = { 47499 mediatargetlivewindow: "targetlivewindow", 47500 mediastreamtype: "streamtype" 47501}; 47502var prependTemplate = Document2.createElement("template"); 47503prependTemplate.innerHTML = /*html*/ 47504` 47505 <style> 47506 :host { 47507 display: inline-block; 47508 line-height: 0; 47509 47510 /* Hide theme element until the breakpoints are available to avoid flicker. */ 47511 visibility: hidden; 47512 } 47513 47514 media-controller { 47515 width: 100%; 47516 height: 100%; 47517 } 47518 47519 media-captions-button:not([mediasubtitleslist]), 47520 media-captions-menu:not([mediasubtitleslist]), 47521 media-captions-menu-button:not([mediasubtitleslist]), 47522 media-audio-track-menu[mediaaudiotrackunavailable], 47523 media-audio-track-menu-button[mediaaudiotrackunavailable], 47524 media-rendition-menu[mediarenditionunavailable], 47525 media-rendition-menu-button[mediarenditionunavailable], 47526 media-volume-range[mediavolumeunavailable], 47527 media-airplay-button[mediaairplayunavailable], 47528 media-fullscreen-button[mediafullscreenunavailable], 47529 media-cast-button[mediacastunavailable], 47530 media-pip-button[mediapipunavailable] { 47531 display: none; 47532 } 47533 </style> 47534`; 47535var MediaThemeElement = class extends GlobalThis.HTMLElement { 47536 constructor() { 47537 super(); 47538 __privateAdd20(this, _upgradeProperty); 47539 __privateAdd20(this, _updateTemplate); 47540 __privateAdd20(this, _template, void 0); 47541 __privateAdd20(this, _prevTemplate, void 0); 47542 __privateAdd20(this, _prevTemplateId, void 0); 47543 if (this.shadowRoot) { 47544 this.renderRoot = this.shadowRoot; 47545 } else { 47546 this.renderRoot = this.attachShadow({ mode: "open" }); 47547 this.createRenderer(); 47548 } 47549 const observer2 = new MutationObserver((mutationList) => { 47550 var _a3; 47551 if (this.mediaController && !((_a3 = this.mediaController) == null ? void 0 : _a3.breakpointsComputed)) 47552 return; 47553 if (mutationList.some((mutation) => { 47554 const target = mutation.target; 47555 if (target === this) 47556 return true; 47557 if (target.localName !== "media-controller") 47558 return false; 47559 if (observedMediaAttributes[mutation.attributeName]) 47560 return true; 47561 if (mutation.attributeName.startsWith("breakpoint")) 47562 return true; 47563 return false; 47564 })) { 47565 this.render(); 47566 } 47567 }); 47568 observer2.observe(this, { attributes: true }); 47569 observer2.observe(this.renderRoot, { 47570 attributes: true, 47571 subtree: true 47572 }); 47573 this.addEventListener( 47574 MediaStateChangeEvents.BREAKPOINTS_COMPUTED, 47575 this.render 47576 ); 47577 __privateMethod7(this, _upgradeProperty, upgradeProperty_fn).call(this, "template"); 47578 } 47579 /** @type {HTMLElement & { breakpointsComputed?: boolean }} */ 47580 get mediaController() { 47581 return this.renderRoot.querySelector("media-controller"); 47582 } 47583 get template() { 47584 var _a3; 47585 return (_a3 = __privateGet20(this, _template)) != null ? _a3 : this.constructor.template; 47586 } 47587 set template(element) { 47588 __privateSet19(this, _prevTemplateId, null); 47589 __privateSet19(this, _template, element); 47590 this.createRenderer(); 47591 } 47592 get props() { 47593 var _a3, _b, _c; 47594 const observedAttributes = [ 47595 ...Array.from((_b = (_a3 = this.mediaController) == null ? void 0 : _a3.attributes) != null ? _b : []).filter( 47596 ({ name }) => { 47597 return observedMediaAttributes[name] || name.startsWith("breakpoint"); 47598 } 47599 ), 47600 ...Array.from(this.attributes) 47601 ]; 47602 const props = {}; 47603 for (const attr of observedAttributes) { 47604 const name = (_c = observedMediaAttributes[attr.name]) != null ? _c : camelCase(attr.name); 47605 let { value } = attr; 47606 if (value != null) { 47607 if (isNumericString(value)) { 47608 value = parseFloat(value); 47609 } 47610 props[name] = value === "" ? true : value; 47611 } else { 47612 props[name] = false; 47613 } 47614 } 47615 return props; 47616 } 47617 attributeChangedCallback(attrName, oldValue, newValue) { 47618 if (attrName === "template" && oldValue != newValue) { 47619 __privateMethod7(this, _updateTemplate, updateTemplate_fn).call(this); 47620 } 47621 } 47622 connectedCallback() { 47623 __privateMethod7(this, _updateTemplate, updateTemplate_fn).call(this); 47624 } 47625 createRenderer() { 47626 if (this.template && this.template !== __privateGet20(this, _prevTemplate)) { 47627 __privateSet19(this, _prevTemplate, this.template); 47628 this.renderer = new TemplateInstance( 47629 this.template, 47630 this.props, 47631 // @ts-ignore 47632 this.constructor.processor 47633 ); 47634 this.renderRoot.textContent = ""; 47635 this.renderRoot.append( 47636 prependTemplate.content.cloneNode(true), 47637 this.renderer 47638 ); 47639 } 47640 } 47641 render() { 47642 var _a3; 47643 (_a3 = this.renderer) == null ? void 0 : _a3.update(this.props); 47644 if (this.renderRoot.isConnected) { 47645 const { style } = getOrInsertCSSRule(this.renderRoot, ":host"); 47646 if (style.visibility === "hidden") { 47647 style.removeProperty("visibility"); 47648 } 47649 } 47650 } 47651}; 47652_template = /* @__PURE__ */ new WeakMap(); 47653_prevTemplate = /* @__PURE__ */ new WeakMap(); 47654_prevTemplateId = /* @__PURE__ */ new WeakMap(); 47655_upgradeProperty = /* @__PURE__ */ new WeakSet(); 47656upgradeProperty_fn = function(prop) { 47657 if (Object.prototype.hasOwnProperty.call(this, prop)) { 47658 const value = this[prop]; 47659 delete this[prop]; 47660 this[prop] = value; 47661 } 47662}; 47663_updateTemplate = /* @__PURE__ */ new WeakSet(); 47664updateTemplate_fn = function() { 47665 var _a3; 47666 const templateId = this.getAttribute("template"); 47667 if (!templateId || templateId === __privateGet20(this, _prevTemplateId)) 47668 return; 47669 const rootNode = this.getRootNode(); 47670 const template18 = (_a3 = rootNode == null ? void 0 : rootNode.getElementById) == null ? void 0 : _a3.call(rootNode, templateId); 47671 if (template18) { 47672 __privateSet19(this, _prevTemplateId, templateId); 47673 __privateSet19(this, _template, template18); 47674 this.createRenderer(); 47675 return; 47676 } 47677 if (isValidUrl(templateId)) { 47678 __privateSet19(this, _prevTemplateId, templateId); 47679 request(templateId).then((data) => { 47680 const template22 = Document2.createElement("template"); 47681 template22.innerHTML = data; 47682 __privateSet19(this, _template, template22); 47683 this.createRenderer(); 47684 }).catch(console.error); 47685 } 47686}; 47687MediaThemeElement.observedAttributes = ["template"]; 47688MediaThemeElement.processor = processor; 47689function isValidUrl(url) { 47690 if (!/^(\/|\.\/|https?:\/\/)/.test(url)) 47691 return false; 47692 const base = /^https?:\/\//.test(url) ? void 0 : location.origin; 47693 try { 47694 new URL(url, base); 47695 } catch (e) { 47696 return false; 47697 } 47698 return true; 47699} 47700async function request(resource) { 47701 const response = await fetch(resource); 47702 if (response.status !== 200) { 47703 throw new Error( 47704 `Failed to load resource: the server responded with a status of ${response.status}` 47705 ); 47706 } 47707 return response.text(); 47708} 47709if (!GlobalThis.customElements.get("media-theme")) { 47710 GlobalThis.customElements.define("media-theme", MediaThemeElement); 47711} 47712
vendor: 2,248 bytes, lines 47713-47788
47713// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/utils/anchor-utils.js 47714function computePosition({ 47715 anchor, 47716 floating, 47717 placement 47718}) { 47719 const rects = getElementRects({ anchor, floating }); 47720 const { x: x2, y: y4 } = computeCoordsFromPlacement(rects, placement); 47721 return { x: x2, y: y4 }; 47722} 47723function getElementRects({ 47724 anchor, 47725 floating 47726}) { 47727 return { 47728 anchor: getRectRelativeToOffsetParent(anchor, floating.offsetParent), 47729 floating: { 47730 x: 0, 47731 y: 0, 47732 width: floating.offsetWidth, 47733 height: floating.offsetHeight 47734 } 47735 }; 47736} 47737function getRectRelativeToOffsetParent(element, offsetParent) { 47738 var _a3; 47739 const rect = element.getBoundingClientRect(); 47740 const offsetRect = (_a3 = offsetParent == null ? void 0 : offsetParent.getBoundingClientRect()) != null ? _a3 : { x: 0, y: 0 }; 47741 return { 47742 x: rect.x - offsetRect.x, 47743 y: rect.y - offsetRect.y, 47744 width: rect.width, 47745 height: rect.height 47746 }; 47747} 47748function computeCoordsFromPlacement({ anchor, floating }, placement) { 47749 const alignmentAxis = getSideAxis(placement) === "x" ? "y" : "x"; 47750 const alignLength = alignmentAxis === "y" ? "height" : "width"; 47751 const side = getSide(placement); 47752 const commonX = anchor.x + anchor.width / 2 - floating.width / 2; 47753 const commonY = anchor.y + anchor.height / 2 - floating.height / 2; 47754 const commonAlign = anchor[alignLength] / 2 - floating[alignLength] / 2; 47755 let coords; 47756 switch (side) { 47757 case "top": 47758 coords = { x: commonX, y: anchor.y - floating.height }; 47759 break; 47760 case "bottom": 47761 coords = { x: commonX, y: anchor.y + anchor.height }; 47762 break; 47763 case "right": 47764 coords = { x: anchor.x + anchor.width, y: commonY }; 47765 break; 47766 case "left": 47767 coords = { x: anchor.x - floating.width, y: commonY }; 47768 break; 47769 default: 47770 coords = { x: anchor.x, y: anchor.y }; 47771 } 47772 switch (placement.split("-")[1]) { 47773 case "start": 47774 coords[alignmentAxis] -= commonAlign; 47775 break; 47776 case "end": 47777 coords[alignmentAxis] += commonAlign; 47778 break; 47779 } 47780 return coords; 47781} 47782function getSide(placement) { 47783 return placement.split("-")[0]; 47784} 47785function getSideAxis(placement) { 47786 return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x"; 47787} 47788
vendor: 589 bytes, lines 47789-47810
47789// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/utils/events.js 47790var InvokeEvent = class extends Event { 47791 /** 47792 * @param init - The event options. 47793 */ 47794 constructor({ action = "auto", relatedTarget, ...options2 }) { 47795 super("invoke", options2); 47796 this.action = action; 47797 this.relatedTarget = relatedTarget; 47798 } 47799}; 47800var ToggleEvent = class extends Event { 47801 /** 47802 * @param init - The event options. 47803 */ 47804 constructor({ newState, oldState, ...options2 }) { 47805 super("toggle", options2); 47806 this.newState = newState; 47807 this.oldState = oldState; 47808 } 47809}; 47810
vendor: 27,930 bytes, lines 47811-48624
47811// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/menu/media-chrome-menu.js 47812var __accessCheck21 = (obj, member, msg) => { 47813 if (!member.has(obj)) 47814 throw TypeError("Cannot " + msg); 47815}; 47816var __privateGet21 = (obj, member, getter) => { 47817 __accessCheck21(obj, member, "read from private field"); 47818 return getter ? getter.call(obj) : member.get(obj); 47819}; 47820var __privateAdd21 = (obj, member, value) => { 47821 if (member.has(obj)) 47822 throw TypeError("Cannot add the same private member more than once"); 47823 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 47824}; 47825var __privateSet20 = (obj, member, value, setter) => { 47826 __accessCheck21(obj, member, "write to private field"); 47827 setter ? setter.call(obj, value) : member.set(obj, value); 47828 return value; 47829}; 47830var __privateMethod8 = (obj, member, method) => { 47831 __accessCheck21(obj, member, "access private method"); 47832 return method; 47833}; 47834var _mediaController8; 47835var _previouslyFocused2; 47836var _invokerElement2; 47837var _previousItems; 47838var _mutationObserver; 47839var _isPopover; 47840var _cssRule; 47841var _handleSlotChange; 47842var handleSlotChange_fn; 47843var _handleMenuItems; 47844var _updateLayoutStyle; 47845var updateLayoutStyle_fn; 47846var _handleInvoke2; 47847var handleInvoke_fn2; 47848var _handleOpen2; 47849var handleOpen_fn2; 47850var _handleClosed2; 47851var handleClosed_fn2; 47852var _handleBoundsResize; 47853var _handleMenuResize; 47854var _positionMenu; 47855var positionMenu_fn; 47856var _resizeMenu; 47857var resizeMenu_fn; 47858var _handleClick; 47859var handleClick_fn; 47860var _backButtonElement; 47861var backButtonElement_get; 47862var _handleToggle; 47863var handleToggle_fn; 47864var _checkSubmenuHasExpanded; 47865var checkSubmenuHasExpanded_fn; 47866var _handleFocusOut2; 47867var handleFocusOut_fn2; 47868var _handleKeyDown2; 47869var handleKeyDown_fn2; 47870var _getItem; 47871var getItem_fn; 47872var _getTabItem; 47873var getTabItem_fn; 47874var _setTabItem; 47875var setTabItem_fn; 47876var _selectItem; 47877var selectItem_fn; 47878function createMenuItem({ 47879 type, 47880 text, 47881 value, 47882 checked 47883}) { 47884 const item = Document2.createElement( 47885 "media-chrome-menu-item" 47886 ); 47887 item.type = type != null ? type : ""; 47888 item.part.add("menu-item"); 47889 if (type) 47890 item.part.add(type); 47891 item.value = value; 47892 item.checked = checked; 47893 const label = Document2.createElement("span"); 47894 label.textContent = text; 47895 item.append(label); 47896 return item; 47897} 47898function createIndicator(el, name) { 47899 let customIndicator = el.querySelector(`:scope > [slot="${name}"]`); 47900 if ((customIndicator == null ? void 0 : customIndicator.nodeName) == "SLOT") 47901 customIndicator = customIndicator.assignedElements({ flatten: true })[0]; 47902 if (customIndicator) { 47903 customIndicator = customIndicator.cloneNode(true); 47904 return customIndicator; 47905 } 47906 const fallbackIndicator = el.shadowRoot.querySelector( 47907 `[name="${name}"] > svg` 47908 ); 47909 if (fallbackIndicator) { 47910 return fallbackIndicator.cloneNode(true); 47911 } 47912 return ""; 47913} 47914var template13 = Document2.createElement("template"); 47915template13.innerHTML = /*html*/ 47916` 47917 <style> 47918 :host { 47919 font: var(--media-font, 47920 var(--media-font-weight, normal) 47921 var(--media-font-size, 14px) / 47922 var(--media-text-content-height, var(--media-control-height, 24px)) 47923 var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif)); 47924 color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238))); 47925 background: var(--media-menu-background, var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .8)))); 47926 border-radius: var(--media-menu-border-radius); 47927 border: var(--media-menu-border, none); 47928 display: var(--media-menu-display, inline-flex); 47929 transition: var(--media-menu-transition-in, 47930 visibility 0s, 47931 opacity .2s ease-out, 47932 transform .15s ease-out, 47933 left .2s ease-in-out, 47934 min-width .2s ease-in-out, 47935 min-height .2s ease-in-out 47936 ) !important; 47937 ${/* ^^Prevent transition override by media-container */ 47938""} 47939 visibility: var(--media-menu-visibility, visible); 47940 opacity: var(--media-menu-opacity, 1); 47941 max-height: var(--media-menu-max-height, var(--_menu-max-height, 300px)); 47942 transform: var(--media-menu-transform-in, translateY(0) scale(1)); 47943 flex-direction: column; 47944 ${/* Prevent overflowing a flex container */ 47945""} 47946 min-height: 0; 47947 position: relative; 47948 bottom: var(--_menu-bottom); 47949 box-sizing: border-box; 47950 } 47951 47952 :host([hidden]) { 47953 transition: var(--media-menu-transition-out, 47954 visibility .15s ease-in, 47955 opacity .15s ease-in, 47956 transform .15s ease-in 47957 ) !important; 47958 visibility: var(--media-menu-hidden-visibility, hidden); 47959 opacity: var(--media-menu-hidden-opacity, 0); 47960 max-height: var(--media-menu-hidden-max-height, 47961 var(--media-menu-max-height, var(--_menu-max-height, 300px))); 47962 transform: var(--media-menu-transform-out, translateY(2px) scale(.99)); 47963 pointer-events: none; 47964 } 47965 47966 :host([slot="submenu"]) { 47967 background: none; 47968 width: 100%; 47969 min-height: 100%; 47970 position: absolute; 47971 bottom: 0; 47972 right: -100%; 47973 } 47974 47975 #container { 47976 display: flex; 47977 flex-direction: column; 47978 min-height: 0; 47979 transition: transform .2s ease-out; 47980 transform: translate(0, 0); 47981 } 47982 47983 #container.has-expanded { 47984 transition: transform .2s ease-in; 47985 transform: translate(-100%, 0); 47986 } 47987 47988 button { 47989 background: none; 47990 color: inherit; 47991 border: none; 47992 padding: 0; 47993 font: inherit; 47994 outline: inherit; 47995 display: inline-flex; 47996 align-items: center; 47997 } 47998 47999 slot[name="header"][hidden] { 48000 display: none; 48001 } 48002 48003 slot[name="header"] > *, 48004 slot[name="header"]::slotted(*) { 48005 padding: .4em .7em; 48006 border-bottom: 1px solid rgb(255 255 255 / .25); 48007 cursor: default; 48008 } 48009 48010 slot[name="header"] > button[part~="back"], 48011 slot[name="header"]::slotted(button[part~="back"]) { 48012 cursor: pointer; 48013 } 48014 48015 svg[part~="back"] { 48016 height: var(--media-menu-icon-height, var(--media-control-height, 24px)); 48017 fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238))); 48018 display: block; 48019 margin-right: .5ch; 48020 } 48021 48022 slot:not([name]) { 48023 gap: var(--media-menu-gap); 48024 flex-direction: var(--media-menu-flex-direction, column); 48025 overflow: var(--media-menu-overflow, hidden auto); 48026 display: flex; 48027 min-height: 0; 48028 } 48029 48030 :host([role="menu"]) slot:not([name]) { 48031 padding-block: .4em; 48032 } 48033 48034 slot:not([name])::slotted([role="menu"]) { 48035 background: none; 48036 } 48037 48038 media-chrome-menu-item > span { 48039 margin-right: .5ch; 48040 max-width: var(--media-menu-item-max-width); 48041 text-overflow: ellipsis; 48042 overflow: hidden; 48043 } 48044 </style> 48045 <style id="layout-row" media="width:0"> 48046 48047 slot[name="header"] > *, 48048 slot[name="header"]::slotted(*) { 48049 padding: .4em .5em; 48050 } 48051 48052 slot:not([name]) { 48053 gap: var(--media-menu-gap, .25em); 48054 flex-direction: var(--media-menu-flex-direction, row); 48055 padding-inline: .5em; 48056 } 48057 48058 media-chrome-menu-item { 48059 padding: .3em .5em; 48060 } 48061 48062 media-chrome-menu-item[aria-checked="true"] { 48063 background: var(--media-menu-item-checked-background, rgb(255 255 255 / .2)); 48064 } 48065 48066 ${/* In row layout hide the checked indicator completely. */ 48067""} 48068 media-chrome-menu-item::part(checked-indicator) { 48069 display: var(--media-menu-item-checked-indicator-display, none); 48070 } 48071 </style> 48072 <div id="container"> 48073 <slot name="header" hidden> 48074 <button part="back button" aria-label="Back to previous menu"> 48075 <slot name="back-icon"> 48076 <svg aria-hidden="true" viewBox="0 0 20 24" part="back indicator"> 48077 <path d="m11.88 17.585.742-.669-4.2-4.665 4.2-4.666-.743-.669-4.803 5.335 4.803 5.334Z"/> 48078 </svg> 48079 </slot> 48080 <slot name="title"></slot> 48081 </button> 48082 </slot> 48083 <slot></slot> 48084 </div> 48085 <slot name="checked-indicator" hidden></slot> 48086`; 48087var Attributes12 = { 48088 STYLE: "style", 48089 HIDDEN: "hidden", 48090 DISABLED: "disabled", 48091 ANCHOR: "anchor" 48092}; 48093var MediaChromeMenu = class extends GlobalThis.HTMLElement { 48094 constructor() { 48095 super(); 48096 __privateAdd21(this, _handleSlotChange); 48097 __privateAdd21(this, _updateLayoutStyle); 48098 __privateAdd21(this, _handleInvoke2); 48099 __privateAdd21(this, _handleOpen2); 48100 __privateAdd21(this, _handleClosed2); 48101 __privateAdd21(this, _positionMenu); 48102 __privateAdd21(this, _resizeMenu); 48103 __privateAdd21(this, _handleClick); 48104 __privateAdd21(this, _backButtonElement); 48105 __privateAdd21(this, _handleToggle); 48106 __privateAdd21(this, _checkSubmenuHasExpanded); 48107 __privateAdd21(this, _handleFocusOut2); 48108 __privateAdd21(this, _handleKeyDown2); 48109 __privateAdd21(this, _getItem); 48110 __privateAdd21(this, _getTabItem); 48111 __privateAdd21(this, _setTabItem); 48112 __privateAdd21(this, _selectItem); 48113 __privateAdd21(this, _mediaController8, null); 48114 __privateAdd21(this, _previouslyFocused2, null); 48115 __privateAdd21(this, _invokerElement2, null); 48116 __privateAdd21(this, _previousItems, /* @__PURE__ */ new Set()); 48117 __privateAdd21(this, _mutationObserver, void 0); 48118 __privateAdd21(this, _isPopover, false); 48119 __privateAdd21(this, _cssRule, null); 48120 __privateAdd21(this, _handleMenuItems, () => { 48121 const previousItems = __privateGet21(this, _previousItems); 48122 const currentItems = new Set(this.items); 48123 for (const item of previousItems) { 48124 if (!currentItems.has(item)) { 48125 this.dispatchEvent(new CustomEvent("removemenuitem", { detail: item })); 48126 } 48127 } 48128 for (const item of currentItems) { 48129 if (!previousItems.has(item)) { 48130 this.dispatchEvent(new CustomEvent("addmenuitem", { detail: item })); 48131 } 48132 } 48133 __privateSet20(this, _previousItems, currentItems); 48134 }); 48135 __privateAdd21(this, _handleBoundsResize, () => { 48136 __privateMethod8(this, _positionMenu, positionMenu_fn).call(this); 48137 __privateMethod8(this, _resizeMenu, resizeMenu_fn).call(this, false); 48138 }); 48139 __privateAdd21(this, _handleMenuResize, () => { 48140 __privateMethod8(this, _positionMenu, positionMenu_fn).call(this); 48141 }); 48142 if (!this.shadowRoot) { 48143 this.attachShadow({ mode: "open" }); 48144 this.nativeEl = this.constructor.template.content.cloneNode(true); 48145 this.shadowRoot.append(this.nativeEl); 48146 } 48147 this.container = this.shadowRoot.querySelector("#container"); 48148 this.defaultSlot = this.shadowRoot.querySelector( 48149 "slot:not([name])" 48150 ); 48151 this.shadowRoot.addEventListener("slotchange", this); 48152 __privateSet20(this, _mutationObserver, new MutationObserver(__privateGet21(this, _handleMenuItems))); 48153 __privateGet21(this, _mutationObserver).observe(this.defaultSlot, { childList: true }); 48154 } 48155 static get observedAttributes() { 48156 return [ 48157 Attributes12.DISABLED, 48158 Attributes12.HIDDEN, 48159 Attributes12.STYLE, 48160 Attributes12.ANCHOR, 48161 MediaStateReceiverAttributes.MEDIA_CONTROLLER 48162 ]; 48163 } 48164 static formatMenuItemText(text) { 48165 return text; 48166 } 48167 enable() { 48168 this.addEventListener("click", this); 48169 this.addEventListener("focusout", this); 48170 this.addEventListener("keydown", this); 48171 this.addEventListener("invoke", this); 48172 this.addEventListener("toggle", this); 48173 } 48174 disable() { 48175 this.removeEventListener("click", this); 48176 this.removeEventListener("focusout", this); 48177 this.removeEventListener("keyup", this); 48178 this.removeEventListener("invoke", this); 48179 this.removeEventListener("toggle", this); 48180 } 48181 handleEvent(event) { 48182 switch (event.type) { 48183 case "slotchange": 48184 __privateMethod8(this, _handleSlotChange, handleSlotChange_fn).call(this, event); 48185 break; 48186 case "invoke": 48187 __privateMethod8(this, _handleInvoke2, handleInvoke_fn2).call(this, event); 48188 break; 48189 case "click": 48190 __privateMethod8(this, _handleClick, handleClick_fn).call(this, event); 48191 break; 48192 case "toggle": 48193 __privateMethod8(this, _handleToggle, handleToggle_fn).call(this, event); 48194 break; 48195 case "focusout": 48196 __privateMethod8(this, _handleFocusOut2, handleFocusOut_fn2).call(this, event); 48197 break; 48198 case "keydown": 48199 __privateMethod8(this, _handleKeyDown2, handleKeyDown_fn2).call(this, event); 48200 break; 48201 } 48202 } 48203 connectedCallback() { 48204 var _a3, _b; 48205 __privateSet20(this, _cssRule, insertCSSRule(this.shadowRoot, ":host")); 48206 __privateMethod8(this, _updateLayoutStyle, updateLayoutStyle_fn).call(this); 48207 if (!this.hasAttribute("disabled")) { 48208 this.enable(); 48209 } 48210 if (!this.role) { 48211 this.role = "menu"; 48212 } 48213 __privateSet20(this, _mediaController8, getAttributeMediaController(this)); 48214 (_b = (_a3 = __privateGet21(this, _mediaController8)) == null ? void 0 : _a3.associateElement) == null ? void 0 : _b.call(_a3, this); 48215 if (!this.hidden) { 48216 observeResize(getBoundsElement(this), __privateGet21(this, _handleBoundsResize)); 48217 observeResize(this, __privateGet21(this, _handleMenuResize)); 48218 } 48219 } 48220 disconnectedCallback() { 48221 var _a3, _b; 48222 unobserveResize(getBoundsElement(this), __privateGet21(this, _handleBoundsResize)); 48223 unobserveResize(this, __privateGet21(this, _handleMenuResize)); 48224 this.disable(); 48225 (_b = (_a3 = __privateGet21(this, _mediaController8)) == null ? void 0 : _a3.unassociateElement) == null ? void 0 : _b.call(_a3, this); 48226 __privateSet20(this, _mediaController8, null); 48227 } 48228 attributeChangedCallback(attrName, oldValue, newValue) { 48229 var _a3, _b, _c, _d; 48230 if (attrName === Attributes12.HIDDEN && newValue !== oldValue) { 48231 if (!__privateGet21(this, _isPopover)) 48232 __privateSet20(this, _isPopover, true); 48233 if (this.hidden) { 48234 __privateMethod8(this, _handleClosed2, handleClosed_fn2).call(this); 48235 } else { 48236 __privateMethod8(this, _handleOpen2, handleOpen_fn2).call(this); 48237 } 48238 this.dispatchEvent( 48239 new ToggleEvent({ 48240 oldState: this.hidden ? "open" : "closed", 48241 newState: this.hidden ? "closed" : "open", 48242 bubbles: true 48243 }) 48244 ); 48245 } else if (attrName === MediaStateReceiverAttributes.MEDIA_CONTROLLER) { 48246 if (oldValue) { 48247 (_b = (_a3 = __privateGet21(this, _mediaController8)) == null ? void 0 : _a3.unassociateElement) == null ? void 0 : _b.call(_a3, this); 48248 __privateSet20(this, _mediaController8, null); 48249 } 48250 if (newValue && this.isConnected) { 48251 __privateSet20(this, _mediaController8, getAttributeMediaController(this)); 48252 (_d = (_c = __privateGet21(this, _mediaController8)) == null ? void 0 : _c.associateElement) == null ? void 0 : _d.call(_c, this); 48253 } 48254 } else if (attrName === Attributes12.DISABLED && newValue !== oldValue) { 48255 if (newValue == null) { 48256 this.enable(); 48257 } else { 48258 this.disable(); 48259 } 48260 } else if (attrName === Attributes12.STYLE && newValue !== oldValue) { 48261 __privateMethod8(this, _updateLayoutStyle, updateLayoutStyle_fn).call(this); 48262 } 48263 } 48264 formatMenuItemText(text, data) { 48265 return this.constructor.formatMenuItemText(text, data); 48266 } 48267 get anchor() { 48268 return this.getAttribute("anchor"); 48269 } 48270 set anchor(value) { 48271 this.setAttribute("anchor", `${value}`); 48272 } 48273 /** 48274 * Returns the anchor element when it is a floating menu. 48275 */ 48276 get anchorElement() { 48277 var _a3; 48278 if (this.anchor) { 48279 return (_a3 = getDocumentOrShadowRoot(this)) == null ? void 0 : _a3.querySelector(`#${this.anchor}`); 48280 } 48281 return null; 48282 } 48283 /** 48284 * Returns the menu items. 48285 */ 48286 get items() { 48287 return this.defaultSlot.assignedElements({ flatten: true }).filter(isMenuItem); 48288 } 48289 get radioGroupItems() { 48290 return this.items.filter((item) => item.role === "menuitemradio"); 48291 } 48292 get checkedItems() { 48293 return this.items.filter((item) => item.checked); 48294 } 48295 get value() { 48296 var _a3, _b; 48297 return (_b = (_a3 = this.checkedItems[0]) == null ? void 0 : _a3.value) != null ? _b : ""; 48298 } 48299 set value(newValue) { 48300 const item = this.items.find((item2) => item2.value === newValue); 48301 if (!item) 48302 return; 48303 __privateMethod8(this, _selectItem, selectItem_fn).call(this, item); 48304 } 48305 focus() { 48306 __privateSet20(this, _previouslyFocused2, getActiveElement()); 48307 if (this.items.length) { 48308 __privateMethod8(this, _setTabItem, setTabItem_fn).call(this, this.items[0]); 48309 this.items[0].focus(); 48310 return; 48311 } 48312 const focusable = this.querySelector( 48313 '[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]' 48314 ); 48315 focusable == null ? void 0 : focusable.focus(); 48316 } 48317 handleSelect(event) { 48318 var _a3; 48319 const item = __privateMethod8(this, _getItem, getItem_fn).call(this, event); 48320 if (!item) 48321 return; 48322 __privateMethod8(this, _selectItem, selectItem_fn).call(this, item, item.type === "checkbox"); 48323 if (__privateGet21(this, _invokerElement2) && !this.hidden) { 48324 (_a3 = __privateGet21(this, _previouslyFocused2)) == null ? void 0 : _a3.focus(); 48325 this.hidden = true; 48326 } 48327 } 48328 get keysUsed() { 48329 return [ 48330 "Enter", 48331 "Escape", 48332 "Tab", 48333 " ", 48334 "ArrowDown", 48335 "ArrowUp", 48336 "Home", 48337 "End" 48338 ]; 48339 } 48340 handleMove(event) { 48341 var _a3, _b; 48342 const { key } = event; 48343 const items = this.items; 48344 const currentItem = (_b = (_a3 = __privateMethod8(this, _getItem, getItem_fn).call(this, event)) != null ? _a3 : __privateMethod8(this, _getTabItem, getTabItem_fn).call(this)) != null ? _b : items[0]; 48345 const currentIndex = items.indexOf(currentItem); 48346 let index2 = Math.max(0, currentIndex); 48347 if (key === "ArrowDown") { 48348 index2++; 48349 } else if (key === "ArrowUp") { 48350 index2--; 48351 } else if (event.key === "Home") { 48352 index2 = 0; 48353 } else if (event.key === "End") { 48354 index2 = items.length - 1; 48355 } 48356 if (index2 < 0) { 48357 index2 = items.length - 1; 48358 } 48359 if (index2 > items.length - 1) { 48360 index2 = 0; 48361 } 48362 __privateMethod8(this, _setTabItem, setTabItem_fn).call(this, items[index2]); 48363 items[index2].focus(); 48364 } 48365}; 48366_mediaController8 = /* @__PURE__ */ new WeakMap(); 48367_previouslyFocused2 = /* @__PURE__ */ new WeakMap(); 48368_invokerElement2 = /* @__PURE__ */ new WeakMap(); 48369_previousItems = /* @__PURE__ */ new WeakMap(); 48370_mutationObserver = /* @__PURE__ */ new WeakMap(); 48371_isPopover = /* @__PURE__ */ new WeakMap(); 48372_cssRule = /* @__PURE__ */ new WeakMap(); 48373_handleSlotChange = /* @__PURE__ */ new WeakSet(); 48374handleSlotChange_fn = function(event) { 48375 const slot = event.target; 48376 for (const node2 of slot.assignedNodes({ flatten: true })) { 48377 if (node2.nodeType === 3 && node2.textContent.trim() === "") { 48378 node2.remove(); 48379 } 48380 } 48381 if (["header", "title"].includes(slot.name)) { 48382 const header = this.shadowRoot.querySelector( 48383 'slot[name="header"]' 48384 ); 48385 header.hidden = slot.assignedNodes().length === 0; 48386 } 48387 if (!slot.name) { 48388 __privateGet21(this, _handleMenuItems).call(this); 48389 } 48390}; 48391_handleMenuItems = /* @__PURE__ */ new WeakMap(); 48392_updateLayoutStyle = /* @__PURE__ */ new WeakSet(); 48393updateLayoutStyle_fn = function() { 48394 var _a3; 48395 const layoutRowStyle = this.shadowRoot.querySelector("#layout-row"); 48396 const menuLayout = (_a3 = getComputedStyle(this).getPropertyValue("--media-menu-layout")) == null ? void 0 : _a3.trim(); 48397 layoutRowStyle.setAttribute("media", menuLayout === "row" ? "" : "width:0"); 48398}; 48399_handleInvoke2 = /* @__PURE__ */ new WeakSet(); 48400handleInvoke_fn2 = function(event) { 48401 __privateSet20(this, _invokerElement2, event.relatedTarget); 48402 if (!containsComposedNode(this, event.relatedTarget)) { 48403 this.hidden = !this.hidden; 48404 } 48405}; 48406_handleOpen2 = /* @__PURE__ */ new WeakSet(); 48407handleOpen_fn2 = function() { 48408 var _a3; 48409 (_a3 = __privateGet21(this, _invokerElement2)) == null ? void 0 : _a3.setAttribute("aria-expanded", "true"); 48410 this.addEventListener("transitionend", () => this.focus(), { once: true }); 48411 observeResize(getBoundsElement(this), __privateGet21(this, _handleBoundsResize)); 48412 observeResize(this, __privateGet21(this, _handleMenuResize)); 48413}; 48414_handleClosed2 = /* @__PURE__ */ new WeakSet(); 48415handleClosed_fn2 = function() { 48416 var _a3; 48417 (_a3 = __privateGet21(this, _invokerElement2)) == null ? void 0 : _a3.setAttribute("aria-expanded", "false"); 48418 unobserveResize(getBoundsElement(this), __privateGet21(this, _handleBoundsResize)); 48419 unobserveResize(this, __privateGet21(this, _handleMenuResize)); 48420}; 48421_handleBoundsResize = /* @__PURE__ */ new WeakMap(); 48422_handleMenuResize = /* @__PURE__ */ new WeakMap(); 48423_positionMenu = /* @__PURE__ */ new WeakSet(); 48424positionMenu_fn = function(menuWidth) { 48425 if (this.hasAttribute("mediacontroller") && !this.anchor) 48426 return; 48427 if (this.hidden || !this.anchorElement) 48428 return; 48429 const { x: x2, y: y4 } = computePosition({ 48430 anchor: this.anchorElement, 48431 floating: this, 48432 placement: "top-start" 48433 }); 48434 menuWidth != null ? menuWidth : menuWidth = this.offsetWidth; 48435 const bounds = getBoundsElement(this); 48436 const boundsRect = bounds.getBoundingClientRect(); 48437 const right = boundsRect.width - x2 - menuWidth; 48438 const bottom = boundsRect.height - y4 - this.offsetHeight; 48439 const { style } = __privateGet21(this, _cssRule); 48440 style.setProperty("position", "absolute"); 48441 style.setProperty("right", `${Math.max(0, right)}px`); 48442 style.setProperty("--_menu-bottom", `${bottom}px`); 48443 const computedStyle = getComputedStyle(this); 48444 const isBottomCalc = style.getPropertyValue("--_menu-bottom") === computedStyle.bottom; 48445 const realBottom = isBottomCalc ? bottom : parseFloat(computedStyle.bottom); 48446 const maxHeight = boundsRect.height - realBottom - parseFloat(computedStyle.marginBottom); 48447 this.style.setProperty("--_menu-max-height", `${maxHeight}px`); 48448}; 48449_resizeMenu = /* @__PURE__ */ new WeakSet(); 48450resizeMenu_fn = function(animate) { 48451 const expandedMenuItem = this.querySelector( 48452 '[role="menuitem"][aria-haspopup][aria-expanded="true"]' 48453 ); 48454 const expandedSubmenu = expandedMenuItem == null ? void 0 : expandedMenuItem.querySelector( 48455 '[role="menu"]' 48456 ); 48457 const { style } = __privateGet21(this, _cssRule); 48458 if (!animate) { 48459 style.setProperty("--media-menu-transition-in", "none"); 48460 } 48461 if (expandedSubmenu) { 48462 const height = expandedSubmenu.offsetHeight; 48463 const width = Math.max( 48464 expandedSubmenu.offsetWidth, 48465 expandedMenuItem.offsetWidth 48466 ); 48467 this.style.setProperty("min-width", `${width}px`); 48468 this.style.setProperty("min-height", `${height}px`); 48469 __privateMethod8(this, _positionMenu, positionMenu_fn).call(this, width); 48470 } else { 48471 this.style.removeProperty("min-width"); 48472 this.style.removeProperty("min-height"); 48473 __privateMethod8(this, _positionMenu, positionMenu_fn).call(this); 48474 } 48475 style.removeProperty("--media-menu-transition-in"); 48476}; 48477_handleClick = /* @__PURE__ */ new WeakSet(); 48478handleClick_fn = function(event) { 48479 var _a3; 48480 event.stopPropagation(); 48481 if (event.composedPath().includes(__privateGet21(this, _backButtonElement, backButtonElement_get))) { 48482 (_a3 = __privateGet21(this, _previouslyFocused2)) == null ? void 0 : _a3.focus(); 48483 this.hidden = true; 48484 return; 48485 } 48486 const item = __privateMethod8(this, _getItem, getItem_fn).call(this, event); 48487 if (!item || item.hasAttribute("disabled")) 48488 return; 48489 __privateMethod8(this, _setTabItem, setTabItem_fn).call(this, item); 48490 this.handleSelect(event); 48491}; 48492_backButtonElement = /* @__PURE__ */ new WeakSet(); 48493backButtonElement_get = function() { 48494 var _a3; 48495 const headerSlot = this.shadowRoot.querySelector( 48496 'slot[name="header"]' 48497 ); 48498 return (_a3 = headerSlot.assignedElements({ flatten: true })) == null ? void 0 : _a3.find( 48499 (el) => el.matches('button[part~="back"]') 48500 ); 48501}; 48502_handleToggle = /* @__PURE__ */ new WeakSet(); 48503handleToggle_fn = function(event) { 48504 if (event.target === this) 48505 return; 48506 __privateMethod8(this, _checkSubmenuHasExpanded, checkSubmenuHasExpanded_fn).call(this); 48507 const menuItemsWithSubmenu = Array.from( 48508 this.querySelectorAll('[role="menuitem"][aria-haspopup]') 48509 ); 48510 for (const item of menuItemsWithSubmenu) { 48511 if (item.invokeTargetElement == event.target) 48512 continue; 48513 if (event.newState == "open" && item.getAttribute("aria-expanded") == "true" && !item.invokeTargetElement.hidden) { 48514 item.invokeTargetElement.dispatchEvent( 48515 new InvokeEvent({ relatedTarget: item }) 48516 ); 48517 } 48518 } 48519 for (const item of menuItemsWithSubmenu) { 48520 item.setAttribute("aria-expanded", `${!item.submenuElement.hidden}`); 48521 } 48522 __privateMethod8(this, _resizeMenu, resizeMenu_fn).call(this, true); 48523}; 48524_checkSubmenuHasExpanded = /* @__PURE__ */ new WeakSet(); 48525checkSubmenuHasExpanded_fn = function() { 48526 const selector = '[role="menuitem"] > [role="menu"]:not([hidden])'; 48527 const expandedMenuItem = this.querySelector(selector); 48528 this.container.classList.toggle("has-expanded", !!expandedMenuItem); 48529}; 48530_handleFocusOut2 = /* @__PURE__ */ new WeakSet(); 48531handleFocusOut_fn2 = function(event) { 48532 var _a3; 48533 if (!containsComposedNode(this, event.relatedTarget)) { 48534 if (__privateGet21(this, _isPopover)) { 48535 (_a3 = __privateGet21(this, _previouslyFocused2)) == null ? void 0 : _a3.focus(); 48536 } 48537 if (__privateGet21(this, _invokerElement2) && __privateGet21(this, _invokerElement2) !== event.relatedTarget && !this.hidden) { 48538 this.hidden = true; 48539 } 48540 } 48541}; 48542_handleKeyDown2 = /* @__PURE__ */ new WeakSet(); 48543handleKeyDown_fn2 = function(event) { 48544 var _a3, _b, _c, _d, _e5; 48545 const { key, ctrlKey, altKey, metaKey } = event; 48546 if (ctrlKey || altKey || metaKey) { 48547 return; 48548 } 48549 if (!this.keysUsed.includes(key)) { 48550 return; 48551 } 48552 event.preventDefault(); 48553 event.stopPropagation(); 48554 if (key === "Tab") { 48555 if (__privateGet21(this, _isPopover)) { 48556 this.hidden = true; 48557 return; 48558 } 48559 if (event.shiftKey) { 48560 (_b = (_a3 = this.previousElementSibling) == null ? void 0 : _a3.focus) == null ? void 0 : _b.call(_a3); 48561 } else { 48562 (_d = (_c = this.nextElementSibling) == null ? void 0 : _c.focus) == null ? void 0 : _d.call(_c); 48563 } 48564 this.blur(); 48565 } else if (key === "Escape") { 48566 (_e5 = __privateGet21(this, _previouslyFocused2)) == null ? void 0 : _e5.focus(); 48567 if (__privateGet21(this, _isPopover)) { 48568 this.hidden = true; 48569 } 48570 } else if (key === "Enter" || key === " ") { 48571 this.handleSelect(event); 48572 } else { 48573 this.handleMove(event); 48574 } 48575}; 48576_getItem = /* @__PURE__ */ new WeakSet(); 48577getItem_fn = function(event) { 48578 return event.composedPath().find((el) => { 48579 return ["menuitemradio", "menuitemcheckbox"].includes( 48580 el.role 48581 ); 48582 }); 48583}; 48584_getTabItem = /* @__PURE__ */ new WeakSet(); 48585getTabItem_fn = function() { 48586 return this.items.find((item) => item.tabIndex === 0); 48587}; 48588_setTabItem = /* @__PURE__ */ new WeakSet(); 48589setTabItem_fn = function(tabItem) { 48590 for (const item of this.items) { 48591 item.tabIndex = item === tabItem ? 0 : -1; 48592 } 48593}; 48594_selectItem = /* @__PURE__ */ new WeakSet(); 48595selectItem_fn = function(item, toggle) { 48596 const oldCheckedItems = [...this.checkedItems]; 48597 if (item.type === "radio") { 48598 this.radioGroupItems.forEach((el) => el.checked = false); 48599 } 48600 if (toggle) { 48601 item.checked = !item.checked; 48602 } else { 48603 item.checked = true; 48604 } 48605 if (this.checkedItems.some((opt, i3) => opt != oldCheckedItems[i3])) { 48606 this.dispatchEvent( 48607 new Event("change", { bubbles: true, composed: true }) 48608 ); 48609 } 48610}; 48611MediaChromeMenu.template = template13; 48612function isMenuItem(element) { 48613 return ["menuitem", "menuitemradio", "menuitemcheckbox"].includes( 48614 element == null ? void 0 : element.role 48615 ); 48616} 48617function getBoundsElement(host) { 48618 var _a3; 48619 return (_a3 = host.getAttribute("bounds") ? closestComposedNode(host, `#${host.getAttribute("bounds")}`) : getMediaController(host) || host.parentElement) != null ? _a3 : host; 48620} 48621if (!GlobalThis.customElements.get("media-chrome-menu")) { 48622 GlobalThis.customElements.define("media-chrome-menu", MediaChromeMenu); 48623} 48624
vendor: 14,141 bytes, lines 48625-49063
48625// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/menu/media-chrome-menu-item.js 48626var __accessCheck22 = (obj, member, msg) => { 48627 if (!member.has(obj)) 48628 throw TypeError("Cannot " + msg); 48629}; 48630var __privateGet22 = (obj, member, getter) => { 48631 __accessCheck22(obj, member, "read from private field"); 48632 return getter ? getter.call(obj) : member.get(obj); 48633}; 48634var __privateAdd22 = (obj, member, value) => { 48635 if (member.has(obj)) 48636 throw TypeError("Cannot add the same private member more than once"); 48637 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 48638}; 48639var __privateSet21 = (obj, member, value, setter) => { 48640 __accessCheck22(obj, member, "write to private field"); 48641 setter ? setter.call(obj, value) : member.set(obj, value); 48642 return value; 48643}; 48644var __privateMethod9 = (obj, member, method) => { 48645 __accessCheck22(obj, member, "access private method"); 48646 return method; 48647}; 48648var _dirty; 48649var _ownerElement; 48650var _handleSlotChange2; 48651var handleSlotChange_fn2; 48652var _submenuConnected; 48653var submenuConnected_fn; 48654var _submenuDisconnected; 48655var submenuDisconnected_fn; 48656var _handleMenuItem; 48657var _handleKeyUp; 48658var handleKeyUp_fn; 48659var _handleKeyDown3; 48660var handleKeyDown_fn3; 48661var _reset; 48662var reset_fn; 48663var template14 = Document2.createElement("template"); 48664template14.innerHTML = /*html*/ 48665` 48666 <style> 48667 :host { 48668 transition: var(--media-menu-item-transition, 48669 background .15s linear, 48670 opacity .2s ease-in-out 48671 ); 48672 outline: var(--media-menu-item-outline, 0); 48673 outline-offset: var(--media-menu-item-outline-offset, -1px); 48674 cursor: pointer; 48675 display: flex; 48676 align-items: center; 48677 align-self: stretch; 48678 justify-self: stretch; 48679 white-space: nowrap; 48680 white-space-collapse: collapse; 48681 text-wrap: nowrap; 48682 padding: .4em .8em .4em 1em; 48683 } 48684 48685 :host(:focus-visible) { 48686 box-shadow: var(--media-menu-item-focus-shadow, inset 0 0 0 2px rgb(27 127 204 / .9)); 48687 outline: var(--media-menu-item-hover-outline, 0); 48688 outline-offset: var(--media-menu-item-hover-outline-offset, var(--media-menu-item-outline-offset, -1px)); 48689 } 48690 48691 :host(:hover) { 48692 cursor: pointer; 48693 background: var(--media-menu-item-hover-background, rgb(92 92 102 / .5)); 48694 outline: var(--media-menu-item-hover-outline); 48695 outline-offset: var(--media-menu-item-hover-outline-offset, var(--media-menu-item-outline-offset, -1px)); 48696 } 48697 48698 :host([aria-checked="true"]) { 48699 background: var(--media-menu-item-checked-background); 48700 } 48701 48702 :host([hidden]) { 48703 display: none; 48704 } 48705 48706 :host([disabled]) { 48707 pointer-events: none; 48708 color: rgba(255, 255, 255, .3); 48709 } 48710 48711 slot:not([name]) { 48712 width: 100%; 48713 } 48714 48715 slot:not([name="submenu"]) { 48716 display: inline-flex; 48717 align-items: center; 48718 transition: inherit; 48719 opacity: var(--media-menu-item-opacity, 1); 48720 } 48721 48722 slot[name="description"] { 48723 justify-content: end; 48724 } 48725 48726 slot[name="description"] > span { 48727 display: inline-block; 48728 margin-inline: 1em .2em; 48729 max-width: var(--media-menu-item-description-max-width, 100px); 48730 text-overflow: ellipsis; 48731 overflow: hidden; 48732 font-size: .8em; 48733 font-weight: 400; 48734 text-align: right; 48735 position: relative; 48736 top: .04em; 48737 } 48738 48739 slot[name="checked-indicator"] { 48740 display: none; 48741 } 48742 48743 :host(:is([role="menuitemradio"],[role="menuitemcheckbox"])) slot[name="checked-indicator"] { 48744 display: var(--media-menu-item-checked-indicator-display, inline-block); 48745 } 48746 48747 ${/* For all slotted icons in prefix and suffix. */ 48748""} 48749 svg, img, ::slotted(svg), ::slotted(img) { 48750 height: var(--media-menu-item-icon-height, var(--media-control-height, 24px)); 48751 fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238))); 48752 display: block; 48753 } 48754 48755 ${/* Only for indicator icons like checked-indicator or captions-indicator. */ 48756""} 48757 [part~="indicator"], 48758 ::slotted([part~="indicator"]) { 48759 fill: var(--media-menu-item-indicator-fill, 48760 var(--media-icon-color, var(--media-primary-color, rgb(238 238 238)))); 48761 height: var(--media-menu-item-indicator-height, 1.25em); 48762 margin-right: .5ch; 48763 } 48764 48765 [part~="checked-indicator"] { 48766 visibility: hidden; 48767 } 48768 48769 :host([aria-checked="true"]) [part~="checked-indicator"] { 48770 visibility: visible; 48771 } 48772 </style> 48773 <slot name="checked-indicator"> 48774 <svg aria-hidden="true" viewBox="0 1 24 24" part="checked-indicator indicator"> 48775 <path d="m10 15.17 9.193-9.191 1.414 1.414-10.606 10.606-6.364-6.364 1.414-1.414 4.95 4.95Z"/> 48776 </svg> 48777 </slot> 48778 <slot name="prefix"></slot> 48779 <slot></slot> 48780 <slot name="description"></slot> 48781 <slot name="suffix"></slot> 48782 <slot name="submenu"></slot> 48783`; 48784var Attributes13 = { 48785 TYPE: "type", 48786 VALUE: "value", 48787 CHECKED: "checked", 48788 DISABLED: "disabled" 48789}; 48790var MediaChromeMenuItem = class extends GlobalThis.HTMLElement { 48791 constructor() { 48792 super(); 48793 __privateAdd22(this, _handleSlotChange2); 48794 __privateAdd22(this, _submenuConnected); 48795 __privateAdd22(this, _submenuDisconnected); 48796 __privateAdd22(this, _handleKeyUp); 48797 __privateAdd22(this, _handleKeyDown3); 48798 __privateAdd22(this, _reset); 48799 __privateAdd22(this, _dirty, false); 48800 __privateAdd22(this, _ownerElement, void 0); 48801 __privateAdd22(this, _handleMenuItem, () => { 48802 var _a3, _b; 48803 this.setAttribute("submenusize", `${this.submenuElement.items.length}`); 48804 const descriptionSlot = this.shadowRoot.querySelector( 48805 'slot[name="description"]' 48806 ); 48807 const checkedItem = (_a3 = this.submenuElement.checkedItems) == null ? void 0 : _a3[0]; 48808 const description = (_b = checkedItem == null ? void 0 : checkedItem.dataset.description) != null ? _b : checkedItem == null ? void 0 : checkedItem.text; 48809 const span = Document2.createElement("span"); 48810 span.textContent = description != null ? description : ""; 48811 descriptionSlot.replaceChildren(span); 48812 }); 48813 if (!this.shadowRoot) { 48814 this.attachShadow({ mode: "open" }); 48815 this.shadowRoot.append(this.constructor.template.content.cloneNode(true)); 48816 } 48817 this.shadowRoot.addEventListener("slotchange", this); 48818 } 48819 static get observedAttributes() { 48820 return [ 48821 Attributes13.TYPE, 48822 Attributes13.DISABLED, 48823 Attributes13.CHECKED, 48824 Attributes13.VALUE 48825 ]; 48826 } 48827 enable() { 48828 if (!this.hasAttribute("tabindex")) { 48829 this.setAttribute("tabindex", "-1"); 48830 } 48831 if (isCheckable(this) && !this.hasAttribute("aria-checked")) { 48832 this.setAttribute("aria-checked", "false"); 48833 } 48834 this.addEventListener("click", this); 48835 this.addEventListener("keydown", this); 48836 } 48837 disable() { 48838 this.removeAttribute("tabindex"); 48839 this.removeEventListener("click", this); 48840 this.removeEventListener("keydown", this); 48841 this.removeEventListener("keyup", this); 48842 } 48843 handleEvent(event) { 48844 switch (event.type) { 48845 case "slotchange": 48846 __privateMethod9(this, _handleSlotChange2, handleSlotChange_fn2).call(this, event); 48847 break; 48848 case "click": 48849 this.handleClick(event); 48850 break; 48851 case "keydown": 48852 __privateMethod9(this, _handleKeyDown3, handleKeyDown_fn3).call(this, event); 48853 break; 48854 case "keyup": 48855 __privateMethod9(this, _handleKeyUp, handleKeyUp_fn).call(this, event); 48856 break; 48857 } 48858 } 48859 attributeChangedCallback(attrName, oldValue, newValue) { 48860 if (attrName === Attributes13.CHECKED && isCheckable(this) && !__privateGet22(this, _dirty)) { 48861 this.setAttribute("aria-checked", newValue != null ? "true" : "false"); 48862 } else if (attrName === Attributes13.TYPE && newValue !== oldValue) { 48863 this.role = "menuitem" + newValue; 48864 } else if (attrName === Attributes13.DISABLED && newValue !== oldValue) { 48865 if (newValue == null) { 48866 this.enable(); 48867 } else { 48868 this.disable(); 48869 } 48870 } 48871 } 48872 connectedCallback() { 48873 if (!this.hasAttribute(Attributes13.DISABLED)) { 48874 this.enable(); 48875 } 48876 this.role = "menuitem" + this.type; 48877 __privateSet21(this, _ownerElement, closestMenuItemsContainer(this, this.parentNode)); 48878 __privateMethod9(this, _reset, reset_fn).call(this); 48879 } 48880 disconnectedCallback() { 48881 this.disable(); 48882 __privateMethod9(this, _reset, reset_fn).call(this); 48883 __privateSet21(this, _ownerElement, null); 48884 } 48885 get invokeTarget() { 48886 return this.getAttribute("invoketarget"); 48887 } 48888 set invokeTarget(value) { 48889 this.setAttribute("invoketarget", `${value}`); 48890 } 48891 /** 48892 * Returns the element with the id specified by the `invoketarget` attribute 48893 * or the slotted submenu element. 48894 */ 48895 get invokeTargetElement() { 48896 var _a3; 48897 if (this.invokeTarget) { 48898 return (_a3 = getDocumentOrShadowRoot(this)) == null ? void 0 : _a3.querySelector( 48899 `#${this.invokeTarget}` 48900 ); 48901 } 48902 return this.submenuElement; 48903 } 48904 /** 48905 * Returns the slotted submenu element. 48906 */ 48907 get submenuElement() { 48908 const submenuSlot = this.shadowRoot.querySelector( 48909 'slot[name="submenu"]' 48910 ); 48911 return submenuSlot.assignedElements({ 48912 flatten: true 48913 })[0]; 48914 } 48915 get type() { 48916 var _a3; 48917 return (_a3 = this.getAttribute(Attributes13.TYPE)) != null ? _a3 : ""; 48918 } 48919 set type(val) { 48920 this.setAttribute(Attributes13.TYPE, `${val}`); 48921 } 48922 get value() { 48923 var _a3; 48924 return (_a3 = this.getAttribute(Attributes13.VALUE)) != null ? _a3 : this.text; 48925 } 48926 set value(val) { 48927 this.setAttribute(Attributes13.VALUE, val); 48928 } 48929 get text() { 48930 var _a3; 48931 return ((_a3 = this.textContent) != null ? _a3 : "").trim(); 48932 } 48933 get checked() { 48934 if (!isCheckable(this)) 48935 return void 0; 48936 return this.getAttribute("aria-checked") === "true"; 48937 } 48938 set checked(value) { 48939 if (!isCheckable(this)) 48940 return; 48941 __privateSet21(this, _dirty, true); 48942 this.setAttribute("aria-checked", value ? "true" : "false"); 48943 if (value) { 48944 this.part.add("checked"); 48945 } else { 48946 this.part.remove("checked"); 48947 } 48948 } 48949 handleClick(event) { 48950 if (isCheckable(this)) 48951 return; 48952 if (this.invokeTargetElement && containsComposedNode(this, event.target)) { 48953 this.invokeTargetElement.dispatchEvent( 48954 new InvokeEvent({ relatedTarget: this }) 48955 ); 48956 } 48957 } 48958 get keysUsed() { 48959 return ["Enter", " "]; 48960 } 48961}; 48962_dirty = /* @__PURE__ */ new WeakMap(); 48963_ownerElement = /* @__PURE__ */ new WeakMap(); 48964_handleSlotChange2 = /* @__PURE__ */ new WeakSet(); 48965handleSlotChange_fn2 = function(event) { 48966 const slot = event.target; 48967 const isDefaultSlot = !(slot == null ? void 0 : slot.name); 48968 if (isDefaultSlot) { 48969 for (const node2 of slot.assignedNodes({ flatten: true })) { 48970 if (node2 instanceof Text && node2.textContent.trim() === "") { 48971 node2.remove(); 48972 } 48973 } 48974 } 48975 if (slot.name === "submenu") { 48976 if (this.submenuElement) { 48977 __privateMethod9(this, _submenuConnected, submenuConnected_fn).call(this); 48978 } else { 48979 __privateMethod9(this, _submenuDisconnected, submenuDisconnected_fn).call(this); 48980 } 48981 } 48982}; 48983_submenuConnected = /* @__PURE__ */ new WeakSet(); 48984submenuConnected_fn = async function() { 48985 this.setAttribute("aria-haspopup", "menu"); 48986 this.setAttribute("aria-expanded", `${!this.submenuElement.hidden}`); 48987 this.submenuElement.addEventListener("change", __privateGet22(this, _handleMenuItem)); 48988 this.submenuElement.addEventListener("addmenuitem", __privateGet22(this, _handleMenuItem)); 48989 this.submenuElement.addEventListener( 48990 "removemenuitem", 48991 __privateGet22(this, _handleMenuItem) 48992 ); 48993 __privateGet22(this, _handleMenuItem).call(this); 48994}; 48995_submenuDisconnected = /* @__PURE__ */ new WeakSet(); 48996submenuDisconnected_fn = function() { 48997 this.removeAttribute("aria-haspopup"); 48998 this.removeAttribute("aria-expanded"); 48999 this.submenuElement.removeEventListener("change", __privateGet22(this, _handleMenuItem)); 49000 this.submenuElement.removeEventListener( 49001 "addmenuitem", 49002 __privateGet22(this, _handleMenuItem) 49003 ); 49004 this.submenuElement.removeEventListener( 49005 "removemenuitem", 49006 __privateGet22(this, _handleMenuItem) 49007 ); 49008 __privateGet22(this, _handleMenuItem).call(this); 49009}; 49010_handleMenuItem = /* @__PURE__ */ new WeakMap(); 49011_handleKeyUp = /* @__PURE__ */ new WeakSet(); 49012handleKeyUp_fn = function(event) { 49013 const { key } = event; 49014 if (!this.keysUsed.includes(key)) { 49015 this.removeEventListener("keyup", __privateMethod9(this, _handleKeyUp, handleKeyUp_fn)); 49016 return; 49017 } 49018 this.handleClick(event); 49019}; 49020_handleKeyDown3 = /* @__PURE__ */ new WeakSet(); 49021handleKeyDown_fn3 = function(event) { 49022 const { metaKey, altKey, key } = event; 49023 if (metaKey || altKey || !this.keysUsed.includes(key)) { 49024 this.removeEventListener("keyup", __privateMethod9(this, _handleKeyUp, handleKeyUp_fn)); 49025 return; 49026 } 49027 this.addEventListener("keyup", __privateMethod9(this, _handleKeyUp, handleKeyUp_fn), { once: true }); 49028}; 49029_reset = /* @__PURE__ */ new WeakSet(); 49030reset_fn = function() { 49031 var _a3; 49032 const items = (_a3 = __privateGet22(this, _ownerElement)) == null ? void 0 : _a3.radioGroupItems; 49033 if (!items) 49034 return; 49035 let checkedItem = items.filter((item) => item.getAttribute("aria-checked") === "true").pop(); 49036 if (!checkedItem) 49037 checkedItem = items[0]; 49038 for (const item of items) { 49039 item.setAttribute("aria-checked", "false"); 49040 } 49041 checkedItem == null ? void 0 : checkedItem.setAttribute("aria-checked", "true"); 49042}; 49043MediaChromeMenuItem.template = template14; 49044function isCheckable(item) { 49045 return item.type === "radio" || item.type === "checkbox"; 49046} 49047function closestMenuItemsContainer(childNode, parentNode) { 49048 if (!childNode) 49049 return null; 49050 const { host } = childNode.getRootNode(); 49051 if (!parentNode && host) 49052 return closestMenuItemsContainer(childNode, host); 49053 if (parentNode == null ? void 0 : parentNode.items) 49054 return parentNode; 49055 return closestMenuItemsContainer(parentNode, parentNode == null ? void 0 : parentNode.parentNode); 49056} 49057if (!GlobalThis.customElements.get("media-chrome-menu-item")) { 49058 GlobalThis.customElements.define( 49059 "media-chrome-menu-item", 49060 MediaChromeMenuItem 49061 ); 49062} 49063
vendor: 1,496 bytes, lines 49064-49110
49064// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/menu/media-settings-menu.js 49065var template15 = Document2.createElement("template"); 49066template15.innerHTML = MediaChromeMenu.template.innerHTML + /*html*/ 49067` 49068 <style> 49069 :host { 49070 background: var(--media-settings-menu-background, 49071 var(--media-menu-background, 49072 var(--media-control-background, 49073 var(--media-secondary-color, rgb(20 20 30 / .8))))); 49074 min-width: var(--media-settings-menu-min-width, 170px); 49075 border-radius: 2px 2px 0 0; 49076 overflow: hidden; 49077 } 49078 49079 :host([role="menu"]) { 49080 ${/* Bottom fix setting menu items for animation when the height expands. */ 49081""} 49082 justify-content: end; 49083 } 49084 49085 slot:not([name]) { 49086 justify-content: var(--media-settings-menu-justify-content); 49087 flex-direction: var(--media-settings-menu-flex-direction, column); 49088 overflow: visible; 49089 } 49090 49091 #container.has-expanded { 49092 --media-settings-menu-item-opacity: 0; 49093 } 49094 </style> 49095`; 49096var MediaSettingsMenu = class extends MediaChromeMenu { 49097 /** 49098 * Returns the anchor element when it is a floating menu. 49099 */ 49100 get anchorElement() { 49101 if (this.anchor !== "auto") 49102 return super.anchorElement; 49103 return getMediaController(this).querySelector("media-settings-menu-button"); 49104 } 49105}; 49106MediaSettingsMenu.template = template15; 49107if (!GlobalThis.customElements.get("media-settings-menu")) { 49108 GlobalThis.customElements.define("media-settings-menu", MediaSettingsMenu); 49109} 49110
vendor: 1,070 bytes, lines 49111-49143
49111// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/menu/media-settings-menu-item.js 49112var _a2; 49113var template16 = Document2.createElement("template"); 49114template16.innerHTML = MediaChromeMenuItem.template.innerHTML + /*html*/ 49115` 49116 <style> 49117 slot:not([name="submenu"]) { 49118 opacity: var(--media-settings-menu-item-opacity, var(--media-menu-item-opacity)); 49119 } 49120 49121 :host([aria-expanded="true"]:hover) { 49122 background: transparent; 49123 } 49124 </style> 49125`; 49126if ((_a2 = template16.content) == null ? void 0 : _a2.querySelector) { 49127 template16.content.querySelector('slot[name="suffix"]').innerHTML = /*html*/ 49128 ` 49129 <svg aria-hidden="true" viewBox="0 0 20 24"> 49130 <path d="m8.12 17.585-.742-.669 4.2-4.665-4.2-4.666.743-.669 4.803 5.335-4.803 5.334Z"/> 49131 </svg> 49132 `; 49133} 49134var MediaSettingsMenuItem = class extends MediaChromeMenuItem { 49135}; 49136MediaSettingsMenuItem.template = template16; 49137if (!GlobalThis.customElements.get("media-settings-menu-item")) { 49138 GlobalThis.customElements.define( 49139 "media-settings-menu-item", 49140 MediaSettingsMenuItem 49141 ); 49142} 49143
vendor: 1,164 bytes, lines 49144-49184
49144// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/menu/media-chrome-menu-button.js 49145var MediaChromeMenuButton = class extends MediaChromeButton { 49146 connectedCallback() { 49147 super.connectedCallback(); 49148 if (this.invokeTargetElement) { 49149 this.setAttribute("aria-haspopup", "menu"); 49150 } 49151 } 49152 get invokeTarget() { 49153 return this.getAttribute("invoketarget"); 49154 } 49155 set invokeTarget(value) { 49156 this.setAttribute("invoketarget", `${value}`); 49157 } 49158 /** 49159 * Returns the element with the id specified by the `invoketarget` attribute. 49160 * @return {HTMLElement | null} 49161 */ 49162 get invokeTargetElement() { 49163 var _a3; 49164 if (this.invokeTarget) { 49165 return (_a3 = getDocumentOrShadowRoot(this)) == null ? void 0 : _a3.querySelector( 49166 `#${this.invokeTarget}` 49167 ); 49168 } 49169 return null; 49170 } 49171 handleClick() { 49172 var _a3; 49173 (_a3 = this.invokeTargetElement) == null ? void 0 : _a3.dispatchEvent( 49174 new InvokeEvent({ relatedTarget: this }) 49175 ); 49176 } 49177}; 49178if (!GlobalThis.customElements.get("media-chrome-menu-button")) { 49179 GlobalThis.customElements.define( 49180 "media-chrome-menu-button", 49181 MediaChromeMenuButton 49182 ); 49183} 49184
vendor: 1,420 bytes, lines 49185-49227
49185// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/menu/media-settings-menu-button.js 49186var slotTemplate12 = Document2.createElement("template"); 49187slotTemplate12.innerHTML = /*html*/ 49188` 49189 <style> 49190 :host([aria-expanded="true"]) slot[name=tooltip] { 49191 display: none; 49192 } 49193 </style> 49194 <slot name="icon"> 49195 <svg aria-hidden="true" viewBox="0 0 24 24"> 49196 <path d="M4.5 14.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm7.5 0a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm7.5 0a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z"/> 49197 </svg> 49198 </slot> 49199`; 49200var MediaSettingsMenuButton = class extends MediaChromeMenuButton { 49201 static get observedAttributes() { 49202 return [...super.observedAttributes, "target"]; 49203 } 49204 constructor() { 49205 super({ slotTemplate: slotTemplate12, tooltipContent: tooltipLabels.SETTINGS }); 49206 } 49207 connectedCallback() { 49208 super.connectedCallback(); 49209 this.setAttribute("aria-label", nouns.SETTINGS()); 49210 } 49211 /** 49212 * Returns the element with the id specified by the `invoketarget` attribute. 49213 * @return {HTMLElement | null} 49214 */ 49215 get invokeTargetElement() { 49216 if (this.invokeTarget != void 0) 49217 return super.invokeTargetElement; 49218 return getMediaController(this).querySelector("media-settings-menu"); 49219 } 49220}; 49221if (!GlobalThis.customElements.get("media-settings-menu-button")) { 49222 GlobalThis.customElements.define( 49223 "media-settings-menu-button", 49224 MediaSettingsMenuButton 49225 ); 49226} 49227
vendor: 4,461 bytes, lines 49228-49360
49228// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/menu/media-audio-track-menu.js 49229var __accessCheck23 = (obj, member, msg) => { 49230 if (!member.has(obj)) 49231 throw TypeError("Cannot " + msg); 49232}; 49233var __privateGet23 = (obj, member, getter) => { 49234 __accessCheck23(obj, member, "read from private field"); 49235 return getter ? getter.call(obj) : member.get(obj); 49236}; 49237var __privateAdd23 = (obj, member, value) => { 49238 if (member.has(obj)) 49239 throw TypeError("Cannot add the same private member more than once"); 49240 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 49241}; 49242var __privateSet22 = (obj, member, value, setter) => { 49243 __accessCheck23(obj, member, "write to private field"); 49244 setter ? setter.call(obj, value) : member.set(obj, value); 49245 return value; 49246}; 49247var __privateMethod10 = (obj, member, method) => { 49248 __accessCheck23(obj, member, "access private method"); 49249 return method; 49250}; 49251var _audioTrackList; 49252var _prevState; 49253var _render; 49254var render_fn; 49255var _onChange; 49256var onChange_fn; 49257var MediaAudioTrackMenu = class extends MediaChromeMenu { 49258 constructor() { 49259 super(...arguments); 49260 __privateAdd23(this, _render); 49261 __privateAdd23(this, _onChange); 49262 __privateAdd23(this, _audioTrackList, []); 49263 __privateAdd23(this, _prevState, void 0); 49264 } 49265 static get observedAttributes() { 49266 return [ 49267 ...super.observedAttributes, 49268 MediaUIAttributes.MEDIA_AUDIO_TRACK_LIST, 49269 MediaUIAttributes.MEDIA_AUDIO_TRACK_ENABLED, 49270 MediaUIAttributes.MEDIA_AUDIO_TRACK_UNAVAILABLE 49271 ]; 49272 } 49273 attributeChangedCallback(attrName, oldValue, newValue) { 49274 super.attributeChangedCallback(attrName, oldValue, newValue); 49275 if (attrName === MediaUIAttributes.MEDIA_AUDIO_TRACK_ENABLED && oldValue !== newValue) { 49276 this.value = newValue; 49277 } else if (attrName === MediaUIAttributes.MEDIA_AUDIO_TRACK_LIST && oldValue !== newValue) { 49278 __privateSet22(this, _audioTrackList, parseAudioTrackList(newValue != null ? newValue : "")); 49279 __privateMethod10(this, _render, render_fn).call(this); 49280 } 49281 } 49282 connectedCallback() { 49283 super.connectedCallback(); 49284 this.addEventListener("change", __privateMethod10(this, _onChange, onChange_fn)); 49285 } 49286 disconnectedCallback() { 49287 super.disconnectedCallback(); 49288 this.removeEventListener("change", __privateMethod10(this, _onChange, onChange_fn)); 49289 } 49290 /** 49291 * Returns the anchor element when it is a floating menu. 49292 */ 49293 get anchorElement() { 49294 var _a3; 49295 if (this.anchor !== "auto") 49296 return super.anchorElement; 49297 return (_a3 = getMediaController(this)) == null ? void 0 : _a3.querySelector( 49298 "media-audio-track-menu-button" 49299 ); 49300 } 49301 get mediaAudioTrackList() { 49302 return __privateGet23(this, _audioTrackList); 49303 } 49304 set mediaAudioTrackList(list) { 49305 __privateSet22(this, _audioTrackList, list); 49306 __privateMethod10(this, _render, render_fn).call(this); 49307 } 49308 /** 49309 * Get enabled audio track id. 49310 */ 49311 get mediaAudioTrackEnabled() { 49312 var _a3; 49313 return (_a3 = getStringAttr(this, MediaUIAttributes.MEDIA_AUDIO_TRACK_ENABLED)) != null ? _a3 : ""; 49314 } 49315 set mediaAudioTrackEnabled(id) { 49316 setStringAttr(this, MediaUIAttributes.MEDIA_AUDIO_TRACK_ENABLED, id); 49317 } 49318}; 49319_audioTrackList = /* @__PURE__ */ new WeakMap(); 49320_prevState = /* @__PURE__ */ new WeakMap(); 49321_render = /* @__PURE__ */ new WeakSet(); 49322render_fn = function() { 49323 if (__privateGet23(this, _prevState) === JSON.stringify(this.mediaAudioTrackList)) 49324 return; 49325 __privateSet22(this, _prevState, JSON.stringify(this.mediaAudioTrackList)); 49326 const audioTrackList = this.mediaAudioTrackList; 49327 this.defaultSlot.textContent = ""; 49328 for (const audioTrack of audioTrackList) { 49329 const text = this.formatMenuItemText(audioTrack.label, audioTrack); 49330 const item = createMenuItem({ 49331 type: "radio", 49332 text, 49333 value: `${audioTrack.id}`, 49334 checked: audioTrack.enabled 49335 }); 49336 item.prepend(createIndicator(this, "checked-indicator")); 49337 this.defaultSlot.append(item); 49338 } 49339}; 49340_onChange = /* @__PURE__ */ new WeakSet(); 49341onChange_fn = function() { 49342 if (this.value == null) 49343 return; 49344 const event = new GlobalThis.CustomEvent( 49345 MediaUIEvents.MEDIA_AUDIO_TRACK_REQUEST, 49346 { 49347 composed: true, 49348 bubbles: true, 49349 detail: this.value 49350 } 49351 ); 49352 this.dispatchEvent(event); 49353}; 49354if (!GlobalThis.customElements.get("media-audio-track-menu")) { 49355 GlobalThis.customElements.define( 49356 "media-audio-track-menu", 49357 MediaAudioTrackMenu 49358 ); 49359} 49360
vendor: 2,167 bytes, lines 49361-49425
49361// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/menu/media-audio-track-menu-button.js 49362var audioTrackIcon = ( 49363 /*html*/ 49364 `<svg aria-hidden="true" viewBox="0 0 24 24"> 49365 <path d="M11 17H9.5V7H11v10Zm-3-3H6.5v-4H8v4Zm6-5h-1.5v6H14V9Zm3 7h-1.5V8H17v8Z"/> 49366 <path d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Zm-2 0a8 8 0 1 0-16 0 8 8 0 0 0 16 0Z"/> 49367</svg>` 49368); 49369var slotTemplate13 = Document2.createElement("template"); 49370slotTemplate13.innerHTML = /*html*/ 49371` 49372 <style> 49373 :host([aria-expanded="true"]) slot[name=tooltip] { 49374 display: none; 49375 } 49376 </style> 49377 <slot name="icon">${audioTrackIcon}</slot> 49378`; 49379var MediaAudioTrackMenuButton = class extends MediaChromeMenuButton { 49380 static get observedAttributes() { 49381 return [ 49382 ...super.observedAttributes, 49383 MediaUIAttributes.MEDIA_AUDIO_TRACK_ENABLED, 49384 MediaUIAttributes.MEDIA_AUDIO_TRACK_UNAVAILABLE 49385 ]; 49386 } 49387 constructor() { 49388 super({ slotTemplate: slotTemplate13, tooltipContent: tooltipLabels.AUDIO_TRACK_MENU }); 49389 } 49390 connectedCallback() { 49391 super.connectedCallback(); 49392 this.setAttribute("aria-label", nouns.AUDIO_TRACKS()); 49393 } 49394 attributeChangedCallback(attrName, oldValue, newValue) { 49395 super.attributeChangedCallback(attrName, oldValue, newValue); 49396 } 49397 /** 49398 * Returns the element with the id specified by the `invoketarget` attribute. 49399 * @return {HTMLElement | null} 49400 */ 49401 get invokeTargetElement() { 49402 var _a3; 49403 if (this.invokeTarget != void 0) 49404 return super.invokeTargetElement; 49405 return (_a3 = getMediaController(this)) == null ? void 0 : _a3.querySelector("media-audio-track-menu"); 49406 } 49407 /** 49408 * Get enabled audio track id. 49409 * @return {string} 49410 */ 49411 get mediaAudioTrackEnabled() { 49412 var _a3; 49413 return (_a3 = getStringAttr(this, MediaUIAttributes.MEDIA_AUDIO_TRACK_ENABLED)) != null ? _a3 : ""; 49414 } 49415 set mediaAudioTrackEnabled(id) { 49416 setStringAttr(this, MediaUIAttributes.MEDIA_AUDIO_TRACK_ENABLED, id); 49417 } 49418}; 49419if (!GlobalThis.customElements.get("media-audio-track-menu-button")) { 49420 GlobalThis.customElements.define( 49421 "media-audio-track-menu-button", 49422 MediaAudioTrackMenuButton 49423 ); 49424} 49425
vendor: 7,089 bytes, lines 49426-49610
49426// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/menu/media-captions-menu.js 49427var __accessCheck24 = (obj, member, msg) => { 49428 if (!member.has(obj)) 49429 throw TypeError("Cannot " + msg); 49430}; 49431var __privateGet24 = (obj, member, getter) => { 49432 __accessCheck24(obj, member, "read from private field"); 49433 return getter ? getter.call(obj) : member.get(obj); 49434}; 49435var __privateAdd24 = (obj, member, value) => { 49436 if (member.has(obj)) 49437 throw TypeError("Cannot add the same private member more than once"); 49438 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 49439}; 49440var __privateSet23 = (obj, member, value, setter) => { 49441 __accessCheck24(obj, member, "write to private field"); 49442 setter ? setter.call(obj, value) : member.set(obj, value); 49443 return value; 49444}; 49445var __privateMethod11 = (obj, member, method) => { 49446 __accessCheck24(obj, member, "access private method"); 49447 return method; 49448}; 49449var _prevState2; 49450var _render2; 49451var render_fn2; 49452var _onChange2; 49453var onChange_fn2; 49454var ccIcon = ( 49455 /*html*/ 49456 ` 49457 <svg aria-hidden="true" viewBox="0 0 26 24" part="captions-indicator indicator"> 49458 <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/> 49459 </svg>` 49460); 49461var template17 = Document2.createElement("template"); 49462template17.innerHTML = MediaChromeMenu.template.innerHTML + /*html*/ 49463` 49464 <slot name="captions-indicator" hidden>${ccIcon}</slot>`; 49465var MediaCaptionsMenu = class extends MediaChromeMenu { 49466 constructor() { 49467 super(...arguments); 49468 __privateAdd24(this, _render2); 49469 __privateAdd24(this, _onChange2); 49470 __privateAdd24(this, _prevState2, void 0); 49471 } 49472 static get observedAttributes() { 49473 return [ 49474 ...super.observedAttributes, 49475 MediaUIAttributes.MEDIA_SUBTITLES_LIST, 49476 MediaUIAttributes.MEDIA_SUBTITLES_SHOWING 49477 ]; 49478 } 49479 attributeChangedCallback(attrName, oldValue, newValue) { 49480 super.attributeChangedCallback(attrName, oldValue, newValue); 49481 if (attrName === MediaUIAttributes.MEDIA_SUBTITLES_LIST && oldValue !== newValue) { 49482 __privateMethod11(this, _render2, render_fn2).call(this); 49483 } else if (attrName === MediaUIAttributes.MEDIA_SUBTITLES_SHOWING && oldValue !== newValue) { 49484 this.value = newValue; 49485 } 49486 } 49487 connectedCallback() { 49488 super.connectedCallback(); 49489 this.addEventListener("change", __privateMethod11(this, _onChange2, onChange_fn2)); 49490 } 49491 disconnectedCallback() { 49492 super.disconnectedCallback(); 49493 this.removeEventListener("change", __privateMethod11(this, _onChange2, onChange_fn2)); 49494 } 49495 /** 49496 * Returns the anchor element when it is a floating menu. 49497 */ 49498 get anchorElement() { 49499 if (this.anchor !== "auto") 49500 return super.anchorElement; 49501 return getMediaController(this).querySelector("media-captions-menu-button"); 49502 } 49503 /** 49504 * @type {Array<object>} An array of TextTrack-like objects. 49505 * Objects must have the properties: kind, language, and label. 49506 */ 49507 get mediaSubtitlesList() { 49508 return getSubtitlesListAttr2(this, MediaUIAttributes.MEDIA_SUBTITLES_LIST); 49509 } 49510 set mediaSubtitlesList(list) { 49511 setSubtitlesListAttr2(this, MediaUIAttributes.MEDIA_SUBTITLES_LIST, list); 49512 } 49513 /** 49514 * An array of TextTrack-like objects. 49515 * Objects must have the properties: kind, language, and label. 49516 */ 49517 get mediaSubtitlesShowing() { 49518 return getSubtitlesListAttr2( 49519 this, 49520 MediaUIAttributes.MEDIA_SUBTITLES_SHOWING 49521 ); 49522 } 49523 set mediaSubtitlesShowing(list) { 49524 setSubtitlesListAttr2(this, MediaUIAttributes.MEDIA_SUBTITLES_SHOWING, list); 49525 } 49526}; 49527_prevState2 = /* @__PURE__ */ new WeakMap(); 49528_render2 = /* @__PURE__ */ new WeakSet(); 49529render_fn2 = function() { 49530 var _a3; 49531 if (__privateGet24(this, _prevState2) === JSON.stringify(this.mediaSubtitlesList)) 49532 return; 49533 __privateSet23(this, _prevState2, JSON.stringify(this.mediaSubtitlesList)); 49534 this.defaultSlot.textContent = ""; 49535 const isOff = !this.value; 49536 const item = createMenuItem({ 49537 type: "radio", 49538 text: this.formatMenuItemText("Off"), 49539 value: "off", 49540 checked: isOff 49541 }); 49542 item.prepend(createIndicator(this, "checked-indicator")); 49543 this.defaultSlot.append(item); 49544 const subtitlesList = this.mediaSubtitlesList; 49545 for (const subs of subtitlesList) { 49546 const item2 = createMenuItem({ 49547 type: "radio", 49548 text: this.formatMenuItemText(subs.label, subs), 49549 value: formatTextTrackObj(subs), 49550 checked: this.value == formatTextTrackObj(subs) 49551 }); 49552 item2.prepend(createIndicator(this, "checked-indicator")); 49553 const type = (_a3 = subs.kind) != null ? _a3 : "subs"; 49554 if (type === "captions") { 49555 item2.append(createIndicator(this, "captions-indicator")); 49556 } 49557 this.defaultSlot.append(item2); 49558 } 49559}; 49560_onChange2 = /* @__PURE__ */ new WeakSet(); 49561onChange_fn2 = function() { 49562 const showingSubs = this.mediaSubtitlesShowing; 49563 const showingSubsStr = this.getAttribute( 49564 MediaUIAttributes.MEDIA_SUBTITLES_SHOWING 49565 ); 49566 const localStateChange = this.value !== showingSubsStr; 49567 if ((showingSubs == null ? void 0 : showingSubs.length) && localStateChange) { 49568 this.dispatchEvent( 49569 new GlobalThis.CustomEvent( 49570 MediaUIEvents.MEDIA_DISABLE_SUBTITLES_REQUEST, 49571 { 49572 composed: true, 49573 bubbles: true, 49574 detail: showingSubs 49575 } 49576 ) 49577 ); 49578 } 49579 if (!this.value || !localStateChange) 49580 return; 49581 const event = new GlobalThis.CustomEvent( 49582 MediaUIEvents.MEDIA_SHOW_SUBTITLES_REQUEST, 49583 { 49584 composed: true, 49585 bubbles: true, 49586 detail: this.value 49587 } 49588 ); 49589 this.dispatchEvent(event); 49590}; 49591MediaCaptionsMenu.template = template17; 49592var getSubtitlesListAttr2 = (el, attrName) => { 49593 const attrVal = el.getAttribute(attrName); 49594 return attrVal ? parseTextTracksStr(attrVal) : []; 49595}; 49596var setSubtitlesListAttr2 = (el, attrName, list) => { 49597 if (!(list == null ? void 0 : list.length)) { 49598 el.removeAttribute(attrName); 49599 return; 49600 } 49601 const newValStr = stringifyTextTrackList(list); 49602 const oldVal = el.getAttribute(attrName); 49603 if (oldVal === newValStr) 49604 return; 49605 el.setAttribute(attrName, newValStr); 49606}; 49607if (!GlobalThis.customElements.get("media-captions-menu")) { 49608 GlobalThis.customElements.define("media-captions-menu", MediaCaptionsMenu); 49609} 49610
vendor: 6,400 bytes, lines 49611-49740
49611// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/menu/media-captions-menu-button.js 49612var __accessCheck25 = (obj, member, msg) => { 49613 if (!member.has(obj)) 49614 throw TypeError("Cannot " + msg); 49615}; 49616var __privateAdd25 = (obj, member, value) => { 49617 if (member.has(obj)) 49618 throw TypeError("Cannot add the same private member more than once"); 49619 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 49620}; 49621var __privateSet24 = (obj, member, value, setter) => { 49622 __accessCheck25(obj, member, "write to private field"); 49623 setter ? setter.call(obj, value) : member.set(obj, value); 49624 return value; 49625}; 49626var _captionsReady; 49627var ccIconOn2 = `<svg aria-hidden="true" viewBox="0 0 26 24"> 49628 <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/> 49629</svg>`; 49630var ccIconOff2 = `<svg aria-hidden="true" viewBox="0 0 26 24"> 49631 <path d="M17.73 14.09a1.4 1.4 0 0 1-1 .37 1.579 1.579 0 0 1-1.27-.58A3 3 0 0 1 15 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34A2.89 2.89 0 0 0 19 9.07a3 3 0 0 0-2.14-.78 3.14 3.14 0 0 0-2.42 1 3.91 3.91 0 0 0-.93 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.17 3.17 0 0 0 1.07-1.74l-1.4-.45c-.083.43-.3.822-.62 1.12Zm-7.22 0a1.43 1.43 0 0 1-1 .37 1.58 1.58 0 0 1-1.27-.58A3 3 0 0 1 7.76 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34a2.81 2.81 0 0 0-.74-1.32 2.94 2.94 0 0 0-2.13-.78 3.18 3.18 0 0 0-2.43 1 4 4 0 0 0-.92 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.23 3.23 0 0 0 1.07-1.74l-1.4-.45a2.06 2.06 0 0 1-.6 1.07Zm12.32-8.41a2.59 2.59 0 0 0-2.3-2.51C18.72 3.05 15.86 3 13 3c-2.86 0-5.72.05-7.53.17a2.59 2.59 0 0 0-2.3 2.51c-.23 4.207-.23 8.423 0 12.63a2.57 2.57 0 0 0 2.3 2.5c1.81.13 4.67.19 7.53.19 2.86 0 5.72-.06 7.53-.19a2.57 2.57 0 0 0 2.3-2.5c.23-4.207.23-8.423 0-12.63Zm-1.49 12.53a1.11 1.11 0 0 1-.91 1.11c-1.67.11-4.45.18-7.43.18-2.98 0-5.76-.07-7.43-.18a1.11 1.11 0 0 1-.91-1.11c-.21-4.14-.21-8.29 0-12.43a1.11 1.11 0 0 1 .91-1.11C7.24 4.56 10 4.49 13 4.49s5.76.07 7.43.18a1.11 1.11 0 0 1 .91 1.11c.21 4.14.21 8.29 0 12.43Z"/> 49632</svg>`; 49633var slotTemplate14 = Document2.createElement("template"); 49634slotTemplate14.innerHTML = /*html*/ 49635` 49636 <style> 49637 :host([aria-checked="true"]) slot[name=off] { 49638 display: none !important; 49639 } 49640 49641 ${/* Double negative, but safer if display doesn't equal 'block' */ 49642""} 49643 :host(:not([aria-checked="true"])) slot[name=on] { 49644 display: none !important; 49645 } 49646 49647 :host([aria-expanded="true"]) slot[name=tooltip] { 49648 display: none; 49649 } 49650 </style> 49651 49652 <slot name="icon"> 49653 <slot name="on">${ccIconOn2}</slot> 49654 <slot name="off">${ccIconOff2}</slot> 49655 </slot> 49656`; 49657var updateAriaChecked2 = (el) => { 49658 el.setAttribute("aria-checked", areSubsOn(el).toString()); 49659}; 49660var MediaCaptionsMenuButton = class extends MediaChromeMenuButton { 49661 constructor(options2 = {}) { 49662 super({ slotTemplate: slotTemplate14, tooltipContent: tooltipLabels.CAPTIONS, ...options2 }); 49663 __privateAdd25(this, _captionsReady, void 0); 49664 __privateSet24(this, _captionsReady, false); 49665 } 49666 static get observedAttributes() { 49667 return [ 49668 ...super.observedAttributes, 49669 MediaUIAttributes.MEDIA_SUBTITLES_LIST, 49670 MediaUIAttributes.MEDIA_SUBTITLES_SHOWING 49671 ]; 49672 } 49673 connectedCallback() { 49674 super.connectedCallback(); 49675 this.setAttribute("aria-label", nouns.CLOSED_CAPTIONS()); 49676 updateAriaChecked2(this); 49677 } 49678 attributeChangedCallback(attrName, oldValue, newValue) { 49679 super.attributeChangedCallback(attrName, oldValue, newValue); 49680 if (attrName === MediaUIAttributes.MEDIA_SUBTITLES_SHOWING) { 49681 updateAriaChecked2(this); 49682 } 49683 } 49684 /** 49685 * Returns the element with the id specified by the `invoketarget` attribute. 49686 * @return {HTMLElement | null} 49687 */ 49688 get invokeTargetElement() { 49689 var _a3; 49690 if (this.invokeTarget != void 0) 49691 return super.invokeTargetElement; 49692 return (_a3 = getMediaController(this)) == null ? void 0 : _a3.querySelector("media-captions-menu"); 49693 } 49694 /** 49695 * An array of TextTrack-like objects. 49696 * Objects must have the properties: kind, language, and label. 49697 */ 49698 get mediaSubtitlesList() { 49699 return getSubtitlesListAttr3(this, MediaUIAttributes.MEDIA_SUBTITLES_LIST); 49700 } 49701 set mediaSubtitlesList(list) { 49702 setSubtitlesListAttr3(this, MediaUIAttributes.MEDIA_SUBTITLES_LIST, list); 49703 } 49704 /** 49705 * An array of TextTrack-like objects. 49706 * Objects must have the properties: kind, language, and label. 49707 */ 49708 get mediaSubtitlesShowing() { 49709 return getSubtitlesListAttr3( 49710 this, 49711 MediaUIAttributes.MEDIA_SUBTITLES_SHOWING 49712 ); 49713 } 49714 set mediaSubtitlesShowing(list) { 49715 setSubtitlesListAttr3(this, MediaUIAttributes.MEDIA_SUBTITLES_SHOWING, list); 49716 } 49717}; 49718_captionsReady = /* @__PURE__ */ new WeakMap(); 49719var getSubtitlesListAttr3 = (el, attrName) => { 49720 const attrVal = el.getAttribute(attrName); 49721 return attrVal ? parseTextTracksStr(attrVal) : []; 49722}; 49723var setSubtitlesListAttr3 = (el, attrName, list) => { 49724 if (!(list == null ? void 0 : list.length)) { 49725 el.removeAttribute(attrName); 49726 return; 49727 } 49728 const newValStr = stringifyTextTrackList(list); 49729 const oldVal = el.getAttribute(attrName); 49730 if (oldVal === newValStr) 49731 return; 49732 el.setAttribute(attrName, newValStr); 49733}; 49734if (!GlobalThis.customElements.get("media-captions-menu-button")) { 49735 GlobalThis.customElements.define( 49736 "media-captions-menu-button", 49737 MediaCaptionsMenuButton 49738 ); 49739} 49740
vendor: 4,042 bytes, lines 49741-49875
49741// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/menu/media-playback-rate-menu.js 49742var __accessCheck26 = (obj, member, msg) => { 49743 if (!member.has(obj)) 49744 throw TypeError("Cannot " + msg); 49745}; 49746var __privateGet25 = (obj, member, getter) => { 49747 __accessCheck26(obj, member, "read from private field"); 49748 return getter ? getter.call(obj) : member.get(obj); 49749}; 49750var __privateAdd26 = (obj, member, value) => { 49751 if (member.has(obj)) 49752 throw TypeError("Cannot add the same private member more than once"); 49753 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 49754}; 49755var __privateMethod12 = (obj, member, method) => { 49756 __accessCheck26(obj, member, "access private method"); 49757 return method; 49758}; 49759var _rates2; 49760var _render3; 49761var render_fn3; 49762var _onChange3; 49763var onChange_fn3; 49764var Attributes14 = { 49765 RATES: "rates" 49766}; 49767var MediaPlaybackRateMenu = class extends MediaChromeMenu { 49768 constructor() { 49769 super(); 49770 __privateAdd26(this, _render3); 49771 __privateAdd26(this, _onChange3); 49772 __privateAdd26(this, _rates2, new AttributeTokenList(this, Attributes14.RATES, { 49773 defaultValue: DEFAULT_RATES 49774 })); 49775 __privateMethod12(this, _render3, render_fn3).call(this); 49776 } 49777 static get observedAttributes() { 49778 return [ 49779 ...super.observedAttributes, 49780 MediaUIAttributes.MEDIA_PLAYBACK_RATE, 49781 Attributes14.RATES 49782 ]; 49783 } 49784 attributeChangedCallback(attrName, oldValue, newValue) { 49785 super.attributeChangedCallback(attrName, oldValue, newValue); 49786 if (attrName === MediaUIAttributes.MEDIA_PLAYBACK_RATE && oldValue != newValue) { 49787 this.value = newValue; 49788 } else if (attrName === Attributes14.RATES && oldValue != newValue) { 49789 __privateGet25(this, _rates2).value = newValue; 49790 __privateMethod12(this, _render3, render_fn3).call(this); 49791 } 49792 } 49793 connectedCallback() { 49794 super.connectedCallback(); 49795 this.addEventListener("change", __privateMethod12(this, _onChange3, onChange_fn3)); 49796 } 49797 disconnectedCallback() { 49798 super.disconnectedCallback(); 49799 this.removeEventListener("change", __privateMethod12(this, _onChange3, onChange_fn3)); 49800 } 49801 /** 49802 * Returns the anchor element when it is a floating menu. 49803 */ 49804 get anchorElement() { 49805 if (this.anchor !== "auto") 49806 return super.anchorElement; 49807 return getMediaController(this).querySelector( 49808 "media-playback-rate-menu-button" 49809 ); 49810 } 49811 /** 49812 * Will return a DOMTokenList. 49813 * Setting a value will accept an array of numbers. 49814 */ 49815 get rates() { 49816 return __privateGet25(this, _rates2); 49817 } 49818 set rates(value) { 49819 if (!value) { 49820 __privateGet25(this, _rates2).value = ""; 49821 } else if (Array.isArray(value)) { 49822 __privateGet25(this, _rates2).value = value.join(" "); 49823 } 49824 __privateMethod12(this, _render3, render_fn3).call(this); 49825 } 49826 /** 49827 * The current playback rate 49828 */ 49829 get mediaPlaybackRate() { 49830 return getNumericAttr( 49831 this, 49832 MediaUIAttributes.MEDIA_PLAYBACK_RATE, 49833 DEFAULT_RATE 49834 ); 49835 } 49836 set mediaPlaybackRate(value) { 49837 setNumericAttr(this, MediaUIAttributes.MEDIA_PLAYBACK_RATE, value); 49838 } 49839}; 49840_rates2 = /* @__PURE__ */ new WeakMap(); 49841_render3 = /* @__PURE__ */ new WeakSet(); 49842render_fn3 = function() { 49843 this.defaultSlot.textContent = ""; 49844 for (const rate of this.rates) { 49845 const item = createMenuItem({ 49846 type: "radio", 49847 text: this.formatMenuItemText(`${rate}x`, rate), 49848 value: rate, 49849 checked: this.mediaPlaybackRate == rate 49850 }); 49851 item.prepend(createIndicator(this, "checked-indicator")); 49852 this.defaultSlot.append(item); 49853 } 49854}; 49855_onChange3 = /* @__PURE__ */ new WeakSet(); 49856onChange_fn3 = function() { 49857 if (!this.value) 49858 return; 49859 const event = new GlobalThis.CustomEvent( 49860 MediaUIEvents.MEDIA_PLAYBACK_RATE_REQUEST, 49861 { 49862 composed: true, 49863 bubbles: true, 49864 detail: this.value 49865 } 49866 ); 49867 this.dispatchEvent(event); 49868}; 49869if (!GlobalThis.customElements.get("media-playback-rate-menu")) { 49870 GlobalThis.customElements.define( 49871 "media-playback-rate-menu", 49872 MediaPlaybackRateMenu 49873 ); 49874} 49875
vendor: 3,493 bytes, lines 49876-49986
49876// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/menu/media-playback-rate-menu-button.js 49877var __accessCheck27 = (obj, member, msg) => { 49878 if (!member.has(obj)) 49879 throw TypeError("Cannot " + msg); 49880}; 49881var __privateGet26 = (obj, member, getter) => { 49882 __accessCheck27(obj, member, "read from private field"); 49883 return getter ? getter.call(obj) : member.get(obj); 49884}; 49885var __privateAdd27 = (obj, member, value) => { 49886 if (member.has(obj)) 49887 throw TypeError("Cannot add the same private member more than once"); 49888 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 49889}; 49890var _rates3; 49891var Attributes15 = { 49892 RATES: "rates" 49893}; 49894var DEFAULT_RATES2 = [1, 1.2, 1.5, 1.7, 2]; 49895var DEFAULT_RATE2 = 1; 49896var slotTemplate15 = Document2.createElement("template"); 49897slotTemplate15.innerHTML = /*html*/ 49898` 49899 <style> 49900 :host { 49901 min-width: 5ch; 49902 padding: var(--media-button-padding, var(--media-control-padding, 10px 5px)); 49903 } 49904 49905 :host([aria-expanded="true"]) slot[name=tooltip] { 49906 display: none; 49907 } 49908 </style> 49909 <slot name="icon"></slot> 49910`; 49911var MediaPlaybackRateMenuButton = class extends MediaChromeMenuButton { 49912 constructor(options2 = {}) { 49913 super({ 49914 slotTemplate: slotTemplate15, 49915 tooltipContent: tooltipLabels.PLAYBACK_RATE, 49916 ...options2 49917 }); 49918 __privateAdd27(this, _rates3, new AttributeTokenList(this, Attributes15.RATES, { 49919 defaultValue: DEFAULT_RATES2 49920 })); 49921 this.container = this.shadowRoot.querySelector('slot[name="icon"]'); 49922 this.container.innerHTML = `${DEFAULT_RATE2}x`; 49923 } 49924 static get observedAttributes() { 49925 return [ 49926 ...super.observedAttributes, 49927 MediaUIAttributes.MEDIA_PLAYBACK_RATE, 49928 Attributes15.RATES 49929 ]; 49930 } 49931 attributeChangedCallback(attrName, oldValue, newValue) { 49932 super.attributeChangedCallback(attrName, oldValue, newValue); 49933 if (attrName === Attributes15.RATES) { 49934 __privateGet26(this, _rates3).value = newValue; 49935 } 49936 if (attrName === MediaUIAttributes.MEDIA_PLAYBACK_RATE) { 49937 const newPlaybackRate = newValue ? +newValue : Number.NaN; 49938 const playbackRate = !Number.isNaN(newPlaybackRate) ? newPlaybackRate : DEFAULT_RATE2; 49939 this.container.innerHTML = `${playbackRate}x`; 49940 this.setAttribute("aria-label", nouns.PLAYBACK_RATE({ playbackRate })); 49941 } 49942 } 49943 /** 49944 * Returns the element with the id specified by the `invoketarget` attribute. 49945 */ 49946 get invokeTargetElement() { 49947 if (this.invokeTarget != void 0) 49948 return super.invokeTargetElement; 49949 return getMediaController(this).querySelector("media-playback-rate-menu"); 49950 } 49951 /** 49952 * Will return a DOMTokenList. 49953 * Setting a value will accept an array of numbers. 49954 */ 49955 get rates() { 49956 return __privateGet26(this, _rates3); 49957 } 49958 set rates(value) { 49959 if (!value) { 49960 __privateGet26(this, _rates3).value = ""; 49961 } else if (Array.isArray(value)) { 49962 __privateGet26(this, _rates3).value = value.join(" "); 49963 } 49964 } 49965 /** 49966 * The current playback rate 49967 */ 49968 get mediaPlaybackRate() { 49969 return getNumericAttr( 49970 this, 49971 MediaUIAttributes.MEDIA_PLAYBACK_RATE, 49972 DEFAULT_RATE2 49973 ); 49974 } 49975 set mediaPlaybackRate(value) { 49976 setNumericAttr(this, MediaUIAttributes.MEDIA_PLAYBACK_RATE, value); 49977 } 49978}; 49979_rates3 = /* @__PURE__ */ new WeakMap(); 49980if (!GlobalThis.customElements.get("media-playback-rate-menu-button")) { 49981 GlobalThis.customElements.define( 49982 "media-playback-rate-menu-button", 49983 MediaPlaybackRateMenuButton 49984 ); 49985} 49986
vendor: 5,548 bytes, lines 49987-50143
49987// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/menu/media-rendition-menu.js 49988var __accessCheck28 = (obj, member, msg) => { 49989 if (!member.has(obj)) 49990 throw TypeError("Cannot " + msg); 49991}; 49992var __privateGet27 = (obj, member, getter) => { 49993 __accessCheck28(obj, member, "read from private field"); 49994 return getter ? getter.call(obj) : member.get(obj); 49995}; 49996var __privateAdd28 = (obj, member, value) => { 49997 if (member.has(obj)) 49998 throw TypeError("Cannot add the same private member more than once"); 49999 member instanceof WeakSet ? member.add(obj) : member.set(obj, value); 50000}; 50001var __privateSet25 = (obj, member, value, setter) => { 50002 __accessCheck28(obj, member, "write to private field"); 50003 setter ? setter.call(obj, value) : member.set(obj, value); 50004 return value; 50005}; 50006var __privateMethod13 = (obj, member, method) => { 50007 __accessCheck28(obj, member, "access private method"); 50008 return method; 50009}; 50010var _renditionList; 50011var _prevState3; 50012var _render4; 50013var render_fn4; 50014var _onChange4; 50015var onChange_fn4; 50016var MediaRenditionMenu = class extends MediaChromeMenu { 50017 constructor() { 50018 super(...arguments); 50019 __privateAdd28(this, _render4); 50020 __privateAdd28(this, _onChange4); 50021 __privateAdd28(this, _renditionList, []); 50022 __privateAdd28(this, _prevState3, {}); 50023 } 50024 static get observedAttributes() { 50025 return [ 50026 ...super.observedAttributes, 50027 MediaUIAttributes.MEDIA_RENDITION_LIST, 50028 MediaUIAttributes.MEDIA_RENDITION_SELECTED, 50029 MediaUIAttributes.MEDIA_RENDITION_UNAVAILABLE, 50030 MediaUIAttributes.MEDIA_HEIGHT 50031 ]; 50032 } 50033 attributeChangedCallback(attrName, oldValue, newValue) { 50034 super.attributeChangedCallback(attrName, oldValue, newValue); 50035 if (attrName === MediaUIAttributes.MEDIA_RENDITION_SELECTED && oldValue !== newValue) { 50036 this.value = newValue != null ? newValue : "auto"; 50037 } else if (attrName === MediaUIAttributes.MEDIA_RENDITION_LIST && oldValue !== newValue) { 50038 __privateSet25(this, _renditionList, parseRenditionList(newValue)); 50039 __privateMethod13(this, _render4, render_fn4).call(this); 50040 } else if (attrName === MediaUIAttributes.MEDIA_HEIGHT && oldValue !== newValue) { 50041 __privateMethod13(this, _render4, render_fn4).call(this); 50042 } 50043 } 50044 connectedCallback() { 50045 super.connectedCallback(); 50046 this.addEventListener("change", __privateMethod13(this, _onChange4, onChange_fn4)); 50047 } 50048 disconnectedCallback() { 50049 super.disconnectedCallback(); 50050 this.removeEventListener("change", __privateMethod13(this, _onChange4, onChange_fn4)); 50051 } 50052 /** 50053 * Returns the anchor element when it is a floating menu. 50054 */ 50055 get anchorElement() { 50056 if (this.anchor !== "auto") 50057 return super.anchorElement; 50058 return getMediaController(this).querySelector( 50059 "media-rendition-menu-button" 50060 ); 50061 } 50062 get mediaRenditionList() { 50063 return __privateGet27(this, _renditionList); 50064 } 50065 set mediaRenditionList(list) { 50066 __privateSet25(this, _renditionList, list); 50067 __privateMethod13(this, _render4, render_fn4).call(this); 50068 } 50069 /** 50070 * Get selected rendition id. 50071 */ 50072 get mediaRenditionSelected() { 50073 return getStringAttr(this, MediaUIAttributes.MEDIA_RENDITION_SELECTED); 50074 } 50075 set mediaRenditionSelected(id) { 50076 setStringAttr(this, MediaUIAttributes.MEDIA_RENDITION_SELECTED, id); 50077 } 50078 get mediaHeight() { 50079 return getNumericAttr(this, MediaUIAttributes.MEDIA_HEIGHT); 50080 } 50081 set mediaHeight(height) { 50082 setNumericAttr(this, MediaUIAttributes.MEDIA_HEIGHT, height); 50083 } 50084}; 50085_renditionList = /* @__PURE__ */ new WeakMap(); 50086_prevState3 = /* @__PURE__ */ new WeakMap(); 50087_render4 = /* @__PURE__ */ new WeakSet(); 50088render_fn4 = function() { 50089 if (__privateGet27(this, _prevState3).mediaRenditionList === JSON.stringify(this.mediaRenditionList) && __privateGet27(this, _prevState3).mediaHeight === this.mediaHeight) 50090 return; 50091 __privateGet27(this, _prevState3).mediaRenditionList = JSON.stringify(this.mediaRenditionList); 50092 __privateGet27(this, _prevState3).mediaHeight = this.mediaHeight; 50093 const renditionList = this.mediaRenditionList.sort( 50094 (a2, b3) => b3.height - a2.height 50095 ); 50096 for (const rendition of renditionList) { 50097 rendition.selected = rendition.id === this.mediaRenditionSelected; 50098 } 50099 this.defaultSlot.textContent = ""; 50100 const isAuto = !this.mediaRenditionSelected; 50101 for (const rendition of renditionList) { 50102 const text = this.formatMenuItemText( 50103 `${Math.min(rendition.width, rendition.height)}p`, 50104 rendition 50105 ); 50106 const item2 = createMenuItem({ 50107 type: "radio", 50108 text, 50109 value: `${rendition.id}`, 50110 checked: rendition.selected && !isAuto 50111 }); 50112 item2.prepend(createIndicator(this, "checked-indicator")); 50113 this.defaultSlot.append(item2); 50114 } 50115 const item = createMenuItem({ 50116 type: "radio", 50117 text: this.formatMenuItemText("Auto"), 50118 value: "auto", 50119 checked: isAuto 50120 }); 50121 const autoDescription = this.mediaHeight > 0 ? `Auto (${this.mediaHeight}p)` : "Auto"; 50122 item.dataset.description = autoDescription; 50123 item.prepend(createIndicator(this, "checked-indicator")); 50124 this.defaultSlot.append(item); 50125}; 50126_onChange4 = /* @__PURE__ */ new WeakSet(); 50127onChange_fn4 = function() { 50128 if (this.value == null) 50129 return; 50130 const event = new GlobalThis.CustomEvent( 50131 MediaUIEvents.MEDIA_RENDITION_REQUEST, 50132 { 50133 composed: true, 50134 bubbles: true, 50135 detail: this.value 50136 } 50137 ); 50138 this.dispatchEvent(event); 50139}; 50140if (!GlobalThis.customElements.get("media-rendition-menu")) { 50141 GlobalThis.customElements.define("media-rendition-menu", MediaRenditionMenu); 50142} 50143
vendor: 2,038 bytes, lines 50144-50207
50144// node_modules/.pnpm/[email protected]/node_modules/media-chrome/dist/menu/media-rendition-menu-button.js 50145var renditionIcon = ( 50146 /*html*/ 50147 `<svg aria-hidden="true" viewBox="0 0 24 24"> 50148 <path d="M13.5 2.5h2v6h-2v-2h-11v-2h11v-2Zm4 2h4v2h-4v-2Zm-12 4h2v6h-2v-2h-3v-2h3v-2Zm4 2h12v2h-12v-2Zm1 4h2v6h-2v-2h-8v-2h8v-2Zm4 2h7v2h-7v-2Z" /> 50149</svg>` 50150); 50151var slotTemplate16 = Document2.createElement("template"); 50152slotTemplate16.innerHTML = /*html*/ 50153` 50154 <style> 50155 :host([aria-expanded="true"]) slot[name=tooltip] { 50156 display: none; 50157 } 50158 </style> 50159 <slot name="icon">${renditionIcon}</slot> 50160`; 50161var MediaRenditionMenuButton = class extends MediaChromeMenuButton { 50162 static get observedAttributes() { 50163 return [ 50164 ...super.observedAttributes, 50165 MediaUIAttributes.MEDIA_RENDITION_SELECTED, 50166 MediaUIAttributes.MEDIA_RENDITION_UNAVAILABLE, 50167 MediaUIAttributes.MEDIA_HEIGHT 50168 ]; 50169 } 50170 constructor() { 50171 super({ slotTemplate: slotTemplate16, tooltipContent: tooltipLabels.RENDITIONS }); 50172 } 50173 connectedCallback() { 50174 super.connectedCallback(); 50175 this.setAttribute("aria-label", nouns.QUALITY()); 50176 } 50177 /** 50178 * Returns the element with the id specified by the `invoketarget` attribute. 50179 */ 50180 get invokeTargetElement() { 50181 if (this.invokeTarget != void 0) 50182 return super.invokeTargetElement; 50183 return getMediaController(this).querySelector("media-rendition-menu"); 50184 } 50185 /** 50186 * Get selected rendition id. 50187 */ 50188 get mediaRenditionSelected() { 50189 return getStringAttr(this, MediaUIAttributes.MEDIA_RENDITION_SELECTED); 50190 } 50191 set mediaRenditionSelected(id) { 50192 setStringAttr(this, MediaUIAttributes.MEDIA_RENDITION_SELECTED, id); 50193 } 50194 get mediaHeight() { 50195 return getNumericAttr(this, MediaUIAttributes.MEDIA_HEIGHT); 50196 } 50197 set mediaHeight(height) { 50198 setNumericAttr(this, MediaUIAttributes.MEDIA_HEIGHT, height); 50199 } 50200}; 50201if (!GlobalThis.customElements.get("media-rendition-menu-button")) { 50202 GlobalThis.customElements.define( 50203 "media-rendition-menu-button", 50204 MediaRenditionMenuButton 50205 ); 50206} 50207
vendor: 113,201 bytes, lines 50208-52920
50208// node_modules/.pnpm/@[email protected]/node_modules/@mux/mux-player/dist/index.mjs 50209var ke4 = (t2, a2, e) => { 50210 if (!a2.has(t2)) throw TypeError("Cannot " + e); 50211}; 50212var u2 = (t2, a2, e) => (ke4(t2, a2, "read from private field"), e ? e.call(t2) : a2.get(t2)); 50213var b2 = (t2, a2, e) => { 50214 if (a2.has(t2)) throw TypeError("Cannot add the same private member more than once"); 50215 a2 instanceof WeakSet ? a2.add(t2) : a2.set(t2, e); 50216}; 50217var R4 = (t2, a2, e, i3) => (ke4(t2, a2, "write to private field"), i3 ? i3.call(t2, e) : a2.set(t2, e), e); 50218var h2 = (t2, a2, e) => (ke4(t2, a2, "access private method"), e); 50219var W3 = class { 50220 addEventListener() { 50221 } 50222 removeEventListener() { 50223 } 50224 dispatchEvent(a2) { 50225 return true; 50226 } 50227}; 50228if (typeof DocumentFragment == "undefined") { 50229 class t2 extends W3 { 50230 } 50231 globalThis.DocumentFragment = t2; 50232} 50233var X4 = class extends W3 { 50234}; 50235var Re3 = class extends W3 { 50236}; 50237var Gt3 = { get(t2) { 50238}, define(t2, a2, e) { 50239}, getName(t2) { 50240 return null; 50241}, upgrade(t2) { 50242}, whenDefined(t2) { 50243 return Promise.resolve(X4); 50244} }; 50245var J4; 50246var Oe4 = class { 50247 constructor(a2, e = {}) { 50248 b2(this, J4, void 0); 50249 R4(this, J4, e == null ? void 0 : e.detail); 50250 } 50251 get detail() { 50252 return u2(this, J4); 50253 } 50254 initCustomEvent() { 50255 } 50256}; 50257J4 = /* @__PURE__ */ new WeakMap(); 50258function jt3(t2, a2) { 50259 return new X4(); 50260} 50261var lt4 = { document: { createElement: jt3 }, DocumentFragment, customElements: Gt3, CustomEvent: Oe4, EventTarget: W3, HTMLElement: X4, HTMLVideoElement: Re3 }; 50262var ut4 = typeof window == "undefined" || typeof globalThis.customElements == "undefined"; 50263var p = ut4 ? lt4 : globalThis; 50264var C3 = ut4 ? lt4.document : globalThis.document; 50265function mt3(t2) { 50266 let a2 = ""; 50267 return Object.entries(t2).forEach(([e, i3]) => { 50268 i3 != null && (a2 += `${le4(e)}: ${i3}; `); 50269 }), a2 ? a2.trim() : void 0; 50270} 50271function le4(t2) { 50272 return t2.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(); 50273} 50274function ue3(t2) { 50275 return t2.replace(/[-_]([a-z])/g, (a2, e) => e.toUpperCase()); 50276} 50277function T2(t2) { 50278 if (t2 == null) return; 50279 let a2 = +t2; 50280 return Number.isNaN(a2) ? void 0 : a2; 50281} 50282function xe2(t2) { 50283 let a2 = qt3(t2).toString(); 50284 return a2 ? "?" + a2 : ""; 50285} 50286function qt3(t2) { 50287 let a2 = {}; 50288 for (let e in t2) t2[e] != null && (a2[e] = t2[e]); 50289 return new URLSearchParams(a2); 50290} 50291var _e4 = (t2, a2) => !t2 || !a2 ? false : t2.contains(a2) ? true : _e4(t2, a2.getRootNode().host); 50292var pt3 = "mux.com"; 50293var zt3 = () => { 50294 try { 50295 return "3.1.0"; 50296 } catch { 50297 } 50298 return "UNKNOWN"; 50299}; 50300var Xt3 = zt3(); 50301var ce3 = () => Xt3; 50302var bt4 = (t2, { token: a2, customDomain: e = pt3, thumbnailTime: i3, programTime: r10 } = {}) => { 50303 var l2; 50304 let o2 = a2 == null ? i3 : void 0, { aud: d2 } = (l2 = Q2(a2)) != null ? l2 : {}; 50305 if (!(a2 && d2 !== "t")) return `https://image.${e}/${t2}/thumbnail.webp${xe2({ token: a2, time: o2, program_time: r10 })}`; 50306}; 50307var ht3 = (t2, { token: a2, customDomain: e = pt3, programStartTime: i3, programEndTime: r10 } = {}) => { 50308 var d2; 50309 let { aud: o2 } = (d2 = Q2(a2)) != null ? d2 : {}; 50310 if (!(a2 && o2 !== "s")) return `https://image.${e}/${t2}/storyboard.vtt${xe2({ token: a2, format: "webp", program_start_time: i3, program_end_time: r10 })}`; 50311}; 50312var Q4 = (t2) => { 50313 if (t2) { 50314 if ([D2.LIVE, D2.ON_DEMAND].includes(t2)) return t2; 50315 if (t2 != null && t2.includes("live")) return D2.LIVE; 50316 } 50317}; 50318var Jt3 = { crossorigin: "crossOrigin", playsinline: "playsInline" }; 50319function gt3(t2) { 50320 var a2; 50321 return (a2 = Jt3[t2]) != null ? a2 : ue3(t2); 50322} 50323var H4; 50324var K3; 50325var v; 50326var me3 = class { 50327 constructor(a2, e) { 50328 b2(this, H4, void 0); 50329 b2(this, K3, void 0); 50330 b2(this, v, []); 50331 R4(this, H4, a2), R4(this, K3, e); 50332 } 50333 [Symbol.iterator]() { 50334 return u2(this, v).values(); 50335 } 50336 get length() { 50337 return u2(this, v).length; 50338 } 50339 get value() { 50340 var a2; 50341 return (a2 = u2(this, v).join(" ")) != null ? a2 : ""; 50342 } 50343 set value(a2) { 50344 var e; 50345 a2 !== this.value && (R4(this, v, []), this.add(...(e = a2 == null ? void 0 : a2.split(" ")) != null ? e : [])); 50346 } 50347 toString() { 50348 return this.value; 50349 } 50350 item(a2) { 50351 return u2(this, v)[a2]; 50352 } 50353 values() { 50354 return u2(this, v).values(); 50355 } 50356 keys() { 50357 return u2(this, v).keys(); 50358 } 50359 forEach(a2) { 50360 u2(this, v).forEach(a2); 50361 } 50362 add(...a2) { 50363 var e, i3; 50364 a2.forEach((r10) => { 50365 this.contains(r10) || u2(this, v).push(r10); 50366 }), !(this.value === "" && !((e = u2(this, H4)) != null && e.hasAttribute(`${u2(this, K3)}`))) && ((i3 = u2(this, H4)) == null || i3.setAttribute(`${u2(this, K3)}`, `${this.value}`)); 50367 } 50368 remove(...a2) { 50369 var e; 50370 a2.forEach((i3) => { 50371 u2(this, v).splice(u2(this, v).indexOf(i3), 1); 50372 }), (e = u2(this, H4)) == null || e.setAttribute(`${u2(this, K3)}`, `${this.value}`); 50373 } 50374 contains(a2) { 50375 return u2(this, v).includes(a2); 50376 } 50377 toggle(a2, e) { 50378 return typeof e != "undefined" ? e ? (this.add(a2), true) : (this.remove(a2), false) : this.contains(a2) ? (this.remove(a2), false) : (this.add(a2), true); 50379 } 50380 replace(a2, e) { 50381 this.remove(a2), this.add(e); 50382 } 50383}; 50384H4 = /* @__PURE__ */ new WeakMap(), K3 = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new WeakMap(); 50385var ft5 = `[mux-player ${ce3()}]`; 50386function _2(...t2) { 50387 console.warn(ft5, ...t2); 50388} 50389function E3(...t2) { 50390 console.error(ft5, ...t2); 50391} 50392function Me4(t2) { 50393 var e; 50394 let a2 = (e = t2.message) != null ? e : ""; 50395 t2.context && (a2 += ` ${t2.context}`), t2.file && (a2 += ` ${E("Read more: ")} 50396https://github.com/muxinc/elements/blob/main/errors/${t2.file}`), _2(a2); 50397} 50398var y2 = { AUTOPLAY: "autoplay", CROSSORIGIN: "crossorigin", LOOP: "loop", MUTED: "muted", PLAYSINLINE: "playsinline", PRELOAD: "preload" }; 50399var U4 = { VOLUME: "volume", PLAYBACKRATE: "playbackrate", MUTED: "muted" }; 50400var vt4 = Object.freeze({ length: 0, start(t2) { 50401 let a2 = t2 >>> 0; 50402 if (a2 >= this.length) throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${a2}) is greater than or equal to the maximum bound (${this.length}).`); 50403 return 0; 50404}, end(t2) { 50405 let a2 = t2 >>> 0; 50406 if (a2 >= this.length) throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${a2}) is greater than or equal to the maximum bound (${this.length}).`); 50407 return 0; 50408} }); 50409var ta2 = ve2.filter((t2) => t2 !== "error"); 50410var aa2 = Object.values(y2).filter((t2) => ![y2.PLAYSINLINE].includes(t2)); 50411var ia2 = Object.values(U4); 50412var Z3; 50413var Se4 = class extends p.HTMLElement { 50414 constructor() { 50415 super(); 50416 b2(this, Z3, /* @__PURE__ */ new WeakMap()); 50417 let e = (r10) => { 50418 for (let o2 of r10) o2.type === "childList" && (o2.removedNodes.forEach((d2) => { 50419 var l2; 50420 (l2 = u2(this, Z3).get(d2)) == null || l2.remove(); 50421 }), o2.addedNodes.forEach((d2) => { 50422 var c3; 50423 let l2 = d2; 50424 l2 != null && l2.slot || (c3 = this.media) == null || c3.append(Tt4(u2(this, Z3), d2)); 50425 })); 50426 }; 50427 new MutationObserver(e).observe(this, { childList: true, subtree: true }); 50428 } 50429 static get observedAttributes() { 50430 return [...aa2, ...ia2]; 50431 } 50432 init() { 50433 this.querySelectorAll(":scope > :not([slot])").forEach((e) => { 50434 var i3; 50435 (i3 = this.media) == null || i3.append(Tt4(u2(this, Z3), e)); 50436 }), ta2.forEach((e) => { 50437 var i3; 50438 (i3 = this.media) == null || i3.addEventListener(e, (r10) => { 50439 this.dispatchEvent(new Event(r10.type)); 50440 }); 50441 }); 50442 } 50443 attributeChangedCallback(e, i3, r10) { 50444 var o2, d2; 50445 switch (e) { 50446 case U4.MUTED: { 50447 this.media && (this.media.muted = r10 != null, this.media.defaultMuted = r10 != null); 50448 return; 50449 } 50450 case U4.VOLUME: { 50451 let l2 = (o2 = T2(r10)) != null ? o2 : 1; 50452 this.media && (this.media.volume = l2); 50453 return; 50454 } 50455 case U4.PLAYBACKRATE: { 50456 let l2 = (d2 = T2(r10)) != null ? d2 : 1; 50457 this.media && (this.media.playbackRate = l2, this.media.defaultPlaybackRate = l2); 50458 return; 50459 } 50460 } 50461 } 50462 play() { 50463 var e, i3; 50464 return (i3 = (e = this.media) == null ? void 0 : e.play()) != null ? i3 : Promise.reject(); 50465 } 50466 pause() { 50467 var e; 50468 (e = this.media) == null || e.pause(); 50469 } 50470 load() { 50471 var e; 50472 (e = this.media) == null || e.load(); 50473 } 50474 requestCast(e) { 50475 var i3; 50476 return (i3 = this.media) == null ? void 0 : i3.requestCast(e); 50477 } 50478 get media() { 50479 var e; 50480 return (e = this.shadowRoot) == null ? void 0 : e.querySelector("mux-video"); 50481 } 50482 get audioTracks() { 50483 return this.media.audioTracks; 50484 } 50485 get videoTracks() { 50486 return this.media.videoTracks; 50487 } 50488 get audioRenditions() { 50489 return this.media.audioRenditions; 50490 } 50491 get videoRenditions() { 50492 return this.media.videoRenditions; 50493 } 50494 get paused() { 50495 var e, i3; 50496 return (i3 = (e = this.media) == null ? void 0 : e.paused) != null ? i3 : true; 50497 } 50498 get duration() { 50499 var e, i3; 50500 return (i3 = (e = this.media) == null ? void 0 : e.duration) != null ? i3 : NaN; 50501 } 50502 get ended() { 50503 var e, i3; 50504 return (i3 = (e = this.media) == null ? void 0 : e.ended) != null ? i3 : false; 50505 } 50506 get buffered() { 50507 var e, i3; 50508 return (i3 = (e = this.media) == null ? void 0 : e.buffered) != null ? i3 : vt4; 50509 } 50510 get seekable() { 50511 var e, i3; 50512 return (i3 = (e = this.media) == null ? void 0 : e.seekable) != null ? i3 : vt4; 50513 } 50514 get readyState() { 50515 var e, i3; 50516 return (i3 = (e = this.media) == null ? void 0 : e.readyState) != null ? i3 : 0; 50517 } 50518 get videoWidth() { 50519 var e, i3; 50520 return (i3 = (e = this.media) == null ? void 0 : e.videoWidth) != null ? i3 : 0; 50521 } 50522 get videoHeight() { 50523 var e, i3; 50524 return (i3 = (e = this.media) == null ? void 0 : e.videoHeight) != null ? i3 : 0; 50525 } 50526 get currentSrc() { 50527 var e, i3; 50528 return (i3 = (e = this.media) == null ? void 0 : e.currentSrc) != null ? i3 : ""; 50529 } 50530 get currentTime() { 50531 var e, i3; 50532 return (i3 = (e = this.media) == null ? void 0 : e.currentTime) != null ? i3 : 0; 50533 } 50534 set currentTime(e) { 50535 this.media && (this.media.currentTime = Number(e)); 50536 } 50537 get volume() { 50538 var e, i3; 50539 return (i3 = (e = this.media) == null ? void 0 : e.volume) != null ? i3 : 1; 50540 } 50541 set volume(e) { 50542 this.media && (this.media.volume = Number(e)); 50543 } 50544 get playbackRate() { 50545 var e, i3; 50546 return (i3 = (e = this.media) == null ? void 0 : e.playbackRate) != null ? i3 : 1; 50547 } 50548 set playbackRate(e) { 50549 this.media && (this.media.playbackRate = Number(e)); 50550 } 50551 get defaultPlaybackRate() { 50552 var e; 50553 return (e = T2(this.getAttribute(U4.PLAYBACKRATE))) != null ? e : 1; 50554 } 50555 set defaultPlaybackRate(e) { 50556 e != null ? this.setAttribute(U4.PLAYBACKRATE, `${e}`) : this.removeAttribute(U4.PLAYBACKRATE); 50557 } 50558 get crossOrigin() { 50559 return ee4(this, y2.CROSSORIGIN); 50560 } 50561 set crossOrigin(e) { 50562 this.setAttribute(y2.CROSSORIGIN, `${e}`); 50563 } 50564 get autoplay() { 50565 return ee4(this, y2.AUTOPLAY) != null; 50566 } 50567 set autoplay(e) { 50568 e ? this.setAttribute(y2.AUTOPLAY, typeof e == "string" ? e : "") : this.removeAttribute(y2.AUTOPLAY); 50569 } 50570 get loop() { 50571 return ee4(this, y2.LOOP) != null; 50572 } 50573 set loop(e) { 50574 e ? this.setAttribute(y2.LOOP, "") : this.removeAttribute(y2.LOOP); 50575 } 50576 get muted() { 50577 var e, i3; 50578 return (i3 = (e = this.media) == null ? void 0 : e.muted) != null ? i3 : false; 50579 } 50580 set muted(e) { 50581 this.media && (this.media.muted = !!e); 50582 } 50583 get defaultMuted() { 50584 return ee4(this, y2.MUTED) != null; 50585 } 50586 set defaultMuted(e) { 50587 e ? this.setAttribute(y2.MUTED, "") : this.removeAttribute(y2.MUTED); 50588 } 50589 get playsInline() { 50590 return ee4(this, y2.PLAYSINLINE) != null; 50591 } 50592 set playsInline(e) { 50593 E3("playsInline is set to true by default and is not currently supported as a setter."); 50594 } 50595 get preload() { 50596 return this.media ? this.media.preload : this.getAttribute("preload"); 50597 } 50598 set preload(e) { 50599 ["", "none", "metadata", "auto"].includes(e) ? this.setAttribute(y2.PRELOAD, e) : this.removeAttribute(y2.PRELOAD); 50600 } 50601}; 50602Z3 = /* @__PURE__ */ new WeakMap(); 50603function ee4(t2, a2) { 50604 return t2.media ? t2.media.getAttribute(a2) : t2.getAttribute(a2); 50605} 50606function Tt4(t2, a2) { 50607 let e = t2.get(a2); 50608 return e || (e = a2.cloneNode(), t2.set(a2, e)), e; 50609} 50610var Ne2 = Se4; 50611var Et4 = `:host { 50612 --media-control-display: var(--controls); 50613 --media-loading-indicator-display: var(--loading-indicator); 50614 --media-dialog-display: var(--dialog); 50615 --media-play-button-display: var(--play-button); 50616 --media-live-button-display: var(--live-button); 50617 --media-seek-backward-button-display: var(--seek-backward-button); 50618 --media-seek-forward-button-display: var(--seek-forward-button); 50619 --media-mute-button-display: var(--mute-button); 50620 --media-captions-button-display: var(--captions-button); 50621 --media-captions-menu-button-display: var(--captions-menu-button, var(--media-captions-button-display)); 50622 --media-rendition-menu-button-display: var(--rendition-menu-button); 50623 --media-audio-track-menu-button-display: var(--audio-track-menu-button); 50624 --media-airplay-button-display: var(--airplay-button); 50625 --media-pip-button-display: var(--pip-button); 50626 --media-fullscreen-button-display: var(--fullscreen-button); 50627 --media-cast-button-display: var(--cast-button, var(--_cast-button-drm-display)); 50628 --media-playback-rate-button-display: var(--playback-rate-button); 50629 --media-playback-rate-menu-button-display: var(--playback-rate-menu-button); 50630 --media-volume-range-display: var(--volume-range); 50631 --media-time-range-display: var(--time-range); 50632 --media-time-display-display: var(--time-display); 50633 --media-duration-display-display: var(--duration-display); 50634 --media-title-display-display: var(--title-display); 50635 50636 display: inline-block; 50637 width: 100%; 50638 line-height: 0; 50639} 50640 50641/* Hide custom elements that are not defined yet */ 50642:not(:defined) { 50643 display: none; 50644} 50645 50646a { 50647 color: #fff; 50648 font-size: 0.9em; 50649 text-decoration: underline; 50650} 50651 50652media-theme { 50653 width: 100%; 50654 height: 100%; 50655 direction: ltr; 50656} 50657 50658media-poster-image { 50659 width: 100%; 50660 height: 100%; 50661} 50662 50663media-poster-image:not([src]):not([placeholdersrc]) { 50664 display: none; 50665} 50666 50667::part(top), 50668[part~='top'] { 50669 --media-control-display: var(--controls, var(--top-controls)); 50670 --media-play-button-display: var(--play-button, var(--top-play-button)); 50671 --media-live-button-display: var(--live-button, var(--top-live-button)); 50672 --media-seek-backward-button-display: var(--seek-backward-button, var(--top-seek-backward-button)); 50673 --media-seek-forward-button-display: var(--seek-forward-button, var(--top-seek-forward-button)); 50674 --media-mute-button-display: var(--mute-button, var(--top-mute-button)); 50675 --media-captions-button-display: var(--captions-button, var(--top-captions-button)); 50676 --media-captions-menu-button-display: var( 50677 --captions-menu-button, 50678 var(--media-captions-button-display, var(--top-captions-menu-button)) 50679 ); 50680 --media-rendition-menu-button-display: var(--rendition-menu-button, var(--top-rendition-menu-button)); 50681 --media-audio-track-menu-button-display: var(--audio-track-menu-button, var(--top-audio-track-menu-button)); 50682 --media-airplay-button-display: var(--airplay-button, var(--top-airplay-button)); 50683 --media-pip-button-display: var(--pip-button, var(--top-pip-button)); 50684 --media-fullscreen-button-display: var(--fullscreen-button, var(--top-fullscreen-button)); 50685 --media-cast-button-display: var(--cast-button, var(--top-cast-button, var(--_cast-button-drm-display))); 50686 --media-playback-rate-button-display: var(--playback-rate-button, var(--top-playback-rate-button)); 50687 --media-playback-rate-menu-button-display: var( 50688 --captions-menu-button, 50689 var(--media-playback-rate-button-display, var(--top-playback-rate-menu-button)) 50690 ); 50691 --media-volume-range-display: var(--volume-range, var(--top-volume-range)); 50692 --media-time-range-display: var(--time-range, var(--top-time-range)); 50693 --media-time-display-display: var(--time-display, var(--top-time-display)); 50694 --media-duration-display-display: var(--duration-display, var(--top-duration-display)); 50695 --media-title-display-display: var(--title-display, var(--top-title-display)); 50696} 50697 50698::part(center), 50699[part~='center'] { 50700 --media-control-display: var(--controls, var(--center-controls)); 50701 --media-play-button-display: var(--play-button, var(--center-play-button)); 50702 --media-live-button-display: var(--live-button, var(--center-live-button)); 50703 --media-seek-backward-button-display: var(--seek-backward-button, var(--center-seek-backward-button)); 50704 --media-seek-forward-button-display: var(--seek-forward-button, var(--center-seek-forward-button)); 50705 --media-mute-button-display: var(--mute-button, var(--center-mute-button)); 50706 --media-captions-button-display: var(--captions-button, var(--center-captions-button)); 50707 --media-captions-menu-button-display: var( 50708 --captions-menu-button, 50709 var(--media-captions-button-display, var(--center-captions-menu-button)) 50710 ); 50711 --media-rendition-menu-button-display: var(--rendition-menu-button, var(--center-rendition-menu-button)); 50712 --media-audio-track-menu-button-display: var(--audio-track-menu-button, var(--center-audio-track-menu-button)); 50713 --media-airplay-button-display: var(--airplay-button, var(--center-airplay-button)); 50714 --media-pip-button-display: var(--pip-button, var(--center-pip-button)); 50715 --media-fullscreen-button-display: var(--fullscreen-button, var(--center-fullscreen-button)); 50716 --media-cast-button-display: var(--cast-button, var(--center-cast-button, var(--_cast-button-drm-display))); 50717 --media-playback-rate-button-display: var(--playback-rate-button, var(--center-playback-rate-button)); 50718 --media-playback-rate-menu-button-display: var( 50719 --playback-rate-menu-button, 50720 var(--media-playback-rate-button-display, var(--center-playback-rate-menu-button)) 50721 ); 50722 --media-volume-range-display: var(--volume-range, var(--center-volume-range)); 50723 --media-time-range-display: var(--time-range, var(--center-time-range)); 50724 --media-time-display-display: var(--time-display, var(--center-time-display)); 50725 --media-duration-display-display: var(--duration-display, var(--center-duration-display)); 50726} 50727 50728::part(bottom), 50729[part~='bottom'] { 50730 --media-control-display: var(--controls, var(--bottom-controls)); 50731 --media-play-button-display: var(--play-button, var(--bottom-play-button)); 50732 --media-live-button-display: var(--live-button, var(--bottom-live-button)); 50733 --media-seek-backward-button-display: var(--seek-backward-button, var(--bottom-seek-backward-button)); 50734 --media-seek-forward-button-display: var(--seek-forward-button, var(--bottom-seek-forward-button)); 50735 --media-mute-button-display: var(--mute-button, var(--bottom-mute-button)); 50736 --media-captions-button-display: var(--captions-button, var(--bottom-captions-button)); 50737 --media-captions-menu-button-display: var( 50738 --captions-menu-button, 50739 var(--media-captions-button-display, var(--bottom-captions-menu-button)) 50740 ); 50741 --media-rendition-menu-button-display: var(--rendition-menu-button, var(--bottom-rendition-menu-button)); 50742 --media-audio-track-menu-button-display: var(--audio-track-menu-button, var(--bottom-audio-track-menu-button)); 50743 --media-airplay-button-display: var(--airplay-button, var(--bottom-airplay-button)); 50744 --media-pip-button-display: var(--pip-button, var(--bottom-pip-button)); 50745 --media-fullscreen-button-display: var(--fullscreen-button, var(--bottom-fullscreen-button)); 50746 --media-cast-button-display: var(--cast-button, var(--bottom-cast-button, var(--_cast-button-drm-display))); 50747 --media-playback-rate-button-display: var(--playback-rate-button, var(--bottom-playback-rate-button)); 50748 --media-playback-rate-menu-button-display: var( 50749 --playback-rate-menu-button, 50750 var(--media-playback-rate-button-display, var(--bottom-playback-rate-menu-button)) 50751 ); 50752 --media-volume-range-display: var(--volume-range, var(--bottom-volume-range)); 50753 --media-time-range-display: var(--time-range, var(--bottom-time-range)); 50754 --media-time-display-display: var(--time-display, var(--bottom-time-display)); 50755 --media-duration-display-display: var(--duration-display, var(--bottom-duration-display)); 50756 --media-title-display-display: var(--title-display, var(--bottom-title-display)); 50757} 50758 50759:host([no-tooltips]) { 50760 --media-tooltip-display: none; 50761} 50762`; 50763var Ct4 = ` 50764 :host { 50765 z-index: 100; 50766 display: var(--media-dialog-display, flex); 50767 justify-content: center; 50768 align-items: center; 50769 width: 100%; 50770 height: 100%; 50771 position: absolute; 50772 top: 0; 50773 left: 0; 50774 box-sizing: border-box; 50775 color: #fff; 50776 line-height: 18px; 50777 font-family: Arial, sans-serif; 50778 padding: var(--media-dialog-backdrop-padding, 0); 50779 background: var(--media-dialog-backdrop-background, 50780 linear-gradient(to bottom, rgba(20, 20, 30, 0.7) 50%, rgba(20, 20, 30, 0.9)) 50781 ); 50782 /* Needs to use !important to prevent overwrite of media-chrome */ 50783 transition: var(--media-dialog-transition-open, visibility .2s, opacity .2s) !important; 50784 transform: var(--media-dialog-transform-open, none) !important; 50785 visibility: visible !important; 50786 opacity: 1 !important; 50787 pointer-events: auto !important; 50788 } 50789 50790 :host(:not([open])) { 50791 /* Needs to use !important to prevent overwrite of media-chrome */ 50792 transition: var(--media-dialog-transition-close, visibility .1s, opacity .1s) !important; 50793 transform: var(--media-dialog-transform-close, none) !important; 50794 visibility: hidden !important; 50795 opacity: 0 !important; 50796 pointer-events: none !important; 50797 } 50798 50799 :focus-visible { 50800 box-shadow: 0 0 0 2px rgba(27, 127, 204, 0.9); 50801 } 50802 50803 .dialog { 50804 position: relative; 50805 box-sizing: border-box; 50806 background: var(--media-dialog-background, none); 50807 padding: var(--media-dialog-padding, 10px); 50808 width: min(320px, 100%); 50809 word-wrap: break-word; 50810 max-height: 100%; 50811 overflow: auto; 50812 text-align: center; 50813 line-height: 1.4; 50814 } 50815`; 50816var kt4 = C3.createElement("template"); 50817kt4.innerHTML = ` 50818 <style> 50819 ${Ct4} 50820 </style> 50821 50822 <div class="dialog"> 50823 <slot></slot> 50824 </div> 50825`; 50826var I3 = class extends p.HTMLElement { 50827 constructor() { 50828 var a2; 50829 super(), this.attachShadow({ mode: "open" }), (a2 = this.shadowRoot) == null || a2.appendChild(this.constructor.template.content.cloneNode(true)); 50830 } 50831 show() { 50832 this.setAttribute("open", ""), this.dispatchEvent(new CustomEvent("open", { composed: true, bubbles: true })), At4(this); 50833 } 50834 close() { 50835 this.hasAttribute("open") && (this.removeAttribute("open"), this.dispatchEvent(new CustomEvent("close", { composed: true, bubbles: true })), oa2(this)); 50836 } 50837 attributeChangedCallback(a2, e, i3) { 50838 a2 === "open" && e !== i3 && (i3 != null ? this.show() : this.close()); 50839 } 50840 connectedCallback() { 50841 this.hasAttribute("role") || this.setAttribute("role", "dialog"), this.hasAttribute("open") && At4(this); 50842 } 50843}; 50844I3.styles = Ct4, I3.template = kt4, I3.observedAttributes = ["open"]; 50845function At4(t2) { 50846 let a2 = new CustomEvent("initfocus", { composed: true, bubbles: true, cancelable: true }); 50847 if (t2.dispatchEvent(a2), a2.defaultPrevented) return; 50848 let e = t2.querySelector("[autofocus]:not([disabled])"); 50849 !e && t2.tabIndex >= 0 && (e = t2), e || (e = Rt4(t2.shadowRoot)), t2._previouslyFocusedElement = C3.activeElement, C3.activeElement instanceof HTMLElement && C3.activeElement.blur(), t2.addEventListener("transitionend", () => { 50850 e instanceof HTMLElement && e.focus({ preventScroll: true }); 50851 }, { once: true }); 50852} 50853function Rt4(t2) { 50854 let e = ["button", "input", "keygen", "select", "textarea"].map(function(r10) { 50855 return r10 + ":not([disabled])"; 50856 }); 50857 e.push('[tabindex]:not([disabled]):not([tabindex=""])'); 50858 let i3 = t2 == null ? void 0 : t2.querySelector(e.join(", ")); 50859 if (!i3 && "attachShadow" in Element.prototype) { 50860 let r10 = (t2 == null ? void 0 : t2.querySelectorAll("*")) || []; 50861 for (let o2 = 0; o2 < r10.length && !(r10[o2].tagName && r10[o2].shadowRoot && (i3 = Rt4(r10[o2].shadowRoot), i3)); o2++) ; 50862 } 50863 return i3; 50864} 50865function oa2(t2) { 50866 t2._previouslyFocusedElement instanceof HTMLElement && t2._previouslyFocusedElement.focus(); 50867} 50868p.customElements.get("media-dialog") || (p.customElements.define("media-dialog", I3), p.MediaDialog = I3); 50869var we3 = I3; 50870var Ot3 = C3.createElement("template"); 50871Ot3.innerHTML = ` 50872 <style> 50873 ${we3.styles} 50874 50875 .close { 50876 background: none; 50877 color: inherit; 50878 border: none; 50879 padding: 0; 50880 font: inherit; 50881 cursor: pointer; 50882 outline: inherit; 50883 width: 28px; 50884 height: 28px; 50885 position: absolute; 50886 top: 1rem; 50887 right: 1rem; 50888 } 50889 </style> 50890 50891 <div class="dialog"> 50892 <slot></slot> 50893 </div> 50894 50895 <slot name="close"> 50896 <button class="close" tabindex="0"> 50897 <svg fill="none" viewBox="0 0 24 24" stroke="currentColor"> 50898 <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" /> 50899 </svg> 50900 </button> 50901 </slot> 50902`; 50903var te4 = class extends we3 { 50904 constructor() { 50905 var a2, e; 50906 super(), (e = (a2 = this.shadowRoot) == null ? void 0 : a2.querySelector(".close")) == null || e.addEventListener("click", () => { 50907 this.close(); 50908 }); 50909 } 50910}; 50911te4.template = Ot3; 50912p.customElements.get("mxp-dialog") || (p.customElements.define("mxp-dialog", te4), p.MxpDialog = te4); 50913var ae3 = /* @__PURE__ */ new WeakMap(); 50914var Ie4 = class t { 50915 constructor(a2, e) { 50916 this.element = a2; 50917 this.type = e; 50918 this.element.addEventListener(this.type, this); 50919 let i3 = ae3.get(this.element); 50920 i3 && i3.set(this.type, this); 50921 } 50922 set(a2) { 50923 if (typeof a2 == "function") this.handleEvent = a2.bind(this.element); 50924 else if (typeof a2 == "object" && typeof a2.handleEvent == "function") this.handleEvent = a2.handleEvent.bind(a2); 50925 else { 50926 this.element.removeEventListener(this.type, this); 50927 let e = ae3.get(this.element); 50928 e && e.delete(this.type); 50929 } 50930 } 50931 static for(a2) { 50932 ae3.has(a2.element) || ae3.set(a2.element, /* @__PURE__ */ new Map()); 50933 let e = a2.attributeName.slice(2), i3 = ae3.get(a2.element); 50934 return i3 && i3.has(e) ? i3.get(e) : new t(a2.element, e); 50935 } 50936}; 50937function sa2(t2, a2) { 50938 return t2 instanceof AttrPart && t2.attributeName.startsWith("on") ? (Ie4.for(t2).set(a2), t2.element.removeAttributeNS(t2.attributeNamespace, t2.attributeName), true) : false; 50939} 50940function da2(t2, a2) { 50941 return a2 instanceof pe4 && t2 instanceof ChildNodePart ? (a2.renderInto(t2), true) : false; 50942} 50943function la2(t2, a2) { 50944 return a2 instanceof DocumentFragment && t2 instanceof ChildNodePart ? (a2.childNodes.length && t2.replace(...a2.childNodes), true) : false; 50945} 50946function ua2(t2, a2) { 50947 if (t2 instanceof AttrPart) { 50948 let e = t2.attributeNamespace, i3 = t2.element.getAttributeNS(e, t2.attributeName); 50949 return String(a2) !== i3 && (t2.value = String(a2)), true; 50950 } 50951 return t2.value = String(a2), true; 50952} 50953function ma2(t2, a2) { 50954 if (t2 instanceof AttrPart && a2 instanceof Element) { 50955 let e = t2.element; 50956 return e[t2.attributeName] !== a2 && (t2.element.removeAttributeNS(t2.attributeNamespace, t2.attributeName), e[t2.attributeName] = a2), true; 50957 } 50958 return false; 50959} 50960function ca2(t2, a2) { 50961 if (typeof a2 == "boolean" && t2 instanceof AttrPart) { 50962 let e = t2.attributeNamespace, i3 = t2.element.hasAttributeNS(e, t2.attributeName); 50963 return a2 !== i3 && (t2.booleanValue = a2), true; 50964 } 50965 return false; 50966} 50967function pa2(t2, a2) { 50968 return a2 === false && t2 instanceof ChildNodePart ? (t2.replace(""), true) : false; 50969} 50970function ba2(t2, a2) { 50971 ma2(t2, a2) || ca2(t2, a2) || sa2(t2, a2) || pa2(t2, a2) || da2(t2, a2) || la2(t2, a2) || ua2(t2, a2); 50972} 50973var Pe4 = /* @__PURE__ */ new Map(); 50974var xt4 = /* @__PURE__ */ new WeakMap(); 50975var _t4 = /* @__PURE__ */ new WeakMap(); 50976var pe4 = class { 50977 constructor(a2, e, i3) { 50978 this.strings = a2; 50979 this.values = e; 50980 this.processor = i3; 50981 this.stringsKey = this.strings.join("�"); 50982 } 50983 get template() { 50984 if (Pe4.has(this.stringsKey)) return Pe4.get(this.stringsKey); 50985 { 50986 let a2 = C3.createElement("template"), e = this.strings.length - 1; 50987 return a2.innerHTML = this.strings.reduce((i3, r10, o2) => i3 + r10 + (o2 < e ? `{{ ${o2} }}` : ""), ""), Pe4.set(this.stringsKey, a2), a2; 50988 } 50989 } 50990 renderInto(a2) { 50991 var r10; 50992 let e = this.template; 50993 if (xt4.get(a2) !== e) { 50994 xt4.set(a2, e); 50995 let o2 = new TemplateInstance(e, this.values, this.processor); 50996 _t4.set(a2, o2), a2 instanceof ChildNodePart ? a2.replace(...o2.children) : a2.appendChild(o2); 50997 return; 50998 } 50999 let i3 = _t4.get(a2); 51000 (r10 = i3 == null ? void 0 : i3.update) == null || r10.call(i3, this.values); 51001 } 51002}; 51003var ha2 = { processCallback(t2, a2, e) { 51004 var i3; 51005 if (e) { 51006 for (let [r10, o2] of a2) if (r10 in e) { 51007 let d2 = (i3 = e[r10]) != null ? i3 : ""; 51008 ba2(o2, d2); 51009 } 51010 } 51011} }; 51012function S2(t2, ...a2) { 51013 return new pe4(t2, a2, ha2); 51014} 51015function Lt3(t2, a2) { 51016 t2.renderInto(a2); 51017} 51018var ya2 = (t2) => { 51019 let { tokens: a2 } = t2; 51020 return a2.drm ? ":host { --_cast-button-drm-display: none; }" : ""; 51021}; 51022var St3 = (t2) => S2` 51023 <style> 51024 ${ya2(t2)} 51025 ${Et4} 51026 </style> 51027 ${Aa2(t2)} 51028`; 51029var va2 = (t2) => { 51030 let a2 = t2.hotKeys ? `${t2.hotKeys}` : ""; 51031 return Q4(t2.streamType) === "live" && (a2 += " noarrowleft noarrowright"), a2; 51032}; 51033var Ta2 = { TOP: "top", CENTER: "center", BOTTOM: "bottom", LAYER: "layer", MEDIA_LAYER: "media-layer", POSTER_LAYER: "poster-layer", VERTICAL_LAYER: "vertical-layer", CENTERED_LAYER: "centered-layer", GESTURE_LAYER: "gesture-layer", CONTROLLER_LAYER: "controller", BUTTON: "button", RANGE: "range", DISPLAY: "display", CONTROL_BAR: "control-bar", MENU_BUTTON: "menu-button", LISTBOX: "listbox", OPTION: "option", POSTER: "poster", LIVE: "live", PLAY: "play", PRE_PLAY: "pre-play", SEEK_BACKWARD: "seek-backward", SEEK_FORWARD: "seek-forward", MUTE: "mute", CAPTIONS: "captions", AIRPLAY: "airplay", PIP: "pip", FULLSCREEN: "fullscreen", CAST: "cast", PLAYBACK_RATE: "playback-rate", VOLUME: "volume", TIME: "time", TITLE: "title", AUDIO_TRACK: "audio-track", RENDITION: "rendition" }; 51034var Ea2 = Object.values(Ta2).join(", "); 51035var Aa2 = (t2) => { 51036 var a2, e, i3, r10, o2, d2, l2, c3, O2, j3, k3, A4, x2, Y4, g, de5, q3, z3, Fe4, Ye4, We3, Ze3, Ge4, je3, qe2, ze3, Xe4, Je4, Qe4, et3, tt4, at3, it4, rt3, ot4, nt4, st3, dt5; 51037 return S2` 51038 <media-theme 51039 template="${t2.themeTemplate || false}" 51040 defaultstreamtype="${(a2 = t2.defaultStreamType) != null ? a2 : false}" 51041 hotkeys="${va2(t2) || false}" 51042 nohotkeys="${t2.noHotKeys || !t2.hasSrc || t2.isDialogOpen || false}" 51043 noautoseektolive="${!!((e = t2.streamType) != null && e.includes(D2.LIVE)) && t2.targetLiveWindow !== 0}" 51044 novolumepref="${t2.novolumepref || false}" 51045 disabled="${!t2.hasSrc || t2.isDialogOpen}" 51046 audio="${(i3 = t2.audio) != null ? i3 : false}" 51047 style="${(r10 = mt3({ "--media-primary-color": t2.primaryColor, "--media-secondary-color": t2.secondaryColor, "--media-accent-color": t2.accentColor })) != null ? r10 : false}" 51048 defaultsubtitles="${!t2.defaultHiddenCaptions}" 51049 forwardseekoffset="${(o2 = t2.forwardSeekOffset) != null ? o2 : false}" 51050 backwardseekoffset="${(d2 = t2.backwardSeekOffset) != null ? d2 : false}" 51051 playbackrates="${(l2 = t2.playbackRates) != null ? l2 : false}" 51052 defaultshowremainingtime="${(c3 = t2.defaultShowRemainingTime) != null ? c3 : false}" 51053 defaultduration="${(O2 = t2.defaultDuration) != null ? O2 : false}" 51054 hideduration="${(j3 = t2.hideDuration) != null ? j3 : false}" 51055 title="${(k3 = t2.title) != null ? k3 : false}" 51056 exportparts="${Ea2}" 51057 > 51058 <mux-video 51059 slot="media" 51060 target-live-window="${(A4 = t2.targetLiveWindow) != null ? A4 : false}" 51061 stream-type="${(x2 = Q4(t2.streamType)) != null ? x2 : false}" 51062 crossorigin="${(Y4 = t2.crossOrigin) != null ? Y4 : ""}" 51063 playsinline 51064 autoplay="${(g = t2.autoplay) != null ? g : false}" 51065 muted="${(de5 = t2.muted) != null ? de5 : false}" 51066 loop="${(q3 = t2.loop) != null ? q3 : false}" 51067 preload="${(z3 = t2.preload) != null ? z3 : false}" 51068 debug="${(Fe4 = t2.debug) != null ? Fe4 : false}" 51069 prefer-cmcd="${(Ye4 = t2.preferCmcd) != null ? Ye4 : false}" 51070 disable-tracking="${(We3 = t2.disableTracking) != null ? We3 : false}" 51071 disable-cookies="${(Ze3 = t2.disableCookies) != null ? Ze3 : false}" 51072 prefer-playback="${(Ge4 = t2.preferPlayback) != null ? Ge4 : false}" 51073 start-time="${t2.startTime != null ? t2.startTime : false}" 51074 beacon-collection-domain="${(je3 = t2.beaconCollectionDomain) != null ? je3 : false}" 51075 player-software-name="${(qe2 = t2.playerSoftwareName) != null ? qe2 : false}" 51076 player-software-version="${(ze3 = t2.playerSoftwareVersion) != null ? ze3 : false}" 51077 env-key="${(Xe4 = t2.envKey) != null ? Xe4 : false}" 51078 custom-domain="${(Je4 = t2.customDomain) != null ? Je4 : false}" 51079 src="${t2.src ? t2.src : t2.playbackId ? Lr(t2) : false}" 51080 cast-src="${t2.src ? t2.src : t2.playbackId ? Lr(t2) : false}" 51081 cast-receiver="${(Qe4 = t2.castReceiver) != null ? Qe4 : false}" 51082 drm-token="${(tt4 = (et3 = t2.tokens) == null ? void 0 : et3.drm) != null ? tt4 : false}" 51083 exportparts="video" 51084 > 51085 ${t2.storyboard ? S2`<track label="thumbnails" default kind="metadata" src="${t2.storyboard}" />` : S2``} 51086 </mux-video> 51087 <slot name="poster" slot="poster"> 51088 <media-poster-image 51089 part="poster" 51090 exportparts="poster, img" 51091 src="${t2.poster ? t2.poster : false}" 51092 placeholdersrc="${(at3 = t2.placeholder) != null ? at3 : false}" 51093 ></media-poster-image> 51094 </slot> 51095 <mxp-dialog 51096 no-auto-hide 51097 open="${(it4 = t2.isDialogOpen) != null ? it4 : false}" 51098 onclose="${t2.onCloseErrorDialog}" 51099 oninitfocus="${t2.onInitFocusDialog}" 51100 > 51101 ${(rt3 = t2.dialog) != null && rt3.title ? S2`<h3>${t2.dialog.title}</h3>` : S2``} 51102 <p> 51103 ${(ot4 = t2.dialog) == null ? void 0 : ot4.message} 51104 ${(nt4 = t2.dialog) != null && nt4.linkUrl ? S2`<a 51105 href="${t2.dialog.linkUrl}" 51106 target="_blank" 51107 rel="external noopener" 51108 aria-label="${(st3 = t2.dialog.linkText) != null ? st3 : ""} ${E("(opens in a new window)")}" 51109 >${(dt5 = t2.dialog.linkText) != null ? dt5 : t2.dialog.linkUrl}</a 51110 >` : S2``} 51111 </p> 51112 </mxp-dialog> 51113 </media-theme> 51114`; 51115}; 51116var Pt4 = (t2) => t2.charAt(0).toUpperCase() + t2.slice(1); 51117var Ca = (t2, a2 = false) => { 51118 var e, i3; 51119 if (t2.muxCode) { 51120 let r10 = Pt4((e = t2.errorCategory) != null ? e : "video"), o2 = H2((i3 = t2.errorCategory) != null ? i3 : C2.VIDEO); 51121 if (t2.muxCode === M.NETWORK_OFFLINE) return E("Your device appears to be offline", a2); 51122 if (t2.muxCode === M.NETWORK_TOKEN_EXPIRED) return E("{category} URL has expired", a2).format({ category: r10 }); 51123 if ([M.NETWORK_TOKEN_SUB_MISMATCH, M.NETWORK_TOKEN_AUD_MISMATCH, M.NETWORK_TOKEN_AUD_MISSING, M.NETWORK_TOKEN_MALFORMED].includes(t2.muxCode)) return E("{category} URL is formatted incorrectly", a2).format({ category: r10 }); 51124 if (t2.muxCode === M.NETWORK_TOKEN_MISSING) return E("Invalid {categoryName} URL", a2).format({ categoryName: o2 }); 51125 if (t2.muxCode === M.NETWORK_NOT_FOUND) return E("{category} does not exist", a2).format({ category: r10 }); 51126 if (t2.muxCode === M.NETWORK_NOT_READY) return E("{category} is not currently available", a2).format({ category: r10 }); 51127 } 51128 if (t2.code) { 51129 if (t2.code === T.MEDIA_ERR_NETWORK) return E("Network Error", a2); 51130 if (t2.code === T.MEDIA_ERR_DECODE) return E("Media Error", a2); 51131 if (t2.code === T.MEDIA_ERR_SRC_NOT_SUPPORTED) return E("Source Not Supported", a2); 51132 } 51133 return E("Error", a2); 51134}; 51135var ka2 = (t2, a2 = false) => { 51136 var e, i3; 51137 if (t2.muxCode) { 51138 let r10 = Pt4((e = t2.errorCategory) != null ? e : "video"), o2 = H2((i3 = t2.errorCategory) != null ? i3 : C2.VIDEO); 51139 return t2.muxCode === M.NETWORK_OFFLINE ? E("Check your internet connection and try reloading this video.", a2) : t2.muxCode === M.NETWORK_TOKEN_EXPIRED ? E("The videoâs secured {tokenNamePrefix}-token has expired.", a2).format({ tokenNamePrefix: o2 }) : t2.muxCode === M.NETWORK_TOKEN_SUB_MISMATCH ? E("The videoâs playback ID does not match the one encoded in the {tokenNamePrefix}-token.", a2).format({ tokenNamePrefix: o2 }) : t2.muxCode === M.NETWORK_TOKEN_MALFORMED ? E("{category} URL is formatted incorrectly", a2).format({ category: r10 }) : [M.NETWORK_TOKEN_AUD_MISMATCH, M.NETWORK_TOKEN_AUD_MISSING].includes(t2.muxCode) ? E("The {tokenNamePrefix}-token is formatted with incorrect information.", a2).format({ tokenNamePrefix: o2 }) : [M.NETWORK_TOKEN_MISSING, M.NETWORK_INVALID_URL].includes(t2.muxCode) ? E("The video URL or {tokenNamePrefix}-token are formatted with incorrect or incomplete information.", a2).format({ tokenNamePrefix: o2 }) : t2.muxCode === M.NETWORK_NOT_FOUND ? "" : t2.muxCode === M.NETWORK_NOT_READY ? E("The live stream or video file are not yet ready.", a2) : t2.message; 51140 } 51141 return t2.code && (t2.code === T.MEDIA_ERR_NETWORK || t2.code === T.MEDIA_ERR_DECODE || t2.code === T.MEDIA_ERR_SRC_NOT_SUPPORTED), t2.message; 51142}; 51143var Ra2 = (t2, a2 = false) => { 51144 let e = Ca(t2, a2), i3 = ka2(t2, a2); 51145 return { title: e, message: i3 }; 51146}; 51147var Oa2 = (t2) => { 51148 if (t2.muxCode) { 51149 if (t2.muxCode === M.NETWORK_TOKEN_EXPIRED) return "403-expired-token.md"; 51150 if (t2.muxCode === M.NETWORK_TOKEN_MALFORMED) return "403-malformatted-token.md"; 51151 if ([M.NETWORK_TOKEN_AUD_MISMATCH, M.NETWORK_TOKEN_AUD_MISSING].includes(t2.muxCode)) return "403-incorrect-aud-value.md"; 51152 if (t2.muxCode === M.NETWORK_TOKEN_SUB_MISMATCH) return "403-playback-id-mismatch.md"; 51153 if (t2.muxCode === M.NETWORK_TOKEN_MISSING) return "missing-signed-tokens.md"; 51154 if (t2.muxCode === M.NETWORK_NOT_FOUND) return "404-not-found.md"; 51155 if (t2.muxCode === M.NETWORK_NOT_READY) return "412-not-playable.md"; 51156 } 51157 if (t2.code) { 51158 if (t2.code === T.MEDIA_ERR_NETWORK) return ""; 51159 if (t2.code === T.MEDIA_ERR_DECODE) return "media-decode-error.md"; 51160 if (t2.code === T.MEDIA_ERR_SRC_NOT_SUPPORTED) return "media-src-not-supported.md"; 51161 } 51162 return ""; 51163}; 51164var xa2 = (t2, a2) => { 51165 let e = Oa2(t2); 51166 return { message: t2.message, context: t2.context, file: e }; 51167}; 51168function De3(t2, a2 = false) { 51169 let e = Ra2(t2, a2), i3 = xa2(t2, a2); 51170 return { dialog: e, devlog: i3 }; 51171} 51172var It4 = `<template id="media-theme-gerwig"> 51173 <style> 51174 @keyframes pre-play-hide { 51175 0% { 51176 transform: scale(1); 51177 opacity: 1; 51178 } 51179 51180 30% { 51181 transform: scale(0.7); 51182 } 51183 51184 100% { 51185 transform: scale(1.5); 51186 opacity: 0; 51187 } 51188 } 51189 51190 :host { 51191 --_primary-color: var(--media-primary-color, #fff); 51192 --_secondary-color: var(--media-secondary-color, transparent); 51193 --_accent-color: var(--media-accent-color, #fa50b5); 51194 --_text-color: var(--media-text-color, #000); 51195 51196 --media-icon-color: var(--_primary-color); 51197 --media-control-background: var(--_secondary-color); 51198 --media-control-hover-background: var(--_accent-color); 51199 --media-time-buffered-color: rgba(255, 255, 255, 0.4); 51200 --media-preview-time-text-shadow: none; 51201 --media-control-height: 14px; 51202 --media-control-padding: 6px; 51203 --media-tooltip-container-margin: 6px; 51204 --media-tooltip-distance: 18px; 51205 51206 color: var(--_primary-color); 51207 display: inline-block; 51208 width: 100%; 51209 height: 100%; 51210 } 51211 51212 :host([audio]) { 51213 --_secondary-color: var(--media-secondary-color, black); 51214 --media-preview-time-text-shadow: none; 51215 } 51216 51217 :host([audio]) ::slotted([slot='media']) { 51218 height: 0px; 51219 } 51220 51221 :host([audio]) media-loading-indicator { 51222 display: none; 51223 } 51224 51225 :host([audio]) media-controller { 51226 background: transparent; 51227 } 51228 51229 :host([audio]) media-controller::part(vertical-layer) { 51230 background: transparent; 51231 } 51232 51233 :host([audio]) media-control-bar { 51234 width: 100%; 51235 background-color: var(--media-control-background); 51236 } 51237 51238 /* 51239 * 0.433s is the transition duration for VTT Regions. 51240 * Borrowed here, so the captions don't move too fast. 51241 */ 51242 media-controller { 51243 --media-webkit-text-track-transform: translateY(0) scale(0.98); 51244 --media-webkit-text-track-transition: transform 0.433s ease-out 0.3s; 51245 } 51246 media-controller:is([mediapaused], :not([userinactive])) { 51247 --media-webkit-text-track-transform: translateY(-50px) scale(0.98); 51248 --media-webkit-text-track-transition: transform 0.15s ease; 51249 } 51250 51251 /* 51252 * CSS specific to iOS devices. 51253 * See: https://stackoverflow.com/questions/30102792/css-media-query-to-target-only-ios-devices/60220757#60220757 51254 */ 51255 @supports (-webkit-touch-callout: none) { 51256 /* Disable subtitle adjusting for iOS Safari */ 51257 media-controller[mediaisfullscreen] { 51258 --media-webkit-text-track-transform: unset; 51259 --media-webkit-text-track-transition: unset; 51260 } 51261 } 51262 51263 media-time-range { 51264 --media-box-padding-left: 6px; 51265 --media-box-padding-right: 6px; 51266 --media-range-bar-color: var(--_accent-color); 51267 --media-time-range-buffered-color: var(--_primary-color); 51268 --media-range-track-color: transparent; 51269 --media-range-track-background: rgba(255, 255, 255, 0.4); 51270 --media-range-thumb-background: radial-gradient( 51271 circle, 51272 #000 0%, 51273 #000 25%, 51274 var(--_accent-color) 25%, 51275 var(--_accent-color) 51276 ); 51277 --media-range-thumb-width: 12px; 51278 --media-range-thumb-height: 12px; 51279 --media-range-thumb-transform: scale(0); 51280 --media-range-thumb-transition: transform 0.3s; 51281 --media-range-thumb-opacity: 1; 51282 --media-preview-background: var(--_primary-color); 51283 --media-box-arrow-background: var(--_primary-color); 51284 --media-preview-thumbnail-border: 5px solid var(--_primary-color); 51285 --media-preview-border-radius: 5px; 51286 --media-text-color: var(--_text-color); 51287 --media-control-hover-background: transparent; 51288 --media-preview-chapter-text-shadow: none; 51289 color: var(--_accent-color); 51290 padding: 0 6px; 51291 } 51292 51293 :host([audio]) media-time-range { 51294 --media-preview-time-padding: 1.5px 6px; 51295 --media-preview-box-margin: 0 0 -5px; 51296 } 51297 51298 media-time-range:hover { 51299 --media-range-thumb-transform: scale(1); 51300 } 51301 51302 media-preview-thumbnail { 51303 border-bottom-width: 0; 51304 } 51305 51306 [part~='menu'] { 51307 border-radius: 2px; 51308 border: 1px solid rgba(0, 0, 0, 0.1); 51309 bottom: 50px; 51310 padding: 2.5px 10px; 51311 } 51312 51313 [part~='menu']::part(indicator) { 51314 fill: var(--_accent-color); 51315 } 51316 51317 [part~='menu']::part(menu-item) { 51318 box-sizing: border-box; 51319 display: flex; 51320 align-items: center; 51321 padding: 6px 10px; 51322 min-height: 34px; 51323 } 51324 51325 [part~='menu']::part(checked) { 51326 font-weight: 700; 51327 } 51328 51329 media-captions-menu, 51330 media-rendition-menu, 51331 media-audio-track-menu, 51332 media-playback-rate-menu { 51333 position: absolute; /* ensure they don't take up space in DOM on load */ 51334 --media-menu-background: var(--_primary-color); 51335 --media-menu-item-checked-background: transparent; 51336 --media-text-color: var(--_text-color); 51337 --media-menu-item-hover-background: transparent; 51338 --media-menu-item-hover-outline: var(--_accent-color) solid 1px; 51339 } 51340 51341 /* The icon is a circle so make it 16px high instead of 14px for more balance. */ 51342 media-audio-track-menu-button { 51343 --media-control-padding: 5px; 51344 --media-control-height: 16px; 51345 } 51346 51347 media-playback-rate-menu-button { 51348 --media-control-padding: 6px 3px; 51349 min-width: 4.4ch; 51350 } 51351 51352 media-playback-rate-menu { 51353 --media-menu-flex-direction: row; 51354 --media-menu-item-checked-background: var(--_accent-color); 51355 --media-menu-item-checked-indicator-display: none; 51356 margin-right: 6px; 51357 padding: 0; 51358 --media-menu-gap: 0.25em; 51359 } 51360 51361 media-playback-rate-menu[part~='menu']::part(menu-item) { 51362 padding: 6px 6px 6px 8px; 51363 } 51364 51365 media-playback-rate-menu[part~='menu']::part(checked) { 51366 color: #fff; 51367 } 51368 51369 :host(:not([audio])) media-time-range { 51370 /* Adding px is required here for calc() */ 51371 --media-range-padding: 0px; 51372 background: transparent; 51373 z-index: 10; 51374 height: 10px; 51375 bottom: -3px; 51376 width: 100%; 51377 } 51378 51379 media-control-bar :is([role='button'], [role='switch'], button) { 51380 line-height: 0; 51381 } 51382 51383 media-control-bar :is([part*='button'], [part*='range'], [part*='display']) { 51384 border-radius: 3px; 51385 } 51386 51387 .spacer { 51388 flex-grow: 1; 51389 background-color: var(--media-control-background, rgba(20, 20, 30, 0.7)); 51390 } 51391 51392 media-control-bar[slot~='top-chrome'] { 51393 min-height: 42px; 51394 pointer-events: none; 51395 } 51396 51397 media-control-bar { 51398 --gradient-steps: hsl(0 0% 0% / 0) 0%, hsl(0 0% 0% / 0.013) 8.1%, hsl(0 0% 0% / 0.049) 15.5%, 51399 hsl(0 0% 0% / 0.104) 22.5%, hsl(0 0% 0% / 0.175) 29%, hsl(0 0% 0% / 0.259) 35.3%, hsl(0 0% 0% / 0.352) 41.2%, 51400 hsl(0 0% 0% / 0.45) 47.1%, hsl(0 0% 0% / 0.55) 52.9%, hsl(0 0% 0% / 0.648) 58.8%, hsl(0 0% 0% / 0.741) 64.7%, 51401 hsl(0 0% 0% / 0.825) 71%, hsl(0 0% 0% / 0.896) 77.5%, hsl(0 0% 0% / 0.951) 84.5%, hsl(0 0% 0% / 0.987) 91.9%, 51402 hsl(0 0% 0%) 100%; 51403 } 51404 51405 :host([title]:not([audio])) media-control-bar[slot='top-chrome']::before { 51406 content: ''; 51407 position: absolute; 51408 width: 100%; 51409 padding-bottom: min(100px, 25%); 51410 background: linear-gradient(to top, var(--gradient-steps)); 51411 opacity: 0.8; 51412 pointer-events: none; 51413 } 51414 51415 :host(:not([audio])) media-control-bar[part~='bottom']::before { 51416 content: ''; 51417 position: absolute; 51418 width: 100%; 51419 bottom: 0; 51420 left: 0; 51421 padding-bottom: min(100px, 25%); 51422 background: linear-gradient(to bottom, var(--gradient-steps)); 51423 opacity: 0.8; 51424 z-index: 1; 51425 pointer-events: none; 51426 } 51427 51428 media-control-bar[part~='bottom'] > * { 51429 z-index: 20; 51430 } 51431 51432 media-control-bar[part~='bottom'] { 51433 padding: 6px 6px; 51434 } 51435 51436 media-control-bar[slot~='top-chrome'] > * { 51437 --media-control-background: transparent; 51438 --media-control-hover-background: transparent; 51439 position: relative; 51440 } 51441 51442 media-controller::part(vertical-layer) { 51443 transition: background-color 1s; 51444 } 51445 51446 media-controller:is([mediapaused], :not([userinactive]))::part(vertical-layer) { 51447 background-color: var(--controls-backdrop-color, var(--controls, transparent)); 51448 transition: background-color 0.25s; 51449 } 51450 51451 .center-controls { 51452 --media-button-icon-width: 100%; 51453 --media-button-icon-height: auto; 51454 --media-tooltip-display: none; 51455 pointer-events: none; 51456 width: 100%; 51457 display: flex; 51458 flex-flow: row; 51459 align-items: center; 51460 justify-content: center; 51461 filter: drop-shadow(0 0 2px rgb(0 0 0 / 0.25)) drop-shadow(0 0 6px rgb(0 0 0 / 0.25)); 51462 paint-order: stroke; 51463 stroke: rgba(102, 102, 102, 1); 51464 stroke-width: 0.3px; 51465 text-shadow: 51466 0 0 2px rgb(0 0 0 / 0.25), 51467 0 0 6px rgb(0 0 0 / 0.25); 51468 } 51469 51470 .center-controls media-play-button { 51471 --media-control-background: transparent; 51472 --media-control-hover-background: transparent; 51473 --media-control-padding: 0; 51474 width: 40px; 51475 } 51476 51477 [breakpointsm] .center-controls media-play-button { 51478 width: 90px; 51479 height: 90px; 51480 border-radius: 50%; 51481 transition: background 0.4s; 51482 padding: 24px; 51483 --media-control-background: #000; 51484 --media-control-hover-background: var(--_accent-color); 51485 } 51486 51487 .center-controls media-seek-backward-button, 51488 .center-controls media-seek-forward-button { 51489 --media-control-background: transparent; 51490 --media-control-hover-background: transparent; 51491 padding: 0; 51492 margin: 0 20px; 51493 width: max(33px, min(8%, 40px)); 51494 } 51495 51496 [breakpointsm]:not([audio]) .center-controls.pre-playback { 51497 display: grid; 51498 align-items: initial; 51499 justify-content: initial; 51500 height: 100%; 51501 overflow: hidden; 51502 } 51503 51504 [breakpointsm]:not([audio]) .center-controls.pre-playback media-play-button { 51505 place-self: var(--_pre-playback-place, center); 51506 grid-area: 1 / 1; 51507 margin: 16px; 51508 } 51509 51510 /* Show and hide controls or pre-playback state */ 51511 51512 [breakpointsm]:is([mediahasplayed], :not([mediapaused])):not([audio]) 51513 .center-controls.pre-playback 51514 media-play-button { 51515 /* Using \`forwards\` would lead to a laggy UI after the animation got in the end state */ 51516 animation: 0.3s linear pre-play-hide; 51517 opacity: 0; 51518 pointer-events: none; 51519 } 51520 51521 .autoplay-unmute { 51522 --media-control-hover-background: transparent; 51523 width: 100%; 51524 display: flex; 51525 align-items: center; 51526 justify-content: center; 51527 filter: drop-shadow(0 0 2px rgb(0 0 0 / 0.25)) drop-shadow(0 0 6px rgb(0 0 0 / 0.25)); 51528 } 51529 51530 .autoplay-unmute-btn { 51531 --media-control-height: 16px; 51532 border-radius: 8px; 51533 background: #000; 51534 color: var(--_primary-color); 51535 display: flex; 51536 align-items: center; 51537 padding: 8px 16px; 51538 font-size: 18px; 51539 font-weight: 500; 51540 cursor: pointer; 51541 } 51542 51543 .autoplay-unmute-btn:hover { 51544 background: var(--_accent-color); 51545 } 51546 51547 [breakpointsm] .autoplay-unmute-btn { 51548 --media-control-height: 30px; 51549 padding: 14px 24px; 51550 font-size: 26px; 51551 } 51552 51553 .autoplay-unmute-btn svg { 51554 margin: 0 6px 0 0; 51555 } 51556 51557 [breakpointsm] .autoplay-unmute-btn svg { 51558 margin: 0 10px 0 0; 51559 } 51560 51561 media-controller:not([audio]):not([mediahasplayed]) *:is(media-control-bar, media-time-range) { 51562 display: none; 51563 } 51564 51565 media-loading-indicator { 51566 --media-loading-icon-width: 100%; 51567 --media-button-icon-height: auto; 51568 display: var(--media-control-display, var(--media-loading-indicator-display, flex)); 51569 pointer-events: none; 51570 position: absolute; 51571 width: min(15%, 150px); 51572 flex-flow: row; 51573 align-items: center; 51574 justify-content: center; 51575 } 51576 51577 /* Intentionally don't target the div for transition but the children 51578 of the div. Prevents messing with media-chrome's autohide feature. */ 51579 media-loading-indicator + div * { 51580 transition: opacity 0.15s; 51581 opacity: 1; 51582 } 51583 51584 media-loading-indicator[medialoading]:not([mediapaused]) ~ div > * { 51585 opacity: 0; 51586 transition-delay: 400ms; 51587 } 51588 51589 media-volume-range { 51590 width: min(100%, 100px); 51591 --media-range-padding-left: 10px; 51592 --media-range-padding-right: 10px; 51593 --media-range-thumb-width: 12px; 51594 --media-range-thumb-height: 12px; 51595 --media-range-thumb-background: radial-gradient( 51596 circle, 51597 #000 0%, 51598 #000 25%, 51599 var(--_primary-color) 25%, 51600 var(--_primary-color) 51601 ); 51602 --media-control-hover-background: none; 51603 } 51604 51605 media-time-display { 51606 white-space: nowrap; 51607 } 51608 51609 /* Generic style for explicitly disabled controls */ 51610 media-control-bar[part~='bottom'] [disabled], 51611 media-control-bar[part~='bottom'] [aria-disabled='true'] { 51612 opacity: 60%; 51613 cursor: not-allowed; 51614 } 51615 51616 media-text-display { 51617 --media-font-size: 16px; 51618 --media-control-padding: 14px; 51619 font-weight: 500; 51620 } 51621 51622 media-play-button.animated *:is(g, path) { 51623 transition: all 0.3s; 51624 } 51625 51626 media-play-button.animated[mediapaused] .pause-icon-pt1 { 51627 opacity: 0; 51628 } 51629 51630 media-play-button.animated[mediapaused] .pause-icon-pt2 { 51631 transform-origin: center center; 51632 transform: scaleY(0); 51633 } 51634 51635 media-play-button.animated[mediapaused] .play-icon { 51636 clip-path: inset(0 0 0 0); 51637 } 51638 51639 media-play-button.animated:not([mediapaused]) .play-icon { 51640 clip-path: inset(0 0 0 100%); 51641 } 51642 51643 media-seek-forward-button, 51644 media-seek-backward-button { 51645 --media-font-weight: 400; 51646 } 51647 51648 .mute-icon { 51649 display: inline-block; 51650 } 51651 51652 .mute-icon :is(path, g) { 51653 transition: opacity 0.5s; 51654 } 51655 51656 .muted { 51657 opacity: 0; 51658 } 51659 51660 media-mute-button[mediavolumelevel='low'] :is(.volume-medium, .volume-high), 51661 media-mute-button[mediavolumelevel='medium'] :is(.volume-high) { 51662 opacity: 0; 51663 } 51664 51665 media-mute-button[mediavolumelevel='off'] .unmuted { 51666 opacity: 0; 51667 } 51668 51669 media-mute-button[mediavolumelevel='off'] .muted { 51670 opacity: 1; 51671 } 51672 51673 /** 51674 * Our defaults for these buttons are to hide them at small sizes 51675 * users can override this with CSS 51676 */ 51677 media-controller:not([breakpointsm]):not([audio]) { 51678 --bottom-play-button: none; 51679 --bottom-seek-backward-button: none; 51680 --bottom-seek-forward-button: none; 51681 --bottom-time-display: none; 51682 --bottom-playback-rate-menu-button: none; 51683 --bottom-pip-button: none; 51684 } 51685 </style> 51686 51687 <template partial="TitleDisplay"> 51688 <template if="title"> 51689 <media-text-display part="top title display" class="title-display">{{title}}</media-text-display> 51690 </template> 51691 </template> 51692 51693 <template partial="PlayButton"> 51694 <media-play-button 51695 part="{{section ?? 'bottom'}} play button" 51696 disabled="{{disabled}}" 51697 aria-disabled="{{disabled}}" 51698 class="animated" 51699 > 51700 <svg aria-hidden="true" viewBox="0 0 18 14" slot="icon"> 51701 <g class="play-icon"> 51702 <path 51703 d="M15.5987 6.2911L3.45577 0.110898C2.83667 -0.204202 2.06287 0.189698 2.06287 0.819798V13.1802C2.06287 13.8103 2.83667 14.2042 3.45577 13.8891L15.5987 7.7089C16.2178 7.3938 16.2178 6.6061 15.5987 6.2911Z" 51704 /> 51705 </g> 51706 <g class="pause-icon"> 51707 <path 51708 class="pause-icon-pt1" 51709 d="M5.90709 0H2.96889C2.46857 0 2.06299 0.405585 2.06299 0.9059V13.0941C2.06299 13.5944 2.46857 14 2.96889 14H5.90709C6.4074 14 6.81299 13.5944 6.81299 13.0941V0.9059C6.81299 0.405585 6.4074 0 5.90709 0Z" 51710 /> 51711 <path 51712 class="pause-icon-pt2" 51713 d="M15.1571 0H12.2189C11.7186 0 11.313 0.405585 11.313 0.9059V13.0941C11.313 13.5944 11.7186 14 12.2189 14H15.1571C15.6574 14 16.063 13.5944 16.063 13.0941V0.9059C16.063 0.405585 15.6574 0 15.1571 0Z" 51714 /> 51715 </g> 51716 </svg> 51717 </media-play-button> 51718 </template> 51719 51720 <template partial="PrePlayButton"> 51721 <media-play-button 51722 part="{{section ?? 'center'}} play button pre-play" 51723 disabled="{{disabled}}" 51724 aria-disabled="{{disabled}}" 51725 > 51726 <svg aria-hidden="true" viewBox="0 0 18 14" slot="icon" style="transform: translate(3px, 0)"> 51727 <path 51728 d="M15.5987 6.2911L3.45577 0.110898C2.83667 -0.204202 2.06287 0.189698 2.06287 0.819798V13.1802C2.06287 13.8103 2.83667 14.2042 3.45577 13.8891L15.5987 7.7089C16.2178 7.3938 16.2178 6.6061 15.5987 6.2911Z" 51729 /> 51730 </svg> 51731 </media-play-button> 51732 </template> 51733 51734 <template partial="SeekBackwardButton"> 51735 <media-seek-backward-button 51736 seekoffset="{{backwardseekoffset}}" 51737 part="{{section ?? 'bottom'}} seek-backward button" 51738 disabled="{{disabled}}" 51739 aria-disabled="{{disabled}}" 51740 > 51741 <svg viewBox="0 0 22 14" aria-hidden="true" slot="icon"> 51742 <path 51743 d="M3.65 2.07888L0.0864 6.7279C-0.0288 6.87812 -0.0288 7.12188 0.0864 7.2721L3.65 11.9211C3.7792 12.0896 4 11.9703 4 11.7321V2.26787C4 2.02968 3.7792 1.9104 3.65 2.07888Z" 51744 /> 51745 <text transform="translate(6 12)" style="font-size: 14px; font-family: 'ArialMT', 'Arial'"> 51746 {{backwardseekoffset}} 51747 </text> 51748 </svg> 51749 </media-seek-backward-button> 51750 </template> 51751 51752 <template partial="SeekForwardButton"> 51753 <media-seek-forward-button 51754 seekoffset="{{forwardseekoffset}}" 51755 part="{{section ?? 'bottom'}} seek-forward button" 51756 disabled="{{disabled}}" 51757 aria-disabled="{{disabled}}" 51758 > 51759 <svg viewBox="0 0 22 14" aria-hidden="true" slot="icon"> 51760 <g> 51761 <text transform="translate(-1 12)" style="font-size: 14px; font-family: 'ArialMT', 'Arial'"> 51762 {{forwardseekoffset}} 51763 </text> 51764 <path 51765 d="M18.35 11.9211L21.9136 7.2721C22.0288 7.12188 22.0288 6.87812 21.9136 6.7279L18.35 2.07888C18.2208 1.91041 18 2.02968 18 2.26787V11.7321C18 11.9703 18.2208 12.0896 18.35 11.9211Z" 51766 /> 51767 </g> 51768 </svg> 51769 </media-seek-forward-button> 51770 </template> 51771 51772 <template partial="MuteButton"> 51773 <media-mute-button part="bottom mute button" disabled="{{disabled}}" aria-disabled="{{disabled}}"> 51774 <svg viewBox="0 0 18 14" slot="icon" class="mute-icon" aria-hidden="true"> 51775 <g class="unmuted"> 51776 <path 51777 d="M6.76786 1.21233L3.98606 3.98924H1.19937C0.593146 3.98924 0.101743 4.51375 0.101743 5.1607V6.96412L0 6.99998L0.101743 7.03583V8.83926C0.101743 9.48633 0.593146 10.0108 1.19937 10.0108H3.98606L6.76773 12.7877C7.23561 13.2547 8 12.9007 8 12.2171V1.78301C8 1.09925 7.23574 0.745258 6.76786 1.21233Z" 51778 /> 51779 <path 51780 class="volume-low" 51781 d="M10 3.54781C10.7452 4.55141 11.1393 5.74511 11.1393 6.99991C11.1393 8.25471 10.7453 9.44791 10 10.4515L10.7988 11.0496C11.6734 9.87201 12.1356 8.47161 12.1356 6.99991C12.1356 5.52821 11.6735 4.12731 10.7988 2.94971L10 3.54781Z" 51782 /> 51783 <path 51784 class="volume-medium" 51785 d="M12.3778 2.40086C13.2709 3.76756 13.7428 5.35806 13.7428 7.00026C13.7428 8.64246 13.2709 10.233 12.3778 11.5992L13.2106 12.1484C14.2107 10.6185 14.739 8.83796 14.739 7.00016C14.739 5.16236 14.2107 3.38236 13.2106 1.85156L12.3778 2.40086Z" 51786 /> 51787 <path 51788 class="volume-high" 51789 d="M15.5981 0.75L14.7478 1.2719C15.7937 2.9919 16.3468 4.9723 16.3468 7C16.3468 9.0277 15.7937 11.0082 14.7478 12.7281L15.5981 13.25C16.7398 11.3722 17.343 9.211 17.343 7C17.343 4.789 16.7398 2.6268 15.5981 0.75Z" 51790 /> 51791 </g> 51792 <g class="muted"> 51793 <path 51794 fill-rule="evenodd" 51795 clip-rule="evenodd" 51796 d="M4.39976 4.98924H1.19937C1.19429 4.98924 1.17777 4.98961 1.15296 5.01609C1.1271 5.04369 1.10174 5.09245 1.10174 5.1607V8.83926C1.10174 8.90761 1.12714 8.95641 1.15299 8.984C1.17779 9.01047 1.1943 9.01084 1.19937 9.01084H4.39977L7 11.6066V2.39357L4.39976 4.98924ZM7.47434 1.92006C7.4743 1.9201 7.47439 1.92002 7.47434 1.92006V1.92006ZM6.76773 12.7877L3.98606 10.0108H1.19937C0.593146 10.0108 0.101743 9.48633 0.101743 8.83926V7.03583L0 6.99998L0.101743 6.96412V5.1607C0.101743 4.51375 0.593146 3.98924 1.19937 3.98924H3.98606L6.76786 1.21233C7.23574 0.745258 8 1.09925 8 1.78301V12.2171C8 12.9007 7.23561 13.2547 6.76773 12.7877Z" 51797 /> 51798 <path 51799 fill-rule="evenodd" 51800 clip-rule="evenodd" 51801 d="M15.2677 9.30323C15.463 9.49849 15.7796 9.49849 15.9749 9.30323C16.1701 9.10796 16.1701 8.79138 15.9749 8.59612L14.2071 6.82841L15.9749 5.06066C16.1702 4.8654 16.1702 4.54882 15.9749 4.35355C15.7796 4.15829 15.4631 4.15829 15.2678 4.35355L13.5 6.1213L11.7322 4.35348C11.537 4.15822 11.2204 4.15822 11.0251 4.35348C10.8298 4.54874 10.8298 4.86532 11.0251 5.06058L12.7929 6.82841L11.0251 8.59619C10.8299 8.79146 10.8299 9.10804 11.0251 9.3033C11.2204 9.49856 11.537 9.49856 11.7323 9.3033L13.5 7.53552L15.2677 9.30323Z" 51802 /> 51803 </g> 51804 </svg> 51805 </media-mute-button> 51806 </template> 51807 51808 <template partial="PipButton"> 51809 <media-pip-button part="bottom pip button" disabled="{{disabled}}" aria-disabled="{{disabled}}"> 51810 <svg viewBox="0 0 18 14" aria-hidden="true" slot="icon"> 51811 <path 51812 d="M15.9891 0H2.011C0.9004 0 0 0.9003 0 2.0109V11.989C0 13.0996 0.9004 14 2.011 14H15.9891C17.0997 14 18 13.0997 18 11.9891V2.0109C18 0.9003 17.0997 0 15.9891 0ZM17 11.9891C17 12.5465 16.5465 13 15.9891 13H2.011C1.4536 13 1.0001 12.5465 1.0001 11.9891V2.0109C1.0001 1.4535 1.4536 0.9999 2.011 0.9999H15.9891C16.5465 0.9999 17 1.4535 17 2.0109V11.9891Z" 51813 /> 51814 <path 51815 d="M15.356 5.67822H8.19523C8.03253 5.67822 7.90063 5.81012 7.90063 5.97282V11.3836C7.90063 11.5463 8.03253 11.6782 8.19523 11.6782H15.356C15.5187 11.6782 15.6506 11.5463 15.6506 11.3836V5.97282C15.6506 5.81012 15.5187 5.67822 15.356 5.67822Z" 51816 /> 51817 </svg> 51818 </media-pip-button> 51819 </template> 51820 51821 <template partial="CaptionsMenu"> 51822 <media-captions-menu-button part="bottom captions button"> 51823 <svg aria-hidden="true" viewBox="0 0 18 14" slot="on"> 51824 <path 51825 d="M15.989 0H2.011C0.9004 0 0 0.9003 0 2.0109V11.9891C0 13.0997 0.9004 14 2.011 14H15.989C17.0997 14 18 13.0997 18 11.9891V2.0109C18 0.9003 17.0997 0 15.989 0ZM4.2292 8.7639C4.5954 9.1902 5.0935 9.4031 5.7233 9.4031C6.1852 9.4031 6.5544 9.301 6.8302 9.0969C7.1061 8.8933 7.2863 8.614 7.3702 8.26H8.4322C8.3062 8.884 8.0093 9.3733 7.5411 9.7273C7.0733 10.0813 6.4703 10.2581 5.732 10.2581C5.108 10.2581 4.5699 10.1219 4.1168 9.8489C3.6637 9.5759 3.3141 9.1946 3.0685 8.7058C2.8224 8.2165 2.6994 7.6511 2.6994 7.009C2.6994 6.3611 2.8224 5.7927 3.0685 5.3034C3.3141 4.8146 3.6637 4.4323 4.1168 4.1559C4.5699 3.88 5.108 3.7418 5.732 3.7418C6.4703 3.7418 7.0733 3.922 7.5411 4.2818C8.0094 4.6422 8.3062 5.1461 8.4322 5.794H7.3702C7.2862 5.4283 7.106 5.1368 6.8302 4.921C6.5544 4.7052 6.1852 4.5968 5.7233 4.5968C5.0934 4.5968 4.5954 4.8116 4.2292 5.2404C3.8635 5.6696 3.6804 6.259 3.6804 7.009C3.6804 7.7531 3.8635 8.3381 4.2292 8.7639ZM11.0974 8.7639C11.4636 9.1902 11.9617 9.4031 12.5915 9.4031C13.0534 9.4031 13.4226 9.301 13.6984 9.0969C13.9743 8.8933 14.1545 8.614 14.2384 8.26H15.3004C15.1744 8.884 14.8775 9.3733 14.4093 9.7273C13.9415 10.0813 13.3385 10.2581 12.6002 10.2581C11.9762 10.2581 11.4381 10.1219 10.985 9.8489C10.5319 9.5759 10.1823 9.1946 9.9367 8.7058C9.6906 8.2165 9.5676 7.6511 9.5676 7.009C9.5676 6.3611 9.6906 5.7927 9.9367 5.3034C10.1823 4.8146 10.5319 4.4323 10.985 4.1559C11.4381 3.88 11.9762 3.7418 12.6002 3.7418C13.3385 3.7418 13.9415 3.922 14.4093 4.2818C14.8776 4.6422 15.1744 5.1461 15.3004 5.794H14.2384C14.1544 5.4283 13.9742 5.1368 13.6984 4.921C13.4226 4.7052 13.0534 4.5968 12.5915 4.5968C11.9616 4.5968 11.4636 4.8116 11.0974 5.2404C10.7317 5.6696 10.5486 6.259 10.5486 7.009C10.5486 7.7531 10.7317 8.3381 11.0974 8.7639Z" 51826 /> 51827 </svg> 51828 <svg aria-hidden="true" viewBox="0 0 18 14" slot="off"> 51829 <path 51830 d="M5.73219 10.258C5.10819 10.258 4.57009 10.1218 4.11699 9.8488C3.66389 9.5758 3.31429 9.1945 3.06869 8.7057C2.82259 8.2164 2.69958 7.651 2.69958 7.0089C2.69958 6.361 2.82259 5.7926 3.06869 5.3033C3.31429 4.8145 3.66389 4.4322 4.11699 4.1558C4.57009 3.8799 5.10819 3.7417 5.73219 3.7417C6.47049 3.7417 7.07348 3.9219 7.54128 4.2817C8.00958 4.6421 8.30638 5.146 8.43238 5.7939H7.37039C7.28639 5.4282 7.10618 5.1367 6.83039 4.9209C6.55459 4.7051 6.18538 4.5967 5.72348 4.5967C5.09358 4.5967 4.59559 4.8115 4.22939 5.2403C3.86369 5.6695 3.68058 6.2589 3.68058 7.0089C3.68058 7.753 3.86369 8.338 4.22939 8.7638C4.59559 9.1901 5.09368 9.403 5.72348 9.403C6.18538 9.403 6.55459 9.3009 6.83039 9.0968C7.10629 8.8932 7.28649 8.6139 7.37039 8.2599H8.43238C8.30638 8.8839 8.00948 9.3732 7.54128 9.7272C7.07348 10.0812 6.47049 10.258 5.73219 10.258Z" 51831 /> 51832 <path 51833 d="M12.6003 10.258C11.9763 10.258 11.4382 10.1218 10.9851 9.8488C10.532 9.5758 10.1824 9.1945 9.93685 8.7057C9.69075 8.2164 9.56775 7.651 9.56775 7.0089C9.56775 6.361 9.69075 5.7926 9.93685 5.3033C10.1824 4.8145 10.532 4.4322 10.9851 4.1558C11.4382 3.8799 11.9763 3.7417 12.6003 3.7417C13.3386 3.7417 13.9416 3.9219 14.4094 4.2817C14.8777 4.6421 15.1745 5.146 15.3005 5.7939H14.2385C14.1545 5.4282 13.9743 5.1367 13.6985 4.9209C13.4227 4.7051 13.0535 4.5967 12.5916 4.5967C11.9617 4.5967 11.4637 4.8115 11.0975 5.2403C10.7318 5.6695 10.5487 6.2589 10.5487 7.0089C10.5487 7.753 10.7318 8.338 11.0975 8.7638C11.4637 9.1901 11.9618 9.403 12.5916 9.403C13.0535 9.403 13.4227 9.3009 13.6985 9.0968C13.9744 8.8932 14.1546 8.6139 14.2385 8.2599H15.3005C15.1745 8.8839 14.8776 9.3732 14.4094 9.7272C13.9416 10.0812 13.3386 10.258 12.6003 10.258Z" 51834 /> 51835 <path 51836 d="M15.9891 1C16.5465 1 17 1.4535 17 2.011V11.9891C17 12.5465 16.5465 13 15.9891 13H2.0109C1.4535 13 1 12.5465 1 11.9891V2.0109C1 1.4535 1.4535 0.9999 2.0109 0.9999L15.9891 1ZM15.9891 0H2.0109C0.9003 0 0 0.9003 0 2.0109V11.9891C0 13.0997 0.9003 14 2.0109 14H15.9891C17.0997 14 18 13.0997 18 11.9891V2.0109C18 0.9003 17.0997 0 15.9891 0Z" 51837 /> 51838 </svg> 51839 </media-captions-menu-button> 51840 <media-captions-menu 51841 hidden 51842 anchor="auto" 51843 part="bottom captions menu" 51844 disabled="{{disabled}}" 51845 aria-disabled="{{disabled}}" 51846 exportparts="menu-item" 51847 > 51848 <div slot="checked-indicator"> 51849 <style> 51850 .indicator { 51851 position: relative; 51852 top: 1px; 51853 width: 0.9em; 51854 height: auto; 51855 fill: var(--_accent-color); 51856 margin-right: 5px; 51857 } 51858 51859 [aria-checked='false'] .indicator { 51860 display: none; 51861 } 51862 </style> 51863 <svg viewBox="0 0 14 18" class="indicator"> 51864 <path 51865 d="M12.252 3.48c-.115.033-.301.161-.425.291-.059.063-1.407 1.815-2.995 3.894s-2.897 3.79-2.908 3.802c-.013.014-.661-.616-1.672-1.624-.908-.905-1.702-1.681-1.765-1.723-.401-.27-.783-.211-1.176.183a1.285 1.285 0 0 0-.261.342.582.582 0 0 0-.082.35c0 .165.01.205.08.35.075.153.213.296 2.182 2.271 1.156 1.159 2.17 2.159 2.253 2.222.189.143.338.196.539.194.203-.003.412-.104.618-.299.205-.193 6.7-8.693 6.804-8.903a.716.716 0 0 0 .085-.345c.01-.179.005-.203-.062-.339-.124-.252-.45-.531-.746-.639a.784.784 0 0 0-.469-.027" 51866 fill-rule="evenodd" 51867 /> 51868 </svg></div 51869 ></media-captions-menu> 51870 </template> 51871 51872 <template partial="AirplayButton"> 51873 <media-airplay-button part="bottom airplay button" disabled="{{disabled}}" aria-disabled="{{disabled}}"> 51874 <svg viewBox="0 0 18 14" aria-hidden="true" slot="icon"> 51875 <path 51876 d="M16.1383 0H1.8618C0.8335 0 0 0.8335 0 1.8617V10.1382C0 11.1664 0.8335 12 1.8618 12H3.076C3.1204 11.9433 3.1503 11.8785 3.2012 11.826L4.004 11H1.8618C1.3866 11 1 10.6134 1 10.1382V1.8617C1 1.3865 1.3866 0.9999 1.8618 0.9999H16.1383C16.6135 0.9999 17.0001 1.3865 17.0001 1.8617V10.1382C17.0001 10.6134 16.6135 11 16.1383 11H13.9961L14.7989 11.826C14.8499 11.8785 14.8798 11.9432 14.9241 12H16.1383C17.1665 12 18.0001 11.1664 18.0001 10.1382V1.8617C18 0.8335 17.1665 0 16.1383 0Z" 51877 /> 51878 <path 51879 d="M9.55061 8.21903C9.39981 8.06383 9.20001 7.98633 9.00011 7.98633C8.80021 7.98633 8.60031 8.06383 8.44951 8.21903L4.09771 12.697C3.62471 13.1838 3.96961 13.9998 4.64831 13.9998H13.3518C14.0304 13.9998 14.3754 13.1838 13.9023 12.697L9.55061 8.21903Z" 51880 /> 51881 </svg> 51882 </media-airplay-button> 51883 </template> 51884 51885 <template partial="FullscreenButton"> 51886 <media-fullscreen-button part="bottom fullscreen button" disabled="{{disabled}}" aria-disabled="{{disabled}}"> 51887 <svg viewBox="0 0 18 14" aria-hidden="true" slot="enter"> 51888 <path 51889 d="M1.00745 4.39539L1.01445 1.98789C1.01605 1.43049 1.47085 0.978289 2.02835 0.979989L6.39375 0.992589L6.39665 -0.007411L2.03125 -0.020011C0.920646 -0.023211 0.0176463 0.874489 0.0144463 1.98509L0.00744629 4.39539H1.00745Z" 51890 /> 51891 <path 51892 d="M17.0144 2.03431L17.0076 4.39541H18.0076L18.0144 2.03721C18.0176 0.926712 17.1199 0.0237125 16.0093 0.0205125L11.6439 0.0078125L11.641 1.00781L16.0064 1.02041C16.5638 1.02201 17.016 1.47681 17.0144 2.03431Z" 51893 /> 51894 <path 51895 d="M16.9925 9.60498L16.9855 12.0124C16.9839 12.5698 16.5291 13.022 15.9717 13.0204L11.6063 13.0078L11.6034 14.0078L15.9688 14.0204C17.0794 14.0236 17.9823 13.1259 17.9855 12.0153L17.9925 9.60498H16.9925Z" 51896 /> 51897 <path 51898 d="M0.985626 11.9661L0.992426 9.60498H-0.0074737L-0.0142737 11.9632C-0.0174737 13.0738 0.880226 13.9767 1.99083 13.98L6.35623 13.9926L6.35913 12.9926L1.99373 12.98C1.43633 12.9784 0.983926 12.5236 0.985626 11.9661Z" 51899 /> 51900 </svg> 51901 <svg viewBox="0 0 18 14" aria-hidden="true" slot="exit"> 51902 <path 51903 d="M5.39655 -0.0200195L5.38955 2.38748C5.38795 2.94488 4.93315 3.39708 4.37565 3.39538L0.0103463 3.38278L0.00744629 4.38278L4.37285 4.39538C5.48345 4.39858 6.38635 3.50088 6.38965 2.39028L6.39665 -0.0200195H5.39655Z" 51904 /> 51905 <path 51906 d="M12.6411 2.36891L12.6479 0.0078125H11.6479L11.6411 2.36601C11.6379 3.47651 12.5356 4.37951 13.6462 4.38271L18.0116 4.39531L18.0145 3.39531L13.6491 3.38271C13.0917 3.38111 12.6395 2.92641 12.6411 2.36891Z" 51907 /> 51908 <path 51909 d="M12.6034 14.0204L12.6104 11.613C12.612 11.0556 13.0668 10.6034 13.6242 10.605L17.9896 10.6176L17.9925 9.61759L13.6271 9.60499C12.5165 9.60179 11.6136 10.4995 11.6104 11.6101L11.6034 14.0204H12.6034Z" 51910 /> 51911 <path 51912 d="M5.359 11.6315L5.3522 13.9926H6.3522L6.359 11.6344C6.3622 10.5238 5.4645 9.62088 4.3539 9.61758L-0.0115043 9.60498L-0.0144043 10.605L4.351 10.6176C4.9084 10.6192 5.3607 11.074 5.359 11.6315Z" 51913 /> 51914 </svg> 51915 </media-fullscreen-button> 51916 </template> 51917 51918 <template partial="CastButton"> 51919 <media-cast-button part="bottom cast button" disabled="{{disabled}}" aria-disabled="{{disabled}}"> 51920 <svg viewBox="0 0 18 14" aria-hidden="true" slot="enter"> 51921 <path 51922 d="M16.0072 0H2.0291C0.9185 0 0.0181 0.9003 0.0181 2.011V5.5009C0.357 5.5016 0.6895 5.5275 1.0181 5.5669V2.011C1.0181 1.4536 1.4716 1 2.029 1H16.0072C16.5646 1 17.0181 1.4536 17.0181 2.011V11.9891C17.0181 12.5465 16.5646 13 16.0072 13H8.4358C8.4746 13.3286 8.4999 13.6611 8.4999 13.9999H16.0071C17.1177 13.9999 18.018 13.0996 18.018 11.989V2.011C18.0181 0.9003 17.1178 0 16.0072 0ZM0 6.4999V7.4999C3.584 7.4999 6.5 10.4159 6.5 13.9999H7.5C7.5 9.8642 4.1357 6.4999 0 6.4999ZM0 8.7499V9.7499C2.3433 9.7499 4.25 11.6566 4.25 13.9999H5.25C5.25 11.1049 2.895 8.7499 0 8.7499ZM0.0181 11V14H3.0181C3.0181 12.3431 1.675 11 0.0181 11Z" 51923 /> 51924 </svg> 51925 <svg viewBox="0 0 18 14" aria-hidden="true" slot="exit"> 51926 <path 51927 d="M15.9891 0H2.01103C0.900434 0 3.35947e-05 0.9003 3.35947e-05 2.011V5.5009C0.338934 5.5016 0.671434 5.5275 1.00003 5.5669V2.011C1.00003 1.4536 1.45353 1 2.01093 1H15.9891C16.5465 1 17 1.4536 17 2.011V11.9891C17 12.5465 16.5465 13 15.9891 13H8.41773C8.45653 13.3286 8.48183 13.6611 8.48183 13.9999H15.989C17.0996 13.9999 17.9999 13.0996 17.9999 11.989V2.011C18 0.9003 17.0997 0 15.9891 0ZM-0.0180664 6.4999V7.4999C3.56593 7.4999 6.48193 10.4159 6.48193 13.9999H7.48193C7.48193 9.8642 4.11763 6.4999 -0.0180664 6.4999ZM-0.0180664 8.7499V9.7499C2.32523 9.7499 4.23193 11.6566 4.23193 13.9999H5.23193C5.23193 11.1049 2.87693 8.7499 -0.0180664 8.7499ZM3.35947e-05 11V14H3.00003C3.00003 12.3431 1.65693 11 3.35947e-05 11Z" 51928 /> 51929 <path d="M2.15002 5.634C5.18352 6.4207 7.57252 8.8151 8.35282 11.8499H15.8501V2.1499H2.15002V5.634Z" /> 51930 </svg> 51931 </media-cast-button> 51932 </template> 51933 51934 <template partial="LiveButton"> 51935 <media-live-button part="{{section ?? 'top'}} live button" disabled="{{disabled}}" aria-disabled="{{disabled}}"> 51936 <span slot="text">Live</span> 51937 </media-live-button> 51938 </template> 51939 51940 <template partial="PlaybackRateMenu"> 51941 <media-playback-rate-menu-button part="bottom playback-rate button"></media-playback-rate-menu-button> 51942 <media-playback-rate-menu 51943 hidden 51944 anchor="auto" 51945 rates="{{playbackrates}}" 51946 exportparts="menu-item" 51947 part="bottom playback-rate menu" 51948 disabled="{{disabled}}" 51949 aria-disabled="{{disabled}}" 51950 ></media-playback-rate-menu> 51951 </template> 51952 51953 <template partial="VolumeRange"> 51954 <media-volume-range 51955 part="bottom volume range" 51956 disabled="{{disabled}}" 51957 aria-disabled="{{disabled}}" 51958 ></media-volume-range> 51959 </template> 51960 51961 <template partial="TimeDisplay"> 51962 <media-time-display 51963 remaining="{{defaultshowremainingtime}}" 51964 showduration="{{!hideduration}}" 51965 part="bottom time display" 51966 disabled="{{disabled}}" 51967 aria-disabled="{{disabled}}" 51968 ></media-time-display> 51969 </template> 51970 51971 <template partial="TimeRange"> 51972 <media-time-range part="bottom time range" disabled="{{disabled}}" aria-disabled="{{disabled}}"> 51973 <media-preview-thumbnail slot="preview"></media-preview-thumbnail> 51974 <media-preview-chapter-display slot="preview"></media-preview-chapter-display> 51975 <media-preview-time-display slot="preview"></media-preview-time-display> 51976 <div slot="preview" part="arrow"></div> 51977 </media-time-range> 51978 </template> 51979 51980 <template partial="AudioTrackMenu"> 51981 <media-audio-track-menu-button part="bottom audio-track button"> 51982 <svg aria-hidden="true" slot="icon" viewBox="0 0 18 16"> 51983 <path d="M9 15A7 7 0 1 1 9 1a7 7 0 0 1 0 14Zm0 1A8 8 0 1 0 9 0a8 8 0 0 0 0 16Z" /> 51984 <path 51985 d="M5.2 6.3a.5.5 0 0 1 .5.5v2.4a.5.5 0 1 1-1 0V6.8a.5.5 0 0 1 .5-.5Zm2.4-2.4a.5.5 0 0 1 .5.5v7.2a.5.5 0 0 1-1 0V4.4a.5.5 0 0 1 .5-.5ZM10 5.5a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5Zm2.4-.8a.5.5 0 0 1 .5.5v5.6a.5.5 0 0 1-1 0V5.2a.5.5 0 0 1 .5-.5Z" 51986 /> 51987 </svg> 51988 </media-audio-track-menu-button> 51989 <media-audio-track-menu 51990 hidden 51991 anchor="auto" 51992 part="bottom audio-track menu" 51993 disabled="{{disabled}}" 51994 aria-disabled="{{disabled}}" 51995 exportparts="menu-item" 51996 > 51997 <div slot="checked-indicator"> 51998 <style> 51999 .indicator { 52000 position: relative; 52001 top: 1px; 52002 width: 0.9em; 52003 height: auto; 52004 fill: var(--_accent-color); 52005 margin-right: 5px; 52006 } 52007 52008 [aria-checked='false'] .indicator { 52009 display: none; 52010 } 52011 </style> 52012 <svg viewBox="0 0 14 18" class="indicator"> 52013 <path 52014 d="M12.252 3.48c-.115.033-.301.161-.425.291-.059.063-1.407 1.815-2.995 3.894s-2.897 3.79-2.908 3.802c-.013.014-.661-.616-1.672-1.624-.908-.905-1.702-1.681-1.765-1.723-.401-.27-.783-.211-1.176.183a1.285 1.285 0 0 0-.261.342.582.582 0 0 0-.082.35c0 .165.01.205.08.35.075.153.213.296 2.182 2.271 1.156 1.159 2.17 2.159 2.253 2.222.189.143.338.196.539.194.203-.003.412-.104.618-.299.205-.193 6.7-8.693 6.804-8.903a.716.716 0 0 0 .085-.345c.01-.179.005-.203-.062-.339-.124-.252-.45-.531-.746-.639a.784.784 0 0 0-.469-.027" 52015 fill-rule="evenodd" 52016 /> 52017 </svg> 52018 </div> 52019 </media-audio-track-menu> 52020 </template> 52021 52022 <template partial="RenditionMenu"> 52023 <media-rendition-menu-button part="bottom rendition button"> 52024 <svg aria-hidden="true" slot="icon" viewBox="0 0 18 14"> 52025 <path 52026 d="M2.25 9a2 2 0 1 0 0-4 2 2 0 0 0 0 4ZM9 9a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm6.75 0a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z" 52027 /> 52028 </svg> 52029 </media-rendition-menu-button> 52030 <media-rendition-menu 52031 hidden 52032 anchor="auto" 52033 part="bottom rendition menu" 52034 disabled="{{disabled}}" 52035 aria-disabled="{{disabled}}" 52036 > 52037 <div slot="checked-indicator"> 52038 <style> 52039 .indicator { 52040 position: relative; 52041 top: 1px; 52042 width: 0.9em; 52043 height: auto; 52044 fill: var(--_accent-color); 52045 margin-right: 5px; 52046 } 52047 52048 [aria-checked='false'] .indicator { 52049 display: none; 52050 } 52051 </style> 52052 <svg viewBox="0 0 14 18" class="indicator"> 52053 <path 52054 d="M12.252 3.48c-.115.033-.301.161-.425.291-.059.063-1.407 1.815-2.995 3.894s-2.897 3.79-2.908 3.802c-.013.014-.661-.616-1.672-1.624-.908-.905-1.702-1.681-1.765-1.723-.401-.27-.783-.211-1.176.183a1.285 1.285 0 0 0-.261.342.582.582 0 0 0-.082.35c0 .165.01.205.08.35.075.153.213.296 2.182 2.271 1.156 1.159 2.17 2.159 2.253 2.222.189.143.338.196.539.194.203-.003.412-.104.618-.299.205-.193 6.7-8.693 6.804-8.903a.716.716 0 0 0 .085-.345c.01-.179.005-.203-.062-.339-.124-.252-.45-.531-.746-.639a.784.784 0 0 0-.469-.027" 52055 fill-rule="evenodd" 52056 /> 52057 </svg> 52058 </div> 52059 </media-rendition-menu> 52060 </template> 52061 52062 <media-controller 52063 part="controller" 52064 defaultstreamtype="{{defaultstreamtype ?? 'on-demand'}}" 52065 breakpoints="sm:470" 52066 gesturesdisabled="{{disabled}}" 52067 hotkeys="{{hotkeys}}" 52068 nohotkeys="{{nohotkeys}}" 52069 novolumepref="{{novolumepref}}" 52070 audio="{{audio}}" 52071 noautoseektolive="{{noautoseektolive}}" 52072 defaultsubtitles="{{defaultsubtitles}}" 52073 defaultduration="{{defaultduration ?? false}}" 52074 keyboardforwardseekoffset="{{forwardseekoffset}}" 52075 keyboardbackwardseekoffset="{{backwardseekoffset}}" 52076 exportparts="layer, media-layer, poster-layer, vertical-layer, centered-layer, gesture-layer" 52077 style="--_pre-playback-place:{{preplaybackplace ?? 'center'}}" 52078 > 52079 <slot name="media" slot="media"></slot> 52080 <slot name="poster" slot="poster"></slot> 52081 52082 <media-loading-indicator slot="centered-chrome" noautohide></media-loading-indicator> 52083 52084 <template if="!audio"> 52085 <!-- Pre-playback UI --> 52086 <!-- same for both on-demand and live --> 52087 <div slot="centered-chrome" class="center-controls pre-playback"> 52088 <template if="!breakpointsm">{{>PlayButton section="center"}}</template> 52089 <template if="breakpointsm">{{>PrePlayButton section="center"}}</template> 52090 </div> 52091 52092 <!-- Autoplay centered unmute button --> 52093 <!-- 52094 todo: figure out how show this with available state variables 52095 needs to show when: 52096 - autoplay is enabled 52097 - playback has been successful 52098 - audio is muted 52099 - in place / instead of the pre-plaback play button 52100 - not to show again after user has interacted with this button 52101 - OR user has interacted with the mute button in the control bar 52102 --> 52103 <!-- 52104 There should be a >MuteButton to the left of the "Unmute" text, but a templating bug 52105 makes it appear even if commented out in the markup, add it back when code is un-commented 52106 --> 52107 <!-- <div slot="centered-chrome" class="autoplay-unmute"> 52108 <div role="button" class="autoplay-unmute-btn">Unmute</div> 52109 </div> --> 52110 52111 <template if="streamtype == 'on-demand'"> 52112 <template if="breakpointsm"> 52113 <media-control-bar part="control-bar top" slot="top-chrome">{{>TitleDisplay}} </media-control-bar> 52114 </template> 52115 {{>TimeRange}} 52116 <media-control-bar part="control-bar bottom"> 52117 {{>PlayButton}} {{>SeekBackwardButton}} {{>SeekForwardButton}} {{>TimeDisplay}} {{>MuteButton}} 52118 {{>VolumeRange}} 52119 <div class="spacer"></div> 52120 {{>RenditionMenu}} {{>PlaybackRateMenu}} {{>AudioTrackMenu}} {{>CaptionsMenu}} {{>AirplayButton}} 52121 {{>CastButton}} {{>PipButton}} {{>FullscreenButton}} 52122 </media-control-bar> 52123 </template> 52124 52125 <template if="streamtype == 'live'"> 52126 <media-control-bar part="control-bar top" slot="top-chrome"> 52127 {{>LiveButton}} 52128 <template if="breakpointsm"> {{>TitleDisplay}} </template> 52129 </media-control-bar> 52130 <template if="targetlivewindow > 0">{{>TimeRange}}</template> 52131 <media-control-bar part="control-bar bottom"> 52132 {{>PlayButton}} 52133 <template if="targetlivewindow > 0">{{>SeekBackwardButton}} {{>SeekForwardButton}}</template> 52134 {{>MuteButton}} {{>VolumeRange}} 52135 <div class="spacer"></div> 52136 {{>RenditionMenu}} {{>AudioTrackMenu}} {{>CaptionsMenu}} {{>AirplayButton}} {{>CastButton}} {{>PipButton}} 52137 {{>FullscreenButton}} 52138 </media-control-bar> 52139 </template> 52140 </template> 52141 52142 <template if="audio"> 52143 <template if="streamtype == 'on-demand'"> 52144 <template if="title"> 52145 <media-control-bar part="control-bar top">{{>TitleDisplay}}</media-control-bar> 52146 </template> 52147 <media-control-bar part="control-bar bottom"> 52148 {{>PlayButton}} 52149 <template if="breakpointsm"> {{>SeekBackwardButton}} {{>SeekForwardButton}} </template> 52150 {{>MuteButton}} 52151 <template if="breakpointsm">{{>VolumeRange}}</template> 52152 {{>TimeDisplay}} {{>TimeRange}} 52153 <template if="breakpointsm">{{>PlaybackRateMenu}}</template> 52154 {{>AirplayButton}} {{>CastButton}} 52155 </media-control-bar> 52156 </template> 52157 52158 <template if="streamtype == 'live'"> 52159 <template if="title"> 52160 <media-control-bar part="control-bar top">{{>TitleDisplay}}</media-control-bar> 52161 </template> 52162 <media-control-bar part="control-bar bottom"> 52163 {{>PlayButton}} {{>LiveButton section="bottom"}} {{>MuteButton}} 52164 <template if="breakpointsm"> 52165 {{>VolumeRange}} 52166 <template if="targetlivewindow > 0"> {{>SeekBackwardButton}} {{>SeekForwardButton}} </template> 52167 </template> 52168 <template if="targetlivewindow > 0"> {{>TimeDisplay}} {{>TimeRange}} </template> 52169 <template if="!targetlivewindow"><div class="spacer"></div></template> 52170 {{>AirplayButton}} {{>CastButton}} 52171 </media-control-bar> 52172 </template> 52173 </template> 52174 52175 <slot></slot> 52176 </media-controller> 52177</template> 52178`; 52179var Ve3 = C3.createElement("template"); 52180"innerHTML" in Ve3 && (Ve3.innerHTML = It4); 52181var Dt4; 52182var Vt4; 52183var ge4 = class extends MediaThemeElement { 52184}; 52185ge4.template = (Vt4 = (Dt4 = Ve3.content) == null ? void 0 : Dt4.children) == null ? void 0 : Vt4[0]; 52186p.customElements.get("media-theme-gerwig") || p.customElements.define("media-theme-gerwig", ge4); 52187var Pa2 = "gerwig"; 52188var w3 = { SRC: "src", POSTER: "poster" }; 52189var n = { STYLE: "style", DEFAULT_HIDDEN_CAPTIONS: "default-hidden-captions", PRIMARY_COLOR: "primary-color", SECONDARY_COLOR: "secondary-color", ACCENT_COLOR: "accent-color", FORWARD_SEEK_OFFSET: "forward-seek-offset", BACKWARD_SEEK_OFFSET: "backward-seek-offset", PLAYBACK_TOKEN: "playback-token", THUMBNAIL_TOKEN: "thumbnail-token", STORYBOARD_TOKEN: "storyboard-token", DRM_TOKEN: "drm-token", STORYBOARD_SRC: "storyboard-src", THUMBNAIL_TIME: "thumbnail-time", AUDIO: "audio", NOHOTKEYS: "nohotkeys", HOTKEYS: "hotkeys", PLAYBACK_RATES: "playbackrates", DEFAULT_SHOW_REMAINING_TIME: "default-show-remaining-time", DEFAULT_DURATION: "default-duration", TITLE: "title", PLACEHOLDER: "placeholder", THEME: "theme", DEFAULT_STREAM_TYPE: "default-stream-type", TARGET_LIVE_WINDOW: "target-live-window", EXTRA_SOURCE_PARAMS: "extra-source-params", NO_VOLUME_PREF: "no-volume-pref", CAST_RECEIVER: "cast-receiver", NO_TOOLTIPS: "no-tooltips" }; 52190var Be3 = ["audio", "backwardseekoffset", "defaultduration", "defaultshowremainingtime", "defaultsubtitles", "noautoseektolive", "disabled", "exportparts", "forwardseekoffset", "hideduration", "hotkeys", "nohotkeys", "playbackrates", "defaultstreamtype", "streamtype", "style", "targetlivewindow", "template", "title", "novolumepref"]; 52191function Ia2(t2, a2) { 52192 var i3; 52193 return { src: !t2.playbackId && t2.src, playbackId: t2.playbackId, hasSrc: !!t2.playbackId || !!t2.src || !!t2.currentSrc, poster: t2.poster, storyboard: t2.storyboard, storyboardSrc: t2.getAttribute(n.STORYBOARD_SRC), placeholder: t2.getAttribute("placeholder"), themeTemplate: Da2(t2), thumbnailTime: !t2.tokens.thumbnail && t2.thumbnailTime, autoplay: t2.autoplay, crossOrigin: t2.crossOrigin, loop: t2.loop, noHotKeys: t2.hasAttribute(n.NOHOTKEYS), hotKeys: t2.getAttribute(n.HOTKEYS), muted: t2.muted, paused: t2.paused, preload: t2.preload, envKey: t2.envKey, preferCmcd: t2.preferCmcd, debug: t2.debug, disableTracking: t2.disableTracking, disableCookies: t2.disableCookies, tokens: t2.tokens, beaconCollectionDomain: t2.beaconCollectionDomain, maxResolution: t2.maxResolution, minResolution: t2.minResolution, programStartTime: t2.programStartTime, programEndTime: t2.programEndTime, assetStartTime: t2.assetStartTime, assetEndTime: t2.assetEndTime, renditionOrder: t2.renditionOrder, metadata: t2.metadata, playerSoftwareName: t2.playerSoftwareName, playerSoftwareVersion: t2.playerSoftwareVersion, startTime: t2.startTime, preferPlayback: t2.preferPlayback, audio: t2.audio, defaultStreamType: t2.defaultStreamType, targetLiveWindow: t2.getAttribute(o.TARGET_LIVE_WINDOW), streamType: Q4(t2.getAttribute(o.STREAM_TYPE)), primaryColor: t2.getAttribute(n.PRIMARY_COLOR), secondaryColor: t2.getAttribute(n.SECONDARY_COLOR), accentColor: t2.getAttribute(n.ACCENT_COLOR), forwardSeekOffset: t2.forwardSeekOffset, backwardSeekOffset: t2.backwardSeekOffset, defaultHiddenCaptions: t2.defaultHiddenCaptions, defaultDuration: t2.defaultDuration, defaultShowRemainingTime: t2.defaultShowRemainingTime, hideDuration: Va(t2), playbackRates: t2.getAttribute(n.PLAYBACK_RATES), customDomain: (i3 = t2.getAttribute(o.CUSTOM_DOMAIN)) != null ? i3 : void 0, title: t2.getAttribute(n.TITLE), novolumepref: t2.hasAttribute(n.NO_VOLUME_PREF), castReceiver: t2.castReceiver, ...a2, extraSourceParams: t2.extraSourceParams }; 52194} 52195function Da2(t2) { 52196 var e, i3; 52197 let a2 = t2.theme; 52198 if (a2) { 52199 let r10 = (i3 = (e = t2.getRootNode()) == null ? void 0 : e.getElementById) == null ? void 0 : i3.call(e, a2); 52200 if (r10 && r10 instanceof HTMLTemplateElement) return r10; 52201 a2.startsWith("media-theme-") || (a2 = `media-theme-${a2}`); 52202 let o2 = p.customElements.get(a2); 52203 if (o2 != null && o2.template) return o2.template; 52204 } 52205} 52206function Va(t2) { 52207 var e; 52208 let a2 = (e = t2.mediaController) == null ? void 0 : e.querySelector("media-time-display"); 52209 return a2 && getComputedStyle(a2).getPropertyValue("--media-duration-display-display").trim() === "none"; 52210} 52211function Ut4(t2) { 52212 let a2 = t2.hasAttribute(n.TITLE) ? { video_title: t2.getAttribute(n.TITLE) } : {}; 52213 return t2.getAttributeNames().filter((e) => e.startsWith("metadata-")).reduce((e, i3) => { 52214 let r10 = t2.getAttribute(i3); 52215 return r10 !== null && (e[i3.replace(/^metadata-/, "").replace(/-/g, "_")] = r10), e; 52216 }, a2); 52217} 52218var Ha = Object.values(o); 52219var Ka = Object.values(w3); 52220var Ua = Object.values(n); 52221var Ba = ce3(); 52222var $a = "mux-player"; 52223var Bt3 = { dialog: void 0, isDialogOpen: false }; 52224var Fa = { redundant_streams: true }; 52225var re4; 52226var oe3; 52227var V4; 52228var ne4; 52229var F3; 52230var M3; 52231var D3; 52232var ve3; 52233var $t3; 52234var se3; 52235var $e4; 52236var P2; 52237var $4; 52238var Te3; 52239var Ft3; 52240var Ee3; 52241var Yt3; 52242var Ae4; 52243var Wt3; 52244var Ce4; 52245var Zt3; 52246var ie4 = class extends Ne2 { 52247 constructor() { 52248 super(); 52249 b2(this, M3); 52250 b2(this, ve3); 52251 b2(this, se3); 52252 b2(this, P2); 52253 b2(this, Te3); 52254 b2(this, Ee3); 52255 b2(this, Ae4); 52256 b2(this, Ce4); 52257 b2(this, re4, false); 52258 b2(this, oe3, {}); 52259 b2(this, V4, true); 52260 b2(this, ne4, new me3(this, "hotkeys")); 52261 b2(this, F3, { ...Bt3, onCloseErrorDialog: () => h2(this, se3, $e4).call(this, { dialog: void 0, isDialogOpen: false }), onInitFocusDialog: (e) => { 52262 _e4(this, C3.activeElement) || e.preventDefault(); 52263 } }); 52264 this.attachShadow({ mode: "open" }), h2(this, ve3, $t3).call(this), this.isConnected && h2(this, M3, D3).call(this); 52265 } 52266 static get observedAttributes() { 52267 var e; 52268 return [...(e = Ne2.observedAttributes) != null ? e : [], ...Ka, ...Ha, ...Ua]; 52269 } 52270 get mediaTheme() { 52271 var e; 52272 return (e = this.shadowRoot) == null ? void 0 : e.querySelector("media-theme"); 52273 } 52274 get mediaController() { 52275 var e, i3; 52276 return (i3 = (e = this.mediaTheme) == null ? void 0 : e.shadowRoot) == null ? void 0 : i3.querySelector("media-controller"); 52277 } 52278 connectedCallback() { 52279 var i3; 52280 let e = (i3 = this.shadowRoot) == null ? void 0 : i3.querySelector("mux-video"); 52281 e && (e.metadata = Ut4(this)); 52282 } 52283 attributeChangedCallback(e, i3, r10) { 52284 switch (h2(this, M3, D3).call(this), super.attributeChangedCallback(e, i3, r10), e) { 52285 case n.HOTKEYS: 52286 u2(this, ne4).value = r10; 52287 break; 52288 case n.THUMBNAIL_TIME: { 52289 r10 != null && this.tokens.thumbnail && _2(E("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.")); 52290 break; 52291 } 52292 case n.THUMBNAIL_TOKEN: { 52293 if (r10) { 52294 let d2 = Q2(r10); 52295 if (d2) { 52296 let { aud: l2 } = d2, c3 = oe.THUMBNAIL; 52297 l2 !== c3 && _2(E("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.").format({ aud: l2, expectedAud: c3, tokenNamePrefix: "thumbnail" })); 52298 } 52299 } 52300 break; 52301 } 52302 case n.STORYBOARD_TOKEN: { 52303 if (r10) { 52304 let d2 = Q2(r10); 52305 if (d2) { 52306 let { aud: l2 } = d2, c3 = oe.STORYBOARD; 52307 l2 !== c3 && _2(E("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.").format({ aud: l2, expectedAud: c3, tokenNamePrefix: "storyboard" })); 52308 } 52309 } 52310 break; 52311 } 52312 case n.DRM_TOKEN: { 52313 if (r10) { 52314 let d2 = Q2(r10); 52315 if (d2) { 52316 let { aud: l2 } = d2, c3 = oe.DRM; 52317 l2 !== c3 && _2(E("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.").format({ aud: l2, expectedAud: c3, tokenNamePrefix: "drm" })); 52318 } 52319 } 52320 break; 52321 } 52322 case o.PLAYBACK_ID: { 52323 r10 != null && r10.includes("?token") && E3(E("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({ playbackId: r10 })); 52324 break; 52325 } 52326 case o.STREAM_TYPE: 52327 r10 && ![D2.LIVE, D2.ON_DEMAND, D2.UNKNOWN].includes(r10) ? ["ll-live", "live:dvr", "ll-live:dvr"].includes(this.streamType) ? this.targetLiveWindow = r10.includes("dvr") ? Number.POSITIVE_INFINITY : 0 : Me4({ file: "invalid-stream-type.md", message: E("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand` or `live`").format({ streamType: this.streamType }) }) : r10 === D2.LIVE ? this.getAttribute(n.TARGET_LIVE_WINDOW) == null && (this.targetLiveWindow = 0) : this.targetLiveWindow = Number.NaN; 52328 } 52329 [o.PLAYBACK_ID, w3.SRC, n.PLAYBACK_TOKEN].includes(e) && i3 !== r10 && R4(this, F3, { ...u2(this, F3), ...Bt3 }), h2(this, P2, $4).call(this, { [gt3(e)]: r10 }); 52330 } 52331 get preferCmcd() { 52332 var e; 52333 return (e = this.getAttribute(o.PREFER_CMCD)) != null ? e : void 0; 52334 } 52335 set preferCmcd(e) { 52336 e !== this.preferCmcd && (e ? Ut2.includes(e) ? this.setAttribute(o.PREFER_CMCD, e) : _2(`Invalid value for preferCmcd. Must be one of ${Ut2.join()}`) : this.removeAttribute(o.PREFER_CMCD)); 52337 } 52338 get hasPlayed() { 52339 var e, i3; 52340 return (i3 = (e = this.mediaController) == null ? void 0 : e.hasAttribute(MediaUIAttributes.MEDIA_HAS_PLAYED)) != null ? i3 : false; 52341 } 52342 get inLiveWindow() { 52343 var e; 52344 return (e = this.mediaController) == null ? void 0 : e.hasAttribute(MediaUIAttributes.MEDIA_TIME_IS_LIVE); 52345 } 52346 get _hls() { 52347 var e; 52348 return (e = this.media) == null ? void 0 : e._hls; 52349 } 52350 get mux() { 52351 var e; 52352 return (e = this.media) == null ? void 0 : e.mux; 52353 } 52354 get theme() { 52355 var e; 52356 return (e = this.getAttribute(n.THEME)) != null ? e : Pa2; 52357 } 52358 set theme(e) { 52359 this.setAttribute(n.THEME, `${e}`); 52360 } 52361 get themeProps() { 52362 let e = this.mediaTheme; 52363 if (!e) return; 52364 let i3 = {}; 52365 for (let r10 of e.getAttributeNames()) { 52366 if (Be3.includes(r10)) continue; 52367 let o2 = e.getAttribute(r10); 52368 i3[ue3(r10)] = o2 === "" ? true : o2; 52369 } 52370 return i3; 52371 } 52372 set themeProps(e) { 52373 var r10, o2; 52374 h2(this, M3, D3).call(this); 52375 let i3 = { ...this.themeProps, ...e }; 52376 for (let d2 in i3) { 52377 if (Be3.includes(d2)) continue; 52378 let l2 = e == null ? void 0 : e[d2]; 52379 typeof l2 == "boolean" || l2 == null ? (r10 = this.mediaTheme) == null || r10.toggleAttribute(le4(d2), !!l2) : (o2 = this.mediaTheme) == null || o2.setAttribute(le4(d2), l2); 52380 } 52381 } 52382 get playbackId() { 52383 var e; 52384 return (e = this.getAttribute(o.PLAYBACK_ID)) != null ? e : void 0; 52385 } 52386 set playbackId(e) { 52387 e ? this.setAttribute(o.PLAYBACK_ID, e) : this.removeAttribute(o.PLAYBACK_ID); 52388 } 52389 get src() { 52390 var e, i3; 52391 return this.playbackId ? (e = B4(this, w3.SRC)) != null ? e : void 0 : (i3 = this.getAttribute(w3.SRC)) != null ? i3 : void 0; 52392 } 52393 set src(e) { 52394 e ? this.setAttribute(w3.SRC, e) : this.removeAttribute(w3.SRC); 52395 } 52396 get poster() { 52397 var r10; 52398 let e = this.getAttribute(w3.POSTER); 52399 if (e != null) return e; 52400 let { tokens: i3 } = this; 52401 if (i3.playback && !i3.thumbnail) { 52402 _2("Missing expected thumbnail token. No poster image will be shown"); 52403 return; 52404 } 52405 if (this.playbackId && !this.audio) return bt4(this.playbackId, { customDomain: this.customDomain, thumbnailTime: (r10 = this.thumbnailTime) != null ? r10 : this.startTime, programTime: this.programStartTime, token: i3.thumbnail }); 52406 } 52407 set poster(e) { 52408 e || e === "" ? this.setAttribute(w3.POSTER, e) : this.removeAttribute(w3.POSTER); 52409 } 52410 get storyboardSrc() { 52411 var e; 52412 return (e = this.getAttribute(n.STORYBOARD_SRC)) != null ? e : void 0; 52413 } 52414 set storyboardSrc(e) { 52415 e ? this.setAttribute(n.STORYBOARD_SRC, e) : this.removeAttribute(n.STORYBOARD_SRC); 52416 } 52417 get storyboard() { 52418 let { tokens: e } = this; 52419 if (this.storyboardSrc && !e.storyboard) return this.storyboardSrc; 52420 if (!(this.audio || !this.playbackId || !this.streamType || [D2.LIVE, D2.UNKNOWN].includes(this.streamType) || e.playback && !e.storyboard)) return ht3(this.playbackId, { customDomain: this.customDomain, token: e.storyboard, programStartTime: this.programStartTime, programEndTime: this.programEndTime }); 52421 } 52422 get audio() { 52423 return this.hasAttribute(n.AUDIO); 52424 } 52425 set audio(e) { 52426 if (!e) { 52427 this.removeAttribute(n.AUDIO); 52428 return; 52429 } 52430 this.setAttribute(n.AUDIO, ""); 52431 } 52432 get hotkeys() { 52433 return u2(this, ne4); 52434 } 52435 get nohotkeys() { 52436 return this.hasAttribute(n.NOHOTKEYS); 52437 } 52438 set nohotkeys(e) { 52439 if (!e) { 52440 this.removeAttribute(n.NOHOTKEYS); 52441 return; 52442 } 52443 this.setAttribute(n.NOHOTKEYS, ""); 52444 } 52445 get thumbnailTime() { 52446 return T2(this.getAttribute(n.THUMBNAIL_TIME)); 52447 } 52448 set thumbnailTime(e) { 52449 this.setAttribute(n.THUMBNAIL_TIME, `${e}`); 52450 } 52451 get title() { 52452 var e; 52453 return (e = this.getAttribute(n.TITLE)) != null ? e : ""; 52454 } 52455 set title(e) { 52456 e !== this.title && (e ? this.setAttribute(n.TITLE, e) : this.removeAttribute("title"), super.title = e); 52457 } 52458 get placeholder() { 52459 var e; 52460 return (e = B4(this, n.PLACEHOLDER)) != null ? e : ""; 52461 } 52462 set placeholder(e) { 52463 this.setAttribute(n.PLACEHOLDER, `${e}`); 52464 } 52465 get primaryColor() { 52466 var i3, r10; 52467 let e = this.getAttribute(n.PRIMARY_COLOR); 52468 if (e != null || this.mediaTheme && (e = (r10 = (i3 = p.getComputedStyle(this.mediaTheme)) == null ? void 0 : i3.getPropertyValue("--_primary-color")) == null ? void 0 : r10.trim(), e)) return e; 52469 } 52470 set primaryColor(e) { 52471 this.setAttribute(n.PRIMARY_COLOR, `${e}`); 52472 } 52473 get secondaryColor() { 52474 var i3, r10; 52475 let e = this.getAttribute(n.SECONDARY_COLOR); 52476 if (e != null || this.mediaTheme && (e = (r10 = (i3 = p.getComputedStyle(this.mediaTheme)) == null ? void 0 : i3.getPropertyValue("--_secondary-color")) == null ? void 0 : r10.trim(), e)) return e; 52477 } 52478 set secondaryColor(e) { 52479 this.setAttribute(n.SECONDARY_COLOR, `${e}`); 52480 } 52481 get accentColor() { 52482 var i3, r10; 52483 let e = this.getAttribute(n.ACCENT_COLOR); 52484 if (e != null || this.mediaTheme && (e = (r10 = (i3 = p.getComputedStyle(this.mediaTheme)) == null ? void 0 : i3.getPropertyValue("--_accent-color")) == null ? void 0 : r10.trim(), e)) return e; 52485 } 52486 set accentColor(e) { 52487 this.setAttribute(n.ACCENT_COLOR, `${e}`); 52488 } 52489 get defaultShowRemainingTime() { 52490 return this.hasAttribute(n.DEFAULT_SHOW_REMAINING_TIME); 52491 } 52492 set defaultShowRemainingTime(e) { 52493 e ? this.setAttribute(n.DEFAULT_SHOW_REMAINING_TIME, "") : this.removeAttribute(n.DEFAULT_SHOW_REMAINING_TIME); 52494 } 52495 get playbackRates() { 52496 if (this.hasAttribute(n.PLAYBACK_RATES)) return this.getAttribute(n.PLAYBACK_RATES).trim().split(/\s*,?\s+/).map((e) => Number(e)).filter((e) => !Number.isNaN(e)).sort((e, i3) => e - i3); 52497 } 52498 set playbackRates(e) { 52499 if (!e) { 52500 this.removeAttribute(n.PLAYBACK_RATES); 52501 return; 52502 } 52503 this.setAttribute(n.PLAYBACK_RATES, e.join(" ")); 52504 } 52505 get forwardSeekOffset() { 52506 var e; 52507 return (e = T2(this.getAttribute(n.FORWARD_SEEK_OFFSET))) != null ? e : 10; 52508 } 52509 set forwardSeekOffset(e) { 52510 this.setAttribute(n.FORWARD_SEEK_OFFSET, `${e}`); 52511 } 52512 get backwardSeekOffset() { 52513 var e; 52514 return (e = T2(this.getAttribute(n.BACKWARD_SEEK_OFFSET))) != null ? e : 10; 52515 } 52516 set backwardSeekOffset(e) { 52517 this.setAttribute(n.BACKWARD_SEEK_OFFSET, `${e}`); 52518 } 52519 get defaultHiddenCaptions() { 52520 return this.hasAttribute(n.DEFAULT_HIDDEN_CAPTIONS); 52521 } 52522 set defaultHiddenCaptions(e) { 52523 e ? this.setAttribute(n.DEFAULT_HIDDEN_CAPTIONS, "") : this.removeAttribute(n.DEFAULT_HIDDEN_CAPTIONS); 52524 } 52525 get defaultDuration() { 52526 return T2(this.getAttribute(n.DEFAULT_DURATION)); 52527 } 52528 set defaultDuration(e) { 52529 e == null ? this.removeAttribute(n.DEFAULT_DURATION) : this.setAttribute(n.DEFAULT_DURATION, `${e}`); 52530 } 52531 get playerSoftwareName() { 52532 var e; 52533 return (e = this.getAttribute(o.PLAYER_SOFTWARE_NAME)) != null ? e : $a; 52534 } 52535 get playerSoftwareVersion() { 52536 var e; 52537 return (e = this.getAttribute(o.PLAYER_SOFTWARE_VERSION)) != null ? e : Ba; 52538 } 52539 get beaconCollectionDomain() { 52540 var e; 52541 return (e = this.getAttribute(o.BEACON_COLLECTION_DOMAIN)) != null ? e : void 0; 52542 } 52543 set beaconCollectionDomain(e) { 52544 e !== this.beaconCollectionDomain && (e ? this.setAttribute(o.BEACON_COLLECTION_DOMAIN, e) : this.removeAttribute(o.BEACON_COLLECTION_DOMAIN)); 52545 } 52546 get maxResolution() { 52547 var e; 52548 return (e = this.getAttribute(o.MAX_RESOLUTION)) != null ? e : void 0; 52549 } 52550 set maxResolution(e) { 52551 e !== this.maxResolution && (e ? this.setAttribute(o.MAX_RESOLUTION, e) : this.removeAttribute(o.MAX_RESOLUTION)); 52552 } 52553 get minResolution() { 52554 var e; 52555 return (e = this.getAttribute(o.MIN_RESOLUTION)) != null ? e : void 0; 52556 } 52557 set minResolution(e) { 52558 e !== this.minResolution && (e ? this.setAttribute(o.MIN_RESOLUTION, e) : this.removeAttribute(o.MIN_RESOLUTION)); 52559 } 52560 get renditionOrder() { 52561 var e; 52562 return (e = this.getAttribute(o.RENDITION_ORDER)) != null ? e : void 0; 52563 } 52564 set renditionOrder(e) { 52565 e !== this.renditionOrder && (e ? this.setAttribute(o.RENDITION_ORDER, e) : this.removeAttribute(o.RENDITION_ORDER)); 52566 } 52567 get programStartTime() { 52568 return T2(this.getAttribute(o.PROGRAM_START_TIME)); 52569 } 52570 set programStartTime(e) { 52571 e == null ? this.removeAttribute(o.PROGRAM_START_TIME) : this.setAttribute(o.PROGRAM_START_TIME, `${e}`); 52572 } 52573 get programEndTime() { 52574 return T2(this.getAttribute(o.PROGRAM_END_TIME)); 52575 } 52576 set programEndTime(e) { 52577 e == null ? this.removeAttribute(o.PROGRAM_END_TIME) : this.setAttribute(o.PROGRAM_END_TIME, `${e}`); 52578 } 52579 get assetStartTime() { 52580 return T2(this.getAttribute(o.ASSET_START_TIME)); 52581 } 52582 set assetStartTime(e) { 52583 e == null ? this.removeAttribute(o.ASSET_START_TIME) : this.setAttribute(o.ASSET_START_TIME, `${e}`); 52584 } 52585 get assetEndTime() { 52586 return T2(this.getAttribute(o.ASSET_END_TIME)); 52587 } 52588 set assetEndTime(e) { 52589 e == null ? this.removeAttribute(o.ASSET_END_TIME) : this.setAttribute(o.ASSET_END_TIME, `${e}`); 52590 } 52591 get extraSourceParams() { 52592 return this.hasAttribute(n.EXTRA_SOURCE_PARAMS) ? [...new URLSearchParams(this.getAttribute(n.EXTRA_SOURCE_PARAMS)).entries()].reduce((e, [i3, r10]) => (e[i3] = r10, e), {}) : Fa; 52593 } 52594 set extraSourceParams(e) { 52595 e == null ? this.removeAttribute(n.EXTRA_SOURCE_PARAMS) : this.setAttribute(n.EXTRA_SOURCE_PARAMS, new URLSearchParams(e).toString()); 52596 } 52597 get customDomain() { 52598 var e; 52599 return (e = this.getAttribute(o.CUSTOM_DOMAIN)) != null ? e : void 0; 52600 } 52601 set customDomain(e) { 52602 e !== this.customDomain && (e ? this.setAttribute(o.CUSTOM_DOMAIN, e) : this.removeAttribute(o.CUSTOM_DOMAIN)); 52603 } 52604 get envKey() { 52605 var e; 52606 return (e = B4(this, o.ENV_KEY)) != null ? e : void 0; 52607 } 52608 set envKey(e) { 52609 this.setAttribute(o.ENV_KEY, `${e}`); 52610 } 52611 get noVolumePref() { 52612 return this.hasAttribute(n.NO_VOLUME_PREF); 52613 } 52614 set noVolumePref(e) { 52615 e ? this.setAttribute(n.NO_VOLUME_PREF, "") : this.removeAttribute(n.NO_VOLUME_PREF); 52616 } 52617 get debug() { 52618 return B4(this, o.DEBUG) != null; 52619 } 52620 set debug(e) { 52621 e ? this.setAttribute(o.DEBUG, "") : this.removeAttribute(o.DEBUG); 52622 } 52623 get disableTracking() { 52624 return B4(this, o.DISABLE_TRACKING) != null; 52625 } 52626 set disableTracking(e) { 52627 this.toggleAttribute(o.DISABLE_TRACKING, !!e); 52628 } 52629 get disableCookies() { 52630 return B4(this, o.DISABLE_COOKIES) != null; 52631 } 52632 set disableCookies(e) { 52633 e ? this.setAttribute(o.DISABLE_COOKIES, "") : this.removeAttribute(o.DISABLE_COOKIES); 52634 } 52635 get streamType() { 52636 var e, i3, r10; 52637 return (r10 = (i3 = this.getAttribute(o.STREAM_TYPE)) != null ? i3 : (e = this.media) == null ? void 0 : e.streamType) != null ? r10 : D2.UNKNOWN; 52638 } 52639 set streamType(e) { 52640 this.setAttribute(o.STREAM_TYPE, `${e}`); 52641 } 52642 get defaultStreamType() { 52643 var e, i3, r10; 52644 return (r10 = (i3 = this.getAttribute(n.DEFAULT_STREAM_TYPE)) != null ? i3 : (e = this.mediaController) == null ? void 0 : e.getAttribute(n.DEFAULT_STREAM_TYPE)) != null ? r10 : D2.ON_DEMAND; 52645 } 52646 set defaultStreamType(e) { 52647 e ? this.setAttribute(n.DEFAULT_STREAM_TYPE, e) : this.removeAttribute(n.DEFAULT_STREAM_TYPE); 52648 } 52649 get targetLiveWindow() { 52650 var e, i3; 52651 return this.hasAttribute(n.TARGET_LIVE_WINDOW) ? +this.getAttribute(n.TARGET_LIVE_WINDOW) : (i3 = (e = this.media) == null ? void 0 : e.targetLiveWindow) != null ? i3 : Number.NaN; 52652 } 52653 set targetLiveWindow(e) { 52654 e == this.targetLiveWindow || Number.isNaN(e) && Number.isNaN(this.targetLiveWindow) || (e == null ? this.removeAttribute(n.TARGET_LIVE_WINDOW) : this.setAttribute(n.TARGET_LIVE_WINDOW, `${+e}`)); 52655 } 52656 get liveEdgeStart() { 52657 var e; 52658 return (e = this.media) == null ? void 0 : e.liveEdgeStart; 52659 } 52660 get startTime() { 52661 return T2(B4(this, o.START_TIME)); 52662 } 52663 set startTime(e) { 52664 this.setAttribute(o.START_TIME, `${e}`); 52665 } 52666 get preferPlayback() { 52667 let e = this.getAttribute(o.PREFER_PLAYBACK); 52668 if (e === q.MSE || e === q.NATIVE) return e; 52669 } 52670 set preferPlayback(e) { 52671 e !== this.preferPlayback && (e === q.MSE || e === q.NATIVE ? this.setAttribute(o.PREFER_PLAYBACK, e) : this.removeAttribute(o.PREFER_PLAYBACK)); 52672 } 52673 get metadata() { 52674 var e; 52675 return (e = this.media) == null ? void 0 : e.metadata; 52676 } 52677 set metadata(e) { 52678 if (h2(this, M3, D3).call(this), !this.media) { 52679 E3("underlying media element missing when trying to set metadata. metadata will not be set."); 52680 return; 52681 } 52682 this.media.metadata = { ...Ut4(this), ...e }; 52683 } 52684 get _hlsConfig() { 52685 var e; 52686 return (e = this.media) == null ? void 0 : e._hlsConfig; 52687 } 52688 set _hlsConfig(e) { 52689 if (h2(this, M3, D3).call(this), !this.media) { 52690 E3("underlying media element missing when trying to set _hlsConfig. _hlsConfig will not be set."); 52691 return; 52692 } 52693 this.media._hlsConfig = e; 52694 } 52695 async addCuePoints(e) { 52696 var i3; 52697 if (h2(this, M3, D3).call(this), !this.media) { 52698 E3("underlying media element missing when trying to addCuePoints. cuePoints will not be added."); 52699 return; 52700 } 52701 return (i3 = this.media) == null ? void 0 : i3.addCuePoints(e); 52702 } 52703 get activeCuePoint() { 52704 var e; 52705 return (e = this.media) == null ? void 0 : e.activeCuePoint; 52706 } 52707 get cuePoints() { 52708 var e, i3; 52709 return (i3 = (e = this.media) == null ? void 0 : e.cuePoints) != null ? i3 : []; 52710 } 52711 addChapters(e) { 52712 var i3; 52713 if (h2(this, M3, D3).call(this), !this.media) { 52714 E3("underlying media element missing when trying to addChapters. chapters will not be added."); 52715 return; 52716 } 52717 return (i3 = this.media) == null ? void 0 : i3.addChapters(e); 52718 } 52719 get activeChapter() { 52720 var e; 52721 return (e = this.media) == null ? void 0 : e.activeChapter; 52722 } 52723 get chapters() { 52724 var e, i3; 52725 return (i3 = (e = this.media) == null ? void 0 : e.chapters) != null ? i3 : []; 52726 } 52727 getStartDate() { 52728 var e; 52729 return (e = this.media) == null ? void 0 : e.getStartDate(); 52730 } 52731 get currentPdt() { 52732 var e; 52733 return (e = this.media) == null ? void 0 : e.currentPdt; 52734 } 52735 get tokens() { 52736 let e = this.getAttribute(n.PLAYBACK_TOKEN), i3 = this.getAttribute(n.DRM_TOKEN), r10 = this.getAttribute(n.THUMBNAIL_TOKEN), o2 = this.getAttribute(n.STORYBOARD_TOKEN); 52737 return { ...u2(this, oe3), ...e != null ? { playback: e } : {}, ...i3 != null ? { drm: i3 } : {}, ...r10 != null ? { thumbnail: r10 } : {}, ...o2 != null ? { storyboard: o2 } : {} }; 52738 } 52739 set tokens(e) { 52740 R4(this, oe3, e != null ? e : {}); 52741 } 52742 get playbackToken() { 52743 var e; 52744 return (e = this.getAttribute(n.PLAYBACK_TOKEN)) != null ? e : void 0; 52745 } 52746 set playbackToken(e) { 52747 this.setAttribute(n.PLAYBACK_TOKEN, `${e}`); 52748 } 52749 get drmToken() { 52750 var e; 52751 return (e = this.getAttribute(n.DRM_TOKEN)) != null ? e : void 0; 52752 } 52753 set drmToken(e) { 52754 this.setAttribute(n.DRM_TOKEN, `${e}`); 52755 } 52756 get thumbnailToken() { 52757 var e; 52758 return (e = this.getAttribute(n.THUMBNAIL_TOKEN)) != null ? e : void 0; 52759 } 52760 set thumbnailToken(e) { 52761 this.setAttribute(n.THUMBNAIL_TOKEN, `${e}`); 52762 } 52763 get storyboardToken() { 52764 var e; 52765 return (e = this.getAttribute(n.STORYBOARD_TOKEN)) != null ? e : void 0; 52766 } 52767 set storyboardToken(e) { 52768 this.setAttribute(n.STORYBOARD_TOKEN, `${e}`); 52769 } 52770 addTextTrack(e, i3, r10, o2) { 52771 var l2; 52772 let d2 = (l2 = this.media) == null ? void 0 : l2.nativeEl; 52773 if (d2) return te2(d2, e, i3, r10, o2); 52774 } 52775 removeTextTrack(e) { 52776 var r10; 52777 let i3 = (r10 = this.media) == null ? void 0 : r10.nativeEl; 52778 if (i3) return Ze(i3, e); 52779 } 52780 get textTracks() { 52781 var e; 52782 return (e = this.media) == null ? void 0 : e.textTracks; 52783 } 52784 get castReceiver() { 52785 var e; 52786 return (e = this.getAttribute(n.CAST_RECEIVER)) != null ? e : void 0; 52787 } 52788 set castReceiver(e) { 52789 e !== this.castReceiver && (e ? this.setAttribute(n.CAST_RECEIVER, e) : this.removeAttribute(n.CAST_RECEIVER)); 52790 } 52791 get castCustomData() { 52792 var e; 52793 return (e = this.media) == null ? void 0 : e.castCustomData; 52794 } 52795 set castCustomData(e) { 52796 if (!this.media) { 52797 E3("underlying media element missing when trying to set castCustomData. castCustomData will not be set."); 52798 return; 52799 } 52800 this.media.castCustomData = e; 52801 } 52802 get noTooltips() { 52803 return this.hasAttribute(n.NO_TOOLTIPS); 52804 } 52805 set noTooltips(e) { 52806 if (!e) { 52807 this.removeAttribute(n.NO_TOOLTIPS); 52808 return; 52809 } 52810 this.setAttribute(n.NO_TOOLTIPS, ""); 52811 } 52812}; 52813re4 = /* @__PURE__ */ new WeakMap(), oe3 = /* @__PURE__ */ new WeakMap(), V4 = /* @__PURE__ */ new WeakMap(), ne4 = /* @__PURE__ */ new WeakMap(), F3 = /* @__PURE__ */ new WeakMap(), M3 = /* @__PURE__ */ new WeakSet(), D3 = function() { 52814 var e, i3, r10, o2; 52815 if (!u2(this, re4)) { 52816 R4(this, re4, true), h2(this, P2, $4).call(this); 52817 try { 52818 if (customElements.upgrade(this.mediaTheme), !(this.mediaTheme instanceof p.HTMLElement)) throw ""; 52819 } catch { 52820 E3("<media-theme> failed to upgrade!"); 52821 } 52822 try { 52823 if (customElements.upgrade(this.media), !(this.media instanceof Cs)) throw ""; 52824 } catch { 52825 E3("<mux-video> failed to upgrade!"); 52826 } 52827 try { 52828 if (customElements.upgrade(this.mediaController), !(this.mediaController instanceof media_controller_default)) throw ""; 52829 } catch { 52830 E3("<media-controller> failed to upgrade!"); 52831 } 52832 this.init(), h2(this, Te3, Ft3).call(this), h2(this, Ee3, Yt3).call(this), h2(this, Ae4, Wt3).call(this), R4(this, V4, (i3 = (e = this.mediaController) == null ? void 0 : e.hasAttribute(Attributes.USER_INACTIVE)) != null ? i3 : true), h2(this, Ce4, Zt3).call(this), (r10 = this.media) == null || r10.addEventListener("streamtypechange", () => h2(this, P2, $4).call(this)), (o2 = this.media) == null || o2.addEventListener("loadstart", () => h2(this, P2, $4).call(this)); 52833 } 52834}, ve3 = /* @__PURE__ */ new WeakSet(), $t3 = function() { 52835 var e, i3; 52836 try { 52837 (e = window == null ? void 0 : window.CSS) == null || e.registerProperty({ name: "--media-primary-color", syntax: "<color>", inherits: true }), (i3 = window == null ? void 0 : window.CSS) == null || i3.registerProperty({ name: "--media-secondary-color", syntax: "<color>", inherits: true }); 52838 } catch { 52839 } 52840}, se3 = /* @__PURE__ */ new WeakSet(), $e4 = function(e) { 52841 Object.assign(u2(this, F3), e), h2(this, P2, $4).call(this); 52842}, P2 = /* @__PURE__ */ new WeakSet(), $4 = function(e = {}) { 52843 Lt3(St3(Ia2(this, { ...u2(this, F3), ...e })), this.shadowRoot); 52844}, Te3 = /* @__PURE__ */ new WeakSet(), Ft3 = function() { 52845 let e = (r10) => { 52846 var l2, c3; 52847 if (!(r10 != null && r10.startsWith("theme-"))) return; 52848 let o2 = r10.replace(/^theme-/, ""); 52849 if (Be3.includes(o2)) return; 52850 let d2 = this.getAttribute(r10); 52851 d2 != null ? (l2 = this.mediaTheme) == null || l2.setAttribute(o2, d2) : (c3 = this.mediaTheme) == null || c3.removeAttribute(o2); 52852 }; 52853 new MutationObserver((r10) => { 52854 for (let { attributeName: o2 } of r10) e(o2); 52855 }).observe(this, { attributes: true }), this.getAttributeNames().forEach(e); 52856}, Ee3 = /* @__PURE__ */ new WeakSet(), Yt3 = function() { 52857 var i3; 52858 let e = (r10) => { 52859 let { detail: o2 } = r10; 52860 if (o2 instanceof T || (o2 = new T(o2.message, o2.code, o2.fatal)), !(o2 != null && o2.fatal)) { 52861 _2(o2), o2.data && _2(`${o2.name} data:`, o2.data); 52862 return; 52863 } 52864 let { dialog: d2, devlog: l2 } = De3(o2, false); 52865 l2.message && Me4(l2), E3(o2), o2.data && E3(`${o2.name} data:`, o2.data), h2(this, se3, $e4).call(this, { isDialogOpen: true, dialog: d2 }); 52866 }; 52867 this.addEventListener("error", e), this.media && (this.media.errorTranslator = (r10 = {}) => { 52868 var d2, l2, c3; 52869 if (!(((d2 = this.media) == null ? void 0 : d2.error) instanceof T)) return r10; 52870 let { devlog: o2 } = De3((l2 = this.media) == null ? void 0 : l2.error, false); 52871 return { player_error_code: (c3 = this.media) == null ? void 0 : c3.error.code, player_error_message: o2.message ? String(o2.message) : r10.player_error_message, player_error_context: o2.context ? String(o2.context) : r10.player_error_context }; 52872 }), (i3 = this.media) == null || i3.addEventListener("error", (r10) => { 52873 var d2, l2; 52874 let { detail: o2 } = r10; 52875 if (!o2) { 52876 let { message: c3, code: O2 } = (l2 = (d2 = this.media) == null ? void 0 : d2.error) != null ? l2 : {}; 52877 o2 = new T(c3, O2); 52878 } 52879 o2 != null && o2.fatal && this.dispatchEvent(new CustomEvent("error", { detail: o2 })); 52880 }); 52881}, Ae4 = /* @__PURE__ */ new WeakSet(), Wt3 = function() { 52882 var i3, r10, o2, d2; 52883 let e = () => h2(this, P2, $4).call(this); 52884 (r10 = (i3 = this.media) == null ? void 0 : i3.textTracks) == null || r10.addEventListener("addtrack", e), (d2 = (o2 = this.media) == null ? void 0 : o2.textTracks) == null || d2.addEventListener("removetrack", e); 52885}, Ce4 = /* @__PURE__ */ new WeakSet(), Zt3 = function() { 52886 var O2, j3; 52887 if (!/Firefox/i.test(navigator.userAgent)) return; 52888 let i3, r10 = /* @__PURE__ */ new WeakMap(), o2 = () => this.streamType === D2.LIVE && !this.secondaryColor && this.offsetWidth >= 800, d2 = (k3, A4, x2 = false) => { 52889 if (o2()) return; 52890 Array.from(k3 && k3.activeCues || []).forEach((g) => { 52891 if (!(!g.snapToLines || g.line < -5 || g.line >= 0 && g.line < 10)) if (!A4 || this.paused) { 52892 let de5 = g.text.split(` 52893`).length, q3 = -3; 52894 this.streamType === D2.LIVE && (q3 = -2); 52895 let z3 = q3 - de5; 52896 if (g.line === z3 && !x2) return; 52897 r10.has(g) || r10.set(g, g.line), g.line = z3; 52898 } else setTimeout(() => { 52899 g.line = r10.get(g) || "auto"; 52900 }, 500); 52901 }); 52902 }, l2 = () => { 52903 var k3, A4; 52904 d2(i3, (A4 = (k3 = this.mediaController) == null ? void 0 : k3.hasAttribute(Attributes.USER_INACTIVE)) != null ? A4 : false); 52905 }, c3 = () => { 52906 var x2, Y4; 52907 let A4 = Array.from(((Y4 = (x2 = this.mediaController) == null ? void 0 : x2.media) == null ? void 0 : Y4.textTracks) || []).filter((g) => ["subtitles", "captions"].includes(g.kind) && g.mode === "showing")[0]; 52908 A4 !== i3 && (i3 == null || i3.removeEventListener("cuechange", l2)), i3 = A4, i3 == null || i3.addEventListener("cuechange", l2), d2(i3, u2(this, V4)); 52909 }; 52910 c3(), (O2 = this.textTracks) == null || O2.addEventListener("change", c3), (j3 = this.textTracks) == null || j3.addEventListener("addtrack", c3), this.addEventListener("userinactivechange", () => { 52911 var A4, x2; 52912 let k3 = (x2 = (A4 = this.mediaController) == null ? void 0 : A4.hasAttribute(Attributes.USER_INACTIVE)) != null ? x2 : true; 52913 u2(this, V4) !== k3 && (R4(this, V4, k3), d2(i3, u2(this, V4))); 52914 }); 52915}; 52916function B4(t2, a2) { 52917 return t2.media ? t2.media.getAttribute(a2) : t2.getAttribute(a2); 52918} 52919p.customElements.get("mux-player") || (p.customElements.define("mux-player", ie4), p.MuxPlayerElement = ie4); 52920
vendor: 4,760 bytes, lines 52921-53000
52921// node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]__@[email protected]_v5oz3fkxfmbzkmmswy7mecoobm/node_modules/@mux/mux-player-react/dist/index.mjs 52922var import_react12 = __toESM(require_react(), 1); 52923var import_react13 = __toESM(require_react(), 1); 52924var import_react14 = __toESM(require_react(), 1); 52925var d = { className: "class", classname: "class", htmlFor: "for", crossOrigin: "crossorigin", viewBox: "viewBox", playsInline: "playsinline", autoPlay: "autoplay", playbackRate: "playbackrate" }; 52926var $5 = (e) => e == null; 52927var Q5 = (e, n2) => $5(n2) ? false : e in n2; 52928var X5 = (e) => e.replace(/[A-Z]/g, (n2) => `-${n2.toLowerCase()}`); 52929var B5 = (e, n2) => { 52930 if (!(typeof n2 == "boolean" && !n2)) { 52931 if (Q5(e, d)) return d[e]; 52932 if (typeof n2 != null) return /[A-Z]/.test(e) ? X5(e) : e; 52933 } 52934}; 52935var ee5 = (e, n2) => typeof e == "boolean" ? "" : e; 52936var p2 = (e = {}) => Object.entries(e).reduce((n2, [t2, o2]) => { 52937 let r10 = B5(t2, o2); 52938 if (!r10) return n2; 52939 let s = ee5(o2, t2); 52940 return n2[r10] = s, n2; 52941}, {}); 52942var m = (...e) => { 52943 let n2 = (0, import_react13.useRef)(null); 52944 return (0, import_react13.useEffect)(() => { 52945 e.forEach((t2) => { 52946 t2 && (typeof t2 == "function" ? t2(n2.current) : t2.current = n2.current); 52947 }); 52948 }, [e]), n2; 52949}; 52950var re5 = Object.prototype.hasOwnProperty; 52951var oe4 = (e, n2) => { 52952 if (Object.is(e, n2)) return true; 52953 if (typeof e != "object" || e === null || typeof n2 != "object" || n2 === null) return false; 52954 if (Array.isArray(e)) return !Array.isArray(n2) || e.length !== n2.length ? false : e.some((r10, s) => n2[s] === r10); 52955 let t2 = Object.keys(e), o2 = Object.keys(n2); 52956 if (t2.length !== o2.length) return false; 52957 for (let r10 = 0; r10 < t2.length; r10++) if (!re5.call(n2, t2[r10]) || !Object.is(e[t2[r10]], n2[t2[r10]])) return false; 52958 return true; 52959}; 52960var c2 = (e, n2, t2) => !oe4(n2, e[t2]); 52961var ie5 = (e, n2, t2) => { 52962 e[t2] = n2; 52963}; 52964var se4 = (e, n2, t2, o2 = ie5, r10 = c2) => (0, import_react14.useEffect)(() => { 52965 let s = t2 == null ? void 0 : t2.current; 52966 s && r10(s, n2, e) && o2(s, n2, e); 52967}, [t2 == null ? void 0 : t2.current, n2]); 52968var i2 = se4; 52969var le5 = () => { 52970 try { 52971 return "3.1.0"; 52972 } catch { 52973 } 52974 return "UNKNOWN"; 52975}; 52976var ue4 = le5(); 52977var E4 = () => ue4; 52978var de4 = import_react11.default.forwardRef(({ children: e, ...n2 }, t2) => import_react11.default.createElement("mux-player", p2({ ...n2, ref: t2 }), e)); 52979var a = (e, n2, t2) => (0, import_react11.useEffect)(() => { 52980 let o2 = n2 == null ? void 0 : n2.current; 52981 if (!(!o2 || !t2)) return o2.addEventListener(e, t2), () => { 52982 o2.removeEventListener(e, t2); 52983 }; 52984}, [n2 == null ? void 0 : n2.current, t2]); 52985var pe5 = (e, n2) => { 52986 let { onAbort: t2, onCanPlay: o2, onCanPlayThrough: r10, onEmptied: s, onLoadStart: g, onLoadedData: M4, onLoadedMetadata: f, onProgress: P3, onDurationChange: b3, onVolumeChange: v2, onRateChange: x2, onResize: h3, onWaiting: T3, onPlay: R5, onPlaying: C4, onTimeUpdate: k3, onPause: L, onSeeking: O2, onSeeked: S3, onStalled: G4, onSuspend: w4, onEnded: V5, onError: A4, onCuePointChange: N3, onCuePointsChange: D4, onChapterChange: I4, metadata: K4, tokens: U5, paused: _3, playbackId: H5, playbackRates: j3, currentTime: z3, themeProps: F4, extraSourceParams: W4, castCustomData: Z4, _hlsConfig: q3, ...J5 } = n2; 52987 return i2("playbackRates", j3, e), i2("metadata", K4, e), i2("extraSourceParams", W4, e), i2("_hlsConfig", q3, e), i2("themeProps", F4, e), i2("tokens", U5, e), i2("playbackId", H5, e), i2("castCustomData", Z4, e), i2("paused", _3, e, (l2, u3) => { 52988 u3 != null && (u3 ? l2.pause() : l2.play()); 52989 }, (l2, u3, Y4) => l2.hasAttribute("autoplay") && !l2.hasPlayed ? false : c2(l2, u3, Y4)), i2("currentTime", z3, e, (l2, u3) => { 52990 u3 != null && (l2.currentTime = u3); 52991 }), a("abort", e, t2), a("canplay", e, o2), a("canplaythrough", e, r10), a("emptied", e, s), a("loadstart", e, g), a("loadeddata", e, M4), a("loadedmetadata", e, f), a("progress", e, P3), a("durationchange", e, b3), a("volumechange", e, v2), a("ratechange", e, x2), a("resize", e, h3), a("waiting", e, T3), a("play", e, R5), a("playing", e, C4), a("timeupdate", e, k3), a("pause", e, L), a("seeking", e, O2), a("seeked", e, S3), a("stalled", e, G4), a("suspend", e, w4), a("ended", e, V5), a("error", e, A4), a("cuepointchange", e, N3), a("cuepointschange", e, D4), a("chapterchange", e, I4), [J5]; 52992}; 52993var me4 = E4(); 52994var Ee4 = "mux-player-react"; 52995var ge5 = import_react11.default.forwardRef((e, n2) => { 52996 let t2 = (0, import_react12.useRef)(null), o2 = m(t2, n2), [r10] = pe5(t2, e); 52997 return import_react11.default.createElement(de4, { ref: o2, playerSoftwareName: Ee4, playerSoftwareVersion: me4, ...r10 }); 52998}); 52999var Ne3 = ge5; 53000
vendor: 216 bytes, lines 53001-53003
53001// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EditAssetDialog/PreviewBox/AssetPreview.mjs 53002var import_qs5 = __toESM(require_lib(), 1); 53003
vendor: 585 bytes, lines 53004-53018
53004// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/utils/icons.mjs 53005var FILE_TYPE_ICON_COMPONENT_MAP = { 53006 [DocType.Pdf]: ForwardRef$1M, 53007 [DocType.Csv]: ForwardRef$1O, 53008 [DocType.Xls]: ForwardRef$1L, 53009 [DocType.Zip]: ForwardRef$1K 53010}; 53011var DEFAULT_FILE_ICON = ForwardRef$1P; 53012var getFileIconComponent = (docType) => { 53013 if (Object.values(DocType).some((type) => docType == null ? void 0 : docType.includes(type))) { 53014 return FILE_TYPE_ICON_COMPONENT_MAP[docType] ?? DEFAULT_FILE_ICON; 53015 } 53016 return DEFAULT_FILE_ICON; 53017}; 53018
vendor: 2,044 bytes, lines 53019-53088
53019// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EditAssetDialog/PreviewBox/AssetPreview.mjs 53020var CardAsset2 = dt(Flex)` 53021 min-height: 26.4rem; 53022 border-radius: ${({ theme }) => theme.borderRadius} ${({ theme }) => theme.borderRadius} 0 0; 53023 background: linear-gradient( 53024 180deg, 53025 ${({ theme }) => theme.colors.neutral0} 0%, 53026 ${({ theme }) => theme.colors.neutral100} 121.48% 53027 ); 53028`; 53029var AssetPreview = React13.forwardRef(({ mime, url, name, ...props }, ref) => { 53030 const theme = nt(); 53031 const assetType = typeFromMime(mime); 53032 const { formatMessage } = useIntl(); 53033 if (assetType === AssetType.Image) { 53034 return (0, import_jsx_runtime8.jsx)("img", { 53035 ref, 53036 src: url, 53037 alt: name, 53038 ...props 53039 }); 53040 } 53041 if (assetType === AssetType.Video) { 53042 return (0, import_jsx_runtime8.jsx)(Ne3, { 53043 src: url, 53044 accentColor: theme.colors.primary500 53045 }); 53046 } 53047 if (assetType === AssetType.Audio) { 53048 return (0, import_jsx_runtime8.jsx)(Box, { 53049 margin: "5", 53050 children: (0, import_jsx_runtime8.jsx)("audio", { 53051 controls: true, 53052 src: url, 53053 ref, 53054 ...props, 53055 children: name 53056 }) 53057 }); 53058 } 53059 const IconComponent = getFileIconComponent(assetType); 53060 return (0, import_jsx_runtime8.jsx)(CardAsset2, { 53061 width: "100%", 53062 justifyContent: "center", 53063 ...props, 53064 children: (0, import_jsx_runtime8.jsxs)(Flex, { 53065 gap: 2, 53066 direction: "column", 53067 alignItems: "center", 53068 children: [ 53069 (0, import_jsx_runtime8.jsx)(IconComponent, { 53070 "aria-label": name, 53071 fill: "neutral500", 53072 width: 24, 53073 height: 24 53074 }), 53075 (0, import_jsx_runtime8.jsx)(Typography, { 53076 textColor: "neutral500", 53077 variant: "pi", 53078 children: formatMessage({ 53079 id: "noPreview", 53080 defaultMessage: "No preview available" 53081 }) 53082 }) 53083 ] 53084 }) 53085 }); 53086}); 53087AssetPreview.displayName = "AssetPreview"; 53088
vendor: 280 bytes, lines 53089-53092
53089// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EditAssetDialog/PreviewBox/CroppingActions.mjs 53090var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1); 53091var import_qs6 = __toESM(require_lib(), 1); 53092
vendor: 1,446 bytes, lines 53093-53154
53093// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EditAssetDialog/PreviewBox/PreviewComponents.mjs 53094var RelativeBox = dt(Box)` 53095 position: relative; 53096`; 53097var Wrapper = dt.div` 53098 position: relative; 53099 display: flex; 53100 justify-content: center; 53101 background: repeating-conic-gradient( 53102 ${({ theme }) => theme.colors.neutral100} 0% 25%, 53103 transparent 0% 50% 53104 ) 53105 50% / 20px 20px; 53106 53107 svg { 53108 height: 26px; 53109 } 53110 53111 img, 53112 mux-player { 53113 margin: 0; 53114 padding: 0; 53115 max-height: 26.4rem; 53116 max-width: 100%; 53117 } 53118 53119 mux-player { 53120 --play-button: inline-flex; 53121 --mute-button: inline-flex; 53122 --pip-button: inline-flex; 53123 --fullscreen-button: inline-flex; 53124 --playback-rate-button: inline-flex; 53125 --volume-range: inline-flex; 53126 --time-range: inline-flex; 53127 --time-display: inline-flex; 53128 --duration-display: inline-flex; 53129 } 53130`; 53131var ActionRow = dt(Flex)` 53132 height: 5.2rem; 53133 background-color: ${({ $blurry }) => $blurry ? `rgba(33, 33, 52, 0.4)` : void 0}; 53134`; 53135var CroppingActionRow = dt(Flex)` 53136 z-index: 1; 53137 height: 5.2rem; 53138 position: absolute; 53139 background-color: rgba(33, 33, 52, 0.4); 53140 width: 100%; 53141`; 53142var BadgeOverride = dt(Badge)` 53143 span { 53144 color: inherit; 53145 font-weight: ${({ theme }) => theme.fontWeights.regular}; 53146 } 53147`; 53148var UploadProgressWrapper = dt.div` 53149 position: absolute; 53150 z-index: 2; 53151 height: 100%; 53152 width: 100%; 53153`; 53154
vendor: 2,955 bytes, lines 53155-53249
53155// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EditAssetDialog/PreviewBox/CroppingActions.mjs 53156var CroppingActions = ({ onCancel, onValidate, onDuplicate }) => { 53157 const { formatMessage } = useIntl(); 53158 const theme = nt(); 53159 return (0, import_jsx_runtime9.jsx)(FocusTrap, { 53160 onEscape: onCancel, 53161 children: (0, import_jsx_runtime9.jsx)(CroppingActionRow, { 53162 justifyContent: "flex-end", 53163 paddingLeft: 3, 53164 paddingRight: 3, 53165 children: (0, import_jsx_runtime9.jsxs)(Flex, { 53166 gap: 1, 53167 children: [ 53168 (0, import_jsx_runtime9.jsx)(IconButton, { 53169 label: formatMessage({ 53170 id: getTrad("control-card.stop-crop"), 53171 defaultMessage: "Stop cropping" 53172 }), 53173 onClick: onCancel, 53174 children: (0, import_jsx_runtime9.jsx)(ForwardRef$26, {}) 53175 }), 53176 (0, import_jsx_runtime9.jsxs)(Menu.Root, { 53177 children: [ 53178 (0, import_jsx_runtime9.jsx)(Trigger, { 53179 "aria-label": formatMessage({ 53180 id: getTrad("control-card.crop"), 53181 defaultMessage: "Crop" 53182 }), 53183 variant: "tertiary", 53184 paddingLeft: 2, 53185 paddingRight: 2, 53186 endIcon: null, 53187 children: (0, import_jsx_runtime9.jsx)(ForwardRef$2o, { 53188 "aria-hidden": true, 53189 focusable: false, 53190 style: { 53191 position: "relative", 53192 top: 2 53193 }, 53194 fill: "#C0C0D0" 53195 }) 53196 }), 53197 (0, import_jsx_runtime9.jsxs)(Menu.Content, { 53198 zIndex: theme.zIndices.dialog, 53199 children: [ 53200 (0, import_jsx_runtime9.jsx)(Menu.Item, { 53201 onSelect: onValidate, 53202 children: formatMessage({ 53203 id: getTrad("checkControl.crop-original"), 53204 defaultMessage: "Crop the original asset" 53205 }) 53206 }), 53207 onDuplicate && (0, import_jsx_runtime9.jsx)(Menu.Item, { 53208 onSelect: onDuplicate, 53209 children: formatMessage({ 53210 id: getTrad("checkControl.crop-duplicate"), 53211 defaultMessage: "Duplicate & crop the asset" 53212 }) 53213 }) 53214 ] 53215 }) 53216 ] 53217 }) 53218 ] 53219 }) 53220 }) 53221 }); 53222}; 53223var Trigger = dt(Menu.Trigger)` 53224 svg { 53225 > g, 53226 path { 53227 fill: ${({ theme }) => theme.colors.neutral500}; 53228 } 53229 } 53230 53231 &:hover { 53232 svg { 53233 > g, 53234 path { 53235 fill: ${({ theme }) => theme.colors.neutral600}; 53236 } 53237 } 53238 } 53239 53240 &:active { 53241 svg { 53242 > g, 53243 path { 53244 fill: ${({ theme }) => theme.colors.neutral400}; 53245 } 53246 } 53247 } 53248`; 53249
vendor: 7,862 bytes, lines 53250-53462
53250// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EditAssetDialog/PreviewBox/PreviewBox.mjs 53251var PreviewBox = ({ asset, canUpdate, canCopyLink, canDownload, onDelete, onCropFinish, onCropStart, onCropCancel, replacementFile, trackedLocation }) => { 53252 var _a3; 53253 const CropperjsStyle = ft`${cropperjscss}`; 53254 const { trackUsage } = useTracking(); 53255 const previewRef = React14.useRef(null); 53256 const [isCropImageReady, setIsCropImageReady] = React14.useState(false); 53257 const [hasCropIntent, setHasCropIntent] = React14.useState(null); 53258 const [assetUrl, setAssetUrl] = React14.useState(createAssetUrl(asset, false)); 53259 const [thumbnailUrl, setThumbnailUrl] = React14.useState(createAssetUrl(asset, true)); 53260 const { formatMessage } = useIntl(); 53261 const [showConfirmDialog, setShowConfirmDialog] = React14.useState(false); 53262 const { crop: crop2, produceFile, stopCropping, isCropping, isCropperReady, width, height } = useCropImg(); 53263 const { editAsset, error, isLoading, progress, cancel } = useEditAsset(); 53264 const { upload, isLoading: isLoadingUpload, cancel: cancelUpload, error: uploadError, progress: progressUpload } = useUpload(); 53265 React14.useEffect(() => { 53266 if (replacementFile) { 53267 const fileLocalUrl = URL.createObjectURL(replacementFile); 53268 if (asset.isLocal) { 53269 asset.url = fileLocalUrl; 53270 } 53271 setAssetUrl(fileLocalUrl); 53272 setThumbnailUrl(fileLocalUrl); 53273 } 53274 }, [ 53275 replacementFile, 53276 asset 53277 ]); 53278 React14.useEffect(() => { 53279 if (hasCropIntent === false) { 53280 stopCropping(); 53281 onCropCancel(); 53282 } 53283 }, [ 53284 hasCropIntent, 53285 stopCropping, 53286 onCropCancel, 53287 onCropFinish 53288 ]); 53289 React14.useEffect(() => { 53290 if (hasCropIntent && isCropImageReady) { 53291 crop2(previewRef.current); 53292 onCropStart(); 53293 } 53294 }, [ 53295 isCropImageReady, 53296 hasCropIntent, 53297 onCropStart, 53298 crop2 53299 ]); 53300 const handleCropping = async () => { 53301 var _a4; 53302 const nextAsset = { 53303 ...asset, 53304 width, 53305 height, 53306 folder: (_a4 = asset.folder) == null ? void 0 : _a4.id 53307 }; 53308 const file = await produceFile(nextAsset.name, nextAsset.mime, nextAsset.updatedAt); 53309 let optimizedCachingImage; 53310 let optimizedCachingThumbnailImage; 53311 if (asset.isLocal) { 53312 optimizedCachingImage = URL.createObjectURL(file); 53313 optimizedCachingThumbnailImage = optimizedCachingImage; 53314 asset.url = optimizedCachingImage; 53315 asset.rawFile = file; 53316 trackUsage("didCropFile", { 53317 duplicatedFile: null, 53318 location: trackedLocation 53319 }); 53320 } else { 53321 const updatedAsset = await editAsset(nextAsset, file); 53322 optimizedCachingImage = createAssetUrl(updatedAsset, false); 53323 optimizedCachingThumbnailImage = createAssetUrl(updatedAsset, true); 53324 trackUsage("didCropFile", { 53325 duplicatedFile: false, 53326 location: trackedLocation 53327 }); 53328 } 53329 setAssetUrl(optimizedCachingImage); 53330 setThumbnailUrl(optimizedCachingThumbnailImage); 53331 setHasCropIntent(false); 53332 }; 53333 const isInCroppingMode = isCropping && !isLoading; 53334 const handleDuplication = async () => { 53335 var _a4; 53336 const nextAsset = { 53337 ...asset, 53338 width, 53339 height 53340 }; 53341 const file = await produceFile(nextAsset.name, nextAsset.mime, nextAsset.updatedAt); 53342 await upload({ 53343 name: file.name, 53344 rawFile: file 53345 }, ((_a4 = asset.folder) == null ? void 0 : _a4.id) ? asset.folder.id : null); 53346 trackUsage("didCropFile", { 53347 duplicatedFile: true, 53348 location: trackedLocation 53349 }); 53350 setHasCropIntent(false); 53351 onCropFinish(); 53352 }; 53353 const handleCropCancel = () => { 53354 setHasCropIntent(false); 53355 }; 53356 const handleCropStart = () => { 53357 setHasCropIntent(true); 53358 }; 53359 return (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { 53360 children: [ 53361 (0, import_jsx_runtime10.jsx)(CropperjsStyle, {}), 53362 (0, import_jsx_runtime10.jsxs)(RelativeBox, { 53363 hasRadius: true, 53364 background: "neutral150", 53365 borderColor: "neutral200", 53366 children: [ 53367 isCropperReady && isInCroppingMode && (0, import_jsx_runtime10.jsx)(CroppingActions, { 53368 onValidate: handleCropping, 53369 onDuplicate: asset.isLocal ? void 0 : handleDuplication, 53370 onCancel: handleCropCancel 53371 }), 53372 (0, import_jsx_runtime10.jsx)(ActionRow, { 53373 paddingLeft: 3, 53374 paddingRight: 3, 53375 justifyContent: "flex-end", 53376 children: (0, import_jsx_runtime10.jsxs)(Flex, { 53377 gap: 1, 53378 children: [ 53379 canUpdate && !asset.isLocal && (0, import_jsx_runtime10.jsx)(IconButton, { 53380 label: formatMessage({ 53381 id: "global.delete", 53382 defaultMessage: "Delete" 53383 }), 53384 onClick: () => setShowConfirmDialog(true), 53385 children: (0, import_jsx_runtime10.jsx)(ForwardRef$b, {}) 53386 }), 53387 canDownload && (0, import_jsx_runtime10.jsx)(IconButton, { 53388 label: formatMessage({ 53389 id: getTrad("control-card.download"), 53390 defaultMessage: "Download" 53391 }), 53392 onClick: () => downloadFile(assetUrl, asset.name), 53393 children: (0, import_jsx_runtime10.jsx)(ForwardRef$20, {}) 53394 }), 53395 canCopyLink && (0, import_jsx_runtime10.jsx)(CopyLinkButton, { 53396 url: assetUrl 53397 }), 53398 canUpdate && ((_a3 = asset.mime) == null ? void 0 : _a3.includes(AssetType.Image)) && (0, import_jsx_runtime10.jsx)(IconButton, { 53399 label: formatMessage({ 53400 id: getTrad("control-card.crop"), 53401 defaultMessage: "Crop" 53402 }), 53403 onClick: handleCropStart, 53404 children: (0, import_jsx_runtime10.jsx)(ForwardRef$27, {}) 53405 }) 53406 ] 53407 }) 53408 }), 53409 (0, import_jsx_runtime10.jsxs)(Wrapper, { 53410 children: [ 53411 isLoading && (0, import_jsx_runtime10.jsx)(UploadProgressWrapper, { 53412 children: (0, import_jsx_runtime10.jsx)(UploadProgress, { 53413 error, 53414 onCancel: cancel, 53415 progress 53416 }) 53417 }), 53418 isLoadingUpload && (0, import_jsx_runtime10.jsx)(UploadProgressWrapper, { 53419 children: (0, import_jsx_runtime10.jsx)(UploadProgress, { 53420 error: uploadError, 53421 onCancel: cancelUpload, 53422 progress: progressUpload 53423 }) 53424 }), 53425 (0, import_jsx_runtime10.jsx)(AssetPreview, { 53426 ref: previewRef, 53427 mime: asset.mime, 53428 name: asset.name, 53429 url: hasCropIntent ? assetUrl : thumbnailUrl, 53430 onLoad: () => { 53431 if (asset.isLocal || hasCropIntent) { 53432 setIsCropImageReady(true); 53433 } 53434 } 53435 }) 53436 ] 53437 }), 53438 (0, import_jsx_runtime10.jsx)(ActionRow, { 53439 paddingLeft: 2, 53440 paddingRight: 2, 53441 justifyContent: "flex-end", 53442 $blurry: isInCroppingMode, 53443 children: isInCroppingMode && width && height && (0, import_jsx_runtime10.jsx)(BadgeOverride, { 53444 background: "neutral900", 53445 color: "neutral0", 53446 children: width && height ? `${height}â${width}` : "N/A" 53447 }) 53448 }) 53449 ] 53450 }), 53451 (0, import_jsx_runtime10.jsx)(RemoveAssetDialog, { 53452 open: showConfirmDialog, 53453 onClose: () => { 53454 setShowConfirmDialog(false); 53455 onDelete(null); 53456 }, 53457 asset 53458 }) 53459 ] 53460 }); 53461}; 53462
vendor: 1,701 bytes, lines 53463-53512
53463// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EditAssetDialog/ReplaceMediaButton.mjs 53464var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1); 53465var React15 = __toESM(require_react(), 1); 53466var import_qs8 = __toESM(require_lib(), 1); 53467var ReplaceMediaButton = ({ onSelectMedia, acceptedMime, trackedLocation, ...props }) => { 53468 const { formatMessage } = useIntl(); 53469 const inputRef = React15.useRef(null); 53470 const { trackUsage } = useTracking(); 53471 const handleClick = (e) => { 53472 var _a3; 53473 e.preventDefault(); 53474 if (trackedLocation) { 53475 trackUsage("didReplaceMedia", { 53476 location: trackedLocation 53477 }); 53478 } 53479 (_a3 = inputRef.current) == null ? void 0 : _a3.click(); 53480 }; 53481 const handleChange = () => { 53482 var _a3, _b; 53483 const file = (_b = (_a3 = inputRef.current) == null ? void 0 : _a3.files) == null ? void 0 : _b[0]; 53484 onSelectMedia(file); 53485 }; 53486 return (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { 53487 children: [ 53488 (0, import_jsx_runtime11.jsx)(Button, { 53489 variant: "secondary", 53490 onClick: handleClick, 53491 ...props, 53492 children: formatMessage({ 53493 id: getTrad("control-card.replace-media"), 53494 defaultMessage: "Replace media" 53495 }) 53496 }), 53497 (0, import_jsx_runtime11.jsx)(VisuallyHidden, { 53498 children: (0, import_jsx_runtime11.jsx)("input", { 53499 accept: acceptedMime, 53500 type: "file", 53501 name: "file", 53502 "data-testid": "file-input", 53503 tabIndex: -1, 53504 ref: inputRef, 53505 onChange: handleChange, 53506 "aria-hidden": true 53507 }) 53508 }) 53509 ] 53510 }); 53511}; 53512
vendor: 15,565 bytes, lines 53513-53871
53513// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EditAssetDialog/EditAssetContent.mjs 53514var LoadingBody = dt(Flex)` 53515 /* 80px are coming from the Tabs component that is not included in the ModalBody */ 53516 min-height: ${() => `calc(60dvh + 8rem)`}; 53517`; 53518var fileInfoSchema = create3({ 53519 name: create().required(), 53520 alternativeText: create(), 53521 caption: create(), 53522 folder: create2() 53523}); 53524var EditAssetContent = ({ onClose, asset, canUpdate = false, canCopyLink = false, canDownload = false, trackedLocation, omitFields = [], omitActions = [] }) => { 53525 var _a3, _b; 53526 const { formatMessage, formatDate } = useIntl(); 53527 const { trackUsage } = useTracking(); 53528 const submitButtonRef = React16.useRef(null); 53529 const [isCropping, setIsCropping] = React16.useState(false); 53530 const [replacementFile, setReplacementFile] = React16.useState(); 53531 const { editAsset, isLoading } = useEditAsset(); 53532 const { data: folderStructure, isLoading: folderStructureIsLoading } = useFolderStructure({ 53533 enabled: true 53534 }); 53535 const handleSubmit = async (values) => { 53536 var _a4, _b2, _c, _d, _e5; 53537 const nextAsset = { 53538 ...asset, 53539 ...values, 53540 folder: (_a4 = values.parent) == null ? void 0 : _a4.value 53541 }; 53542 if (asset == null ? void 0 : asset.isLocal) { 53543 onClose(nextAsset); 53544 } else { 53545 const editedAsset = await editAsset(nextAsset, replacementFile); 53546 const assetType = (_b2 = asset == null ? void 0 : asset.mime) == null ? void 0 : _b2.split("/")[0]; 53547 const didChangeLocation = ((_c = asset == null ? void 0 : asset.folder) == null ? void 0 : _c.id) ? asset.folder.id !== ((_d = values.parent) == null ? void 0 : _d.value) : (asset == null ? void 0 : asset.folder) === null && !!((_e5 = values.parent) == null ? void 0 : _e5.value); 53548 trackUsage("didEditMediaLibraryElements", { 53549 location: trackedLocation, 53550 type: assetType, 53551 changeLocation: didChangeLocation 53552 }); 53553 onClose(editedAsset); 53554 } 53555 }; 53556 const handleStartCropping = () => { 53557 setIsCropping(true); 53558 }; 53559 const handleCancelCropping = () => { 53560 setIsCropping(false); 53561 }; 53562 const handleFinishCropping = () => { 53563 setIsCropping(false); 53564 onClose(); 53565 }; 53566 const formDisabled = !canUpdate || isCropping; 53567 const handleConfirmClose = () => { 53568 const confirm = window.confirm(formatMessage({ 53569 id: "window.confirm.close-modal.file", 53570 defaultMessage: "Are you sure? Your changes will be lost." 53571 })); 53572 if (confirm) { 53573 onClose(); 53574 } 53575 }; 53576 const activeFolderId = (_a3 = asset == null ? void 0 : asset.folder) == null ? void 0 : _a3.id; 53577 const initialFormData = !folderStructureIsLoading && { 53578 name: asset == null ? void 0 : asset.name, 53579 alternativeText: (asset == null ? void 0 : asset.alternativeText) ?? void 0, 53580 caption: (asset == null ? void 0 : asset.caption) ?? void 0, 53581 parent: { 53582 value: activeFolderId ?? void 0, 53583 label: ((_b = findRecursiveFolderByValue(folderStructure, activeFolderId)) == null ? void 0 : _b.label) ?? folderStructure[0].label 53584 } 53585 }; 53586 const handleClose = (values) => { 53587 if (!(0, import_isEqual.default)(initialFormData, values)) { 53588 handleConfirmClose(); 53589 } else { 53590 onClose(); 53591 } 53592 }; 53593 if (folderStructureIsLoading) { 53594 return (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { 53595 children: [ 53596 (0, import_jsx_runtime12.jsx)(DialogHeader, {}), 53597 (0, import_jsx_runtime12.jsx)(LoadingBody, { 53598 minHeight: "60vh", 53599 justifyContent: "center", 53600 paddingTop: 4, 53601 paddingBottom: 4, 53602 children: (0, import_jsx_runtime12.jsx)(Loader, { 53603 children: formatMessage({ 53604 id: getTrad("content.isLoading"), 53605 defaultMessage: "Content is loading." 53606 }) 53607 }) 53608 }), 53609 (0, import_jsx_runtime12.jsx)(Modal.Footer, { 53610 children: (0, import_jsx_runtime12.jsx)(Button, { 53611 onClick: () => handleClose(), 53612 variant: "tertiary", 53613 children: formatMessage({ 53614 id: "cancel", 53615 defaultMessage: "Cancel" 53616 }) 53617 }) 53618 }) 53619 ] 53620 }); 53621 } 53622 return (0, import_jsx_runtime12.jsx)(Formik, { 53623 validationSchema: fileInfoSchema, 53624 validateOnChange: false, 53625 onSubmit: handleSubmit, 53626 initialValues: initialFormData, 53627 children: ({ values, errors, handleChange, setFieldValue }) => (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { 53628 children: [ 53629 (0, import_jsx_runtime12.jsx)(DialogHeader, {}), 53630 (0, import_jsx_runtime12.jsx)(Modal.Body, { 53631 children: (0, import_jsx_runtime12.jsxs)(Grid.Root, { 53632 gap: 4, 53633 children: [ 53634 (0, import_jsx_runtime12.jsx)(Grid.Item, { 53635 xs: 12, 53636 col: 6, 53637 direction: "column", 53638 alignItems: "stretch", 53639 children: (0, import_jsx_runtime12.jsx)(PreviewBox, { 53640 asset, 53641 canUpdate, 53642 canCopyLink, 53643 canDownload, 53644 onDelete: onClose, 53645 onCropFinish: handleFinishCropping, 53646 onCropStart: handleStartCropping, 53647 onCropCancel: handleCancelCropping, 53648 replacementFile, 53649 trackedLocation 53650 }) 53651 }), 53652 (0, import_jsx_runtime12.jsx)(Grid.Item, { 53653 xs: 12, 53654 col: 6, 53655 direction: "column", 53656 alignItems: "stretch", 53657 children: (0, import_jsx_runtime12.jsxs)(Form, { 53658 noValidate: true, 53659 children: [ 53660 (0, import_jsx_runtime12.jsxs)(Flex, { 53661 direction: "column", 53662 alignItems: "stretch", 53663 gap: 3, 53664 children: [ 53665 (0, import_jsx_runtime12.jsx)(ContextInfo, { 53666 blocks: [ 53667 { 53668 label: formatMessage({ 53669 id: getTrad("modal.file-details.size"), 53670 defaultMessage: "Size" 53671 }), 53672 value: formatBytes((asset == null ? void 0 : asset.size) ? asset.size : 0) 53673 }, 53674 { 53675 label: formatMessage({ 53676 id: getTrad("modal.file-details.dimensions"), 53677 defaultMessage: "Dimensions" 53678 }), 53679 value: (asset == null ? void 0 : asset.height) && asset.width ? `${asset.width}â${asset.height}` : null 53680 }, 53681 { 53682 label: formatMessage({ 53683 id: getTrad("modal.file-details.date"), 53684 defaultMessage: "Date" 53685 }), 53686 value: formatDate(new Date((asset == null ? void 0 : asset.createdAt) ? asset.createdAt : "")) 53687 }, 53688 { 53689 label: formatMessage({ 53690 id: getTrad("modal.file-details.extension"), 53691 defaultMessage: "Extension" 53692 }), 53693 value: getFileExtension(asset == null ? void 0 : asset.ext) 53694 }, 53695 { 53696 label: formatMessage({ 53697 id: getTrad("modal.file-details.id"), 53698 defaultMessage: "Asset ID" 53699 }), 53700 value: (asset == null ? void 0 : asset.id) ? asset.id : null 53701 } 53702 ] 53703 }), 53704 (0, import_jsx_runtime12.jsxs)(Field.Root, { 53705 name: "name", 53706 error: errors.name, 53707 children: [ 53708 (0, import_jsx_runtime12.jsx)(Field.Label, { 53709 children: formatMessage({ 53710 id: getTrad("form.input.label.file-name"), 53711 defaultMessage: "File name" 53712 }) 53713 }), 53714 (0, import_jsx_runtime12.jsx)(TextInput, { 53715 value: values.name, 53716 onChange: handleChange, 53717 disabled: formDisabled, 53718 type: "text" 53719 }), 53720 (0, import_jsx_runtime12.jsx)(Field.Error, {}) 53721 ] 53722 }), 53723 !(omitFields == null ? void 0 : omitFields.includes("alternativeText")) && (0, import_jsx_runtime12.jsxs)(Field.Root, { 53724 name: "alternativeText", 53725 hint: formatMessage({ 53726 id: getTrad("form.input.description.file-alt"), 53727 defaultMessage: "This text will be displayed if the asset canât be shown." 53728 }), 53729 error: errors.alternativeText, 53730 children: [ 53731 (0, import_jsx_runtime12.jsx)(Field.Label, { 53732 children: formatMessage({ 53733 id: getTrad("form.input.label.file-alt"), 53734 defaultMessage: "Alternative text" 53735 }) 53736 }), 53737 (0, import_jsx_runtime12.jsx)(TextInput, { 53738 value: values.alternativeText, 53739 onChange: handleChange, 53740 disabled: formDisabled, 53741 type: "text" 53742 }), 53743 (0, import_jsx_runtime12.jsx)(Field.Hint, {}), 53744 (0, import_jsx_runtime12.jsx)(Field.Error, {}) 53745 ] 53746 }), 53747 !(omitFields == null ? void 0 : omitFields.includes("caption")) && (0, import_jsx_runtime12.jsxs)(Field.Root, { 53748 name: "caption", 53749 error: errors.caption, 53750 children: [ 53751 (0, import_jsx_runtime12.jsx)(Field.Label, { 53752 children: formatMessage({ 53753 id: getTrad("form.input.label.file-caption"), 53754 defaultMessage: "Caption" 53755 }) 53756 }), 53757 (0, import_jsx_runtime12.jsx)(TextInput, { 53758 value: values.caption, 53759 onChange: handleChange, 53760 disabled: formDisabled, 53761 type: "text" 53762 }) 53763 ] 53764 }), 53765 (0, import_jsx_runtime12.jsx)(Flex, { 53766 direction: "column", 53767 alignItems: "stretch", 53768 gap: 1, 53769 children: (0, import_jsx_runtime12.jsxs)(Field.Root, { 53770 name: "parent", 53771 id: "asset-folder", 53772 children: [ 53773 (0, import_jsx_runtime12.jsx)(Field.Label, { 53774 children: formatMessage({ 53775 id: getTrad("form.input.label.file-location"), 53776 defaultMessage: "Location" 53777 }) 53778 }), 53779 (0, import_jsx_runtime12.jsx)(SelectTree, { 53780 name: "parent", 53781 defaultValue: values.parent, 53782 options: folderStructure, 53783 onChange: (value) => { 53784 setFieldValue("parent", value); 53785 }, 53786 menuPortalTarget: document.querySelector("body"), 53787 inputId: "asset-folder", 53788 isDisabled: formDisabled, 53789 error: errors == null ? void 0 : errors.parent, 53790 ariaErrorMessage: "folder-parent-error" 53791 }) 53792 ] 53793 }) 53794 }) 53795 ] 53796 }), 53797 (0, import_jsx_runtime12.jsx)(VisuallyHidden, { 53798 children: (0, import_jsx_runtime12.jsx)("button", { 53799 type: "submit", 53800 tabIndex: -1, 53801 ref: submitButtonRef, 53802 disabled: formDisabled, 53803 children: formatMessage({ 53804 id: "submit", 53805 defaultMessage: "Submit" 53806 }) 53807 }) 53808 }) 53809 ] 53810 }) 53811 }) 53812 ] 53813 }) 53814 }), 53815 (0, import_jsx_runtime12.jsxs)(Modal.Footer, { 53816 children: [ 53817 (0, import_jsx_runtime12.jsx)(Button, { 53818 onClick: () => handleClose({ 53819 ...values 53820 }), 53821 variant: "tertiary", 53822 children: formatMessage({ 53823 id: "global.cancel", 53824 defaultMessage: "Cancel" 53825 }) 53826 }), 53827 (0, import_jsx_runtime12.jsxs)(Flex, { 53828 gap: 2, 53829 children: [ 53830 !(omitActions == null ? void 0 : omitActions.includes("replace")) && (0, import_jsx_runtime12.jsx)(ReplaceMediaButton, { 53831 onSelectMedia: setReplacementFile, 53832 acceptedMime: (asset == null ? void 0 : asset.mime) ?? "", 53833 disabled: formDisabled, 53834 trackedLocation 53835 }), 53836 (0, import_jsx_runtime12.jsx)(Button, { 53837 onClick: () => { 53838 var _a4; 53839 return (_a4 = submitButtonRef.current) == null ? void 0 : _a4.click(); 53840 }, 53841 loading: isLoading, 53842 disabled: formDisabled, 53843 children: formatMessage({ 53844 id: "global.finish", 53845 defaultMessage: "Finish" 53846 }) 53847 }) 53848 ] 53849 }) 53850 ] 53851 }) 53852 ] 53853 }) 53854 }); 53855}; 53856var EditAssetDialog = ({ open, onClose, canUpdate = false, canCopyLink = false, canDownload = false, ...restProps }) => { 53857 return (0, import_jsx_runtime12.jsx)(Modal.Root, { 53858 open, 53859 onOpenChange: onClose, 53860 children: (0, import_jsx_runtime12.jsx)(Modal.Content, { 53861 children: (0, import_jsx_runtime12.jsx)(EditAssetContent, { 53862 onClose, 53863 canUpdate, 53864 canCopyLink, 53865 canDownload, 53866 ...restProps 53867 }) 53868 }) 53869 }); 53870}; 53871
vendor: 323 bytes, lines 53872-53876
53872// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EditFolderDialog/EditFolderDialog.mjs 53873var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1); 53874var React17 = __toESM(require_react(), 1); 53875var import_isEmpty = __toESM(require_isEmpty(), 1); 53876
vendor: 2,087 bytes, lines 53877-53947
53877// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/hooks/useBulkRemove.mjs 53878var import_qs10 = __toESM(require_lib(), 1); 53879var useBulkRemove = () => { 53880 const dispatch = useDispatch(); 53881 const { toggleNotification } = useNotification(); 53882 const { formatMessage } = useIntl(); 53883 const queryClient = useQueryClient(); 53884 const { post } = useFetchClient(); 53885 const bulkRemoveQuery = (filesAndFolders) => { 53886 const payload = filesAndFolders.reduce((acc, selected) => { 53887 const { id, type } = selected; 53888 const key = type === "asset" ? "fileIds" : "folderIds"; 53889 if (!acc[key]) { 53890 acc[key] = []; 53891 } 53892 acc[key].push(id); 53893 return acc; 53894 }, {}); 53895 return post("/upload/actions/bulk-delete", payload); 53896 }; 53897 const mutation = useMutation(bulkRemoveQuery, { 53898 onSuccess(res) { 53899 var _a3, _b; 53900 const { data: { data } } = res; 53901 if (((_a3 = data == null ? void 0 : data.files) == null ? void 0 : _a3.length) > 0) { 53902 queryClient.refetchQueries([ 53903 pluginId, 53904 "assets" 53905 ], { 53906 active: true 53907 }); 53908 queryClient.refetchQueries([ 53909 pluginId, 53910 "asset-count" 53911 ], { 53912 active: true 53913 }); 53914 } 53915 if (((_b = data == null ? void 0 : data.folders) == null ? void 0 : _b.length) > 0) { 53916 queryClient.refetchQueries([ 53917 pluginId, 53918 "folders" 53919 ], { 53920 active: true 53921 }); 53922 } 53923 toggleNotification({ 53924 type: "success", 53925 message: formatMessage({ 53926 id: getTrad("modal.remove.success-label"), 53927 defaultMessage: "Elements have been successfully deleted." 53928 }) 53929 }); 53930 dispatch(adminApi.util.invalidateTags([ 53931 "HomepageKeyStatistics" 53932 ])); 53933 }, 53934 onError(error) { 53935 toggleNotification({ 53936 type: "danger", 53937 message: error == null ? void 0 : error.message 53938 }); 53939 } 53940 }); 53941 const remove = (...args) => mutation.mutateAsync(...args); 53942 return { 53943 ...mutation, 53944 remove 53945 }; 53946}; 53947
vendor: 998 bytes, lines 53948-53984
53948// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/hooks/useEditFolder.mjs 53949var editFolderRequest = (put, post, { attrs, id }) => { 53950 const isEditing = !!id; 53951 const method = isEditing ? put : post; 53952 return method(`/upload/folders/${id ?? ""}`, attrs).then((res) => res.data); 53953}; 53954var useEditFolder = () => { 53955 const queryClient = useQueryClient(); 53956 const { put, post } = useFetchClient(); 53957 const mutation = useMutation((...args) => editFolderRequest(put, post, ...args), { 53958 async onSuccess() { 53959 await queryClient.refetchQueries([ 53960 pluginId, 53961 "folders" 53962 ], { 53963 active: true 53964 }); 53965 await queryClient.refetchQueries([ 53966 pluginId, 53967 "folder", 53968 "structure" 53969 ], { 53970 active: true 53971 }); 53972 } 53973 }); 53974 const editFolder = (attrs, id) => mutation.mutateAsync({ 53975 attrs, 53976 id 53977 }); 53978 return { 53979 ...mutation, 53980 editFolder, 53981 status: mutation.status 53982 }; 53983}; 53984
vendor: 1,462 bytes, lines 53985-54029
53985// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/utils/normalizeAPIError.mjs 53986function getPrefixedId(message, callback) { 53987 const prefixedMessage = `apiError.${message}`; 53988 if (typeof callback === "function") { 53989 return callback(prefixedMessage); 53990 } 53991 return prefixedMessage; 53992} 53993function normalizeError(error, { name, intlMessagePrefixCallback }) { 53994 const { message } = error; 53995 const normalizedError = { 53996 id: getPrefixedId(message, intlMessagePrefixCallback), 53997 defaultMessage: message, 53998 name: error.name ?? name, 53999 values: {} 54000 }; 54001 if ("path" in error) { 54002 normalizedError.values = { 54003 path: error.path.join(".") 54004 }; 54005 } 54006 return normalizedError; 54007} 54008var validateErrorIsYupValidationError = (err) => typeof err.details === "object" && err.details !== null && "errors" in err.details; 54009function normalizeAPIError(apiError, intlMessagePrefixCallback) { 54010 var _a3; 54011 const error = (_a3 = apiError.response) == null ? void 0 : _a3.data.error; 54012 if (error) { 54013 if (validateErrorIsYupValidationError(error)) { 54014 return { 54015 name: error.name, 54016 message: (error == null ? void 0 : error.message) || null, 54017 errors: error.details.errors.map((err) => normalizeError(err, { 54018 name: error.name, 54019 intlMessagePrefixCallback 54020 })) 54021 }; 54022 } 54023 return normalizeError(error, { 54024 intlMessagePrefixCallback 54025 }); 54026 } 54027 return null; 54028} 54029
vendor: 659 bytes, lines 54030-54046
54030// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/utils/getAPIInnerErrors.mjs 54031function getAPIInnerErrors(error, { getTrad: getTrad2 }) { 54032 const normalizedError = normalizeAPIError(error, getTrad2); 54033 if (normalizedError && "errors" in normalizedError) { 54034 return normalizedError.errors.reduce((acc, error2) => { 54035 if ("path" in error2.values) { 54036 acc[error2.values.path] = { 54037 id: error2.id, 54038 defaultMessage: error2.defaultMessage 54039 }; 54040 } 54041 return acc; 54042 }, {}); 54043 } 54044 return normalizedError == null ? void 0 : normalizedError.defaultMessage; 54045} 54046
vendor: 211 bytes, lines 54047-54049
54047// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EditFolderDialog/EditFolderDialog.mjs 54048var import_qs12 = __toESM(require_lib(), 1); 54049
vendor: 748 bytes, lines 54050-54067
54050// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EditFolderDialog/ModalHeader/ModalHeader.mjs 54051var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1); 54052var import_qs11 = __toESM(require_lib(), 1); 54053var EditFolderModalHeader = ({ isEditing = false }) => { 54054 const { formatMessage } = useIntl(); 54055 return (0, import_jsx_runtime13.jsx)(Modal.Header, { 54056 children: (0, import_jsx_runtime13.jsx)(Modal.Title, { 54057 children: formatMessage(isEditing ? { 54058 id: getTrad("modal.folder.edit.title"), 54059 defaultMessage: "Edit folder" 54060 } : { 54061 id: getTrad("modal.folder.create.title"), 54062 defaultMessage: "Add new folder" 54063 }) 54064 }) 54065 }); 54066}; 54067
vendor: 475 bytes, lines 54068-54079
54068// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EditFolderDialog/RemoveFolderDialog.mjs 54069var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1); 54070var RemoveFolderDialog = ({ onClose, onConfirm, open }) => { 54071 return (0, import_jsx_runtime14.jsx)(Dialog.Root, { 54072 open, 54073 onOpenChange: onClose, 54074 children: (0, import_jsx_runtime14.jsx)(ConfirmDialog, { 54075 onConfirm 54076 }) 54077 }); 54078}; 54079
vendor: 12,575 bytes, lines 54080-54383
54080// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EditFolderDialog/EditFolderDialog.mjs 54081var folderSchema = create3({ 54082 name: create().required(), 54083 parent: create3({ 54084 label: create(), 54085 value: create2().nullable(true) 54086 }).nullable(true) 54087}); 54088var EditFolderContent = ({ onClose, folder, location: location3, parentFolderId }) => { 54089 var _a3; 54090 const { data: folderStructure, isLoading: folderStructureIsLoading } = useFolderStructure({ 54091 enabled: true 54092 }); 54093 const { canCreate, isLoading: isLoadingPermissions, canUpdate } = useMediaLibraryPermissions(); 54094 const [showConfirmDialog, setShowConfirmDialog] = React17.useState(false); 54095 const { formatMessage, formatDate } = useIntl(); 54096 const { trackUsage } = useTracking(); 54097 const { editFolder, isLoading: isEditFolderLoading } = useEditFolder(); 54098 const { remove } = useBulkRemove(); 54099 const { toggleNotification } = useNotification(); 54100 const isLoading = isLoadingPermissions || folderStructureIsLoading; 54101 const isEditing = !!folder; 54102 const formDisabled = folder && !canUpdate || !folder && !canCreate; 54103 const initialFormData = !folderStructureIsLoading ? { 54104 name: (folder == null ? void 0 : folder.name) ?? "", 54105 parent: { 54106 /* ideally we would use folderStructure[0].value, but since it is null 54107 react complains about rendering null as field value */ 54108 value: parentFolderId ? parseInt(parentFolderId.toString(), 10) : void 0, 54109 label: parentFolderId ? folderStructure && ((_a3 = findRecursiveFolderByValue(folderStructure, parseInt(parentFolderId.toString(), 10))) == null ? void 0 : _a3.label) : folderStructure == null ? void 0 : folderStructure[0].label 54110 } 54111 } : { 54112 name: "", 54113 parent: null 54114 }; 54115 const formRef = React17.useRef(null); 54116 const handleKeyDown = (handleSubmit2) => (event) => { 54117 if (event.key === "Enter") { 54118 if (event.target instanceof HTMLInputElement) { 54119 handleSubmit2(event); 54120 event.preventDefault(); 54121 } 54122 } 54123 }; 54124 const handleSubmit = async (values, { setErrors }) => { 54125 var _a4, _b, _c; 54126 try { 54127 await editFolder({ 54128 ...values, 54129 parent: ((_a4 = values.parent) == null ? void 0 : _a4.value) ?? null 54130 }, folder == null ? void 0 : folder.id); 54131 toggleNotification({ 54132 type: "success", 54133 message: isEditing ? formatMessage({ 54134 id: getTrad("modal.folder-notification-edited-success"), 54135 defaultMessage: "Folder successfully edited" 54136 }) : formatMessage({ 54137 id: getTrad("modal.folder-notification-created-success"), 54138 defaultMessage: "Folder successfully created" 54139 }) 54140 }); 54141 if (isEditing) { 54142 const didChangeLocation = parentFolderId ? parseInt(parentFolderId.toString(), 10) !== ((_b = values.parent) == null ? void 0 : _b.value) : parentFolderId === null && !!((_c = values.parent) == null ? void 0 : _c.value); 54143 trackUsage("didEditMediaLibraryElements", { 54144 location: location3, 54145 type: "folder", 54146 changeLocation: didChangeLocation 54147 }); 54148 } else { 54149 trackUsage("didAddMediaLibraryFolders", { 54150 location: location3 54151 }); 54152 } 54153 onClose({ 54154 created: true 54155 }); 54156 } catch (err) { 54157 const errors = getAPIInnerErrors(err, { 54158 getTrad 54159 }); 54160 const formikErrors = Object.entries(errors).reduce((acc, [key, error]) => { 54161 acc[key] = error.defaultMessage; 54162 return acc; 54163 }, {}); 54164 if (!(0, import_isEmpty.default)(formikErrors)) { 54165 setErrors(formikErrors); 54166 } 54167 } 54168 }; 54169 const handleDelete = async () => { 54170 if (folder) { 54171 await remove([ 54172 folder 54173 ]); 54174 } 54175 setShowConfirmDialog(false); 54176 onClose(); 54177 }; 54178 if (isLoading) { 54179 return (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { 54180 children: [ 54181 (0, import_jsx_runtime15.jsx)(EditFolderModalHeader, { 54182 isEditing 54183 }), 54184 (0, import_jsx_runtime15.jsx)(Modal.Body, { 54185 children: (0, import_jsx_runtime15.jsx)(Flex, { 54186 justifyContent: "center", 54187 paddingTop: 4, 54188 paddingBottom: 4, 54189 children: (0, import_jsx_runtime15.jsx)(Loader, { 54190 children: formatMessage({ 54191 id: getTrad("content.isLoading"), 54192 defaultMessage: "Content is loading." 54193 }) 54194 }) 54195 }) 54196 }) 54197 ] 54198 }); 54199 } 54200 return (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { 54201 children: [ 54202 (0, import_jsx_runtime15.jsx)(Formik, { 54203 validationSchema: folderSchema, 54204 validateOnChange: false, 54205 onSubmit: handleSubmit, 54206 initialValues: initialFormData, 54207 children: ({ values, errors, handleChange, setFieldValue, handleSubmit: handleSubmit2 }) => { 54208 var _a4, _b; 54209 return (0, import_jsx_runtime15.jsxs)(Form, { 54210 noValidate: true, 54211 ref: formRef, 54212 onKeyDown: handleKeyDown(handleSubmit2), 54213 children: [ 54214 (0, import_jsx_runtime15.jsx)(EditFolderModalHeader, { 54215 isEditing 54216 }), 54217 (0, import_jsx_runtime15.jsx)(Modal.Body, { 54218 children: (0, import_jsx_runtime15.jsxs)(Grid.Root, { 54219 gap: 4, 54220 children: [ 54221 isEditing && (0, import_jsx_runtime15.jsx)(Grid.Item, { 54222 xs: 12, 54223 col: 12, 54224 direction: "column", 54225 alignItems: "stretch", 54226 children: (0, import_jsx_runtime15.jsx)(ContextInfo, { 54227 blocks: [ 54228 { 54229 label: formatMessage({ 54230 id: getTrad("modal.folder.create.elements"), 54231 defaultMessage: "Elements" 54232 }), 54233 value: formatMessage({ 54234 id: getTrad("modal.folder.elements.count"), 54235 defaultMessage: "{folderCount} folders, {assetCount} assets" 54236 }, { 54237 assetCount: ((_a4 = folder == null ? void 0 : folder.files) == null ? void 0 : _a4.count) ?? 0, 54238 folderCount: ((_b = folder == null ? void 0 : folder.children) == null ? void 0 : _b.count) ?? 0 54239 }) 54240 }, 54241 { 54242 label: formatMessage({ 54243 id: getTrad("modal.folder.create.creation-date"), 54244 defaultMessage: "Creation Date" 54245 }), 54246 value: formatDate(new Date(folder.createdAt)) 54247 } 54248 ] 54249 }) 54250 }), 54251 (0, import_jsx_runtime15.jsx)(Grid.Item, { 54252 xs: 12, 54253 col: 6, 54254 direction: "column", 54255 alignItems: "stretch", 54256 children: (0, import_jsx_runtime15.jsxs)(Field.Root, { 54257 name: "name", 54258 error: typeof errors.name === "string" ? errors.name : void 0, 54259 children: [ 54260 (0, import_jsx_runtime15.jsx)(Field.Label, { 54261 children: formatMessage({ 54262 id: getTrad("form.input.label.folder-name"), 54263 defaultMessage: "Name" 54264 }) 54265 }), 54266 (0, import_jsx_runtime15.jsx)(Field.Input, { 54267 value: values.name, 54268 onChange: handleChange, 54269 disabled: formDisabled 54270 }), 54271 (0, import_jsx_runtime15.jsx)(Field.Error, {}) 54272 ] 54273 }) 54274 }), 54275 (0, import_jsx_runtime15.jsx)(Grid.Item, { 54276 xs: 12, 54277 col: 6, 54278 direction: "column", 54279 alignItems: "stretch", 54280 children: (0, import_jsx_runtime15.jsxs)(Field.Root, { 54281 id: "folder-parent", 54282 children: [ 54283 (0, import_jsx_runtime15.jsx)(Field.Label, { 54284 children: formatMessage({ 54285 id: getTrad("form.input.label.folder-location"), 54286 defaultMessage: "Location" 54287 }) 54288 }), 54289 (0, import_jsx_runtime15.jsx)(SelectTree, { 54290 options: folderStructure, 54291 onChange: (value) => { 54292 setFieldValue("parent", value); 54293 }, 54294 isDisabled: formDisabled, 54295 defaultValue: values.parent, 54296 name: "parent", 54297 menuPortalTarget: document.querySelector("body"), 54298 inputId: "folder-parent", 54299 disabled: formDisabled, 54300 error: typeof errors.parent === "string" ? errors.parent : void 0, 54301 ariaErrorMessage: "folder-parent-error" 54302 }), 54303 errors.parent && (0, import_jsx_runtime15.jsx)(Typography, { 54304 variant: "pi", 54305 tag: "p", 54306 id: "folder-parent-error", 54307 textColor: "danger600", 54308 children: typeof errors.parent === "string" ? errors.parent : void 0 54309 }) 54310 ] 54311 }) 54312 }) 54313 ] 54314 }) 54315 }), 54316 (0, import_jsx_runtime15.jsxs)(Modal.Footer, { 54317 children: [ 54318 (0, import_jsx_runtime15.jsx)(Button, { 54319 onClick: () => onClose(), 54320 variant: "tertiary", 54321 name: "cancel", 54322 children: formatMessage({ 54323 id: "cancel", 54324 defaultMessage: "Cancel" 54325 }) 54326 }), 54327 (0, import_jsx_runtime15.jsxs)(Flex, { 54328 gap: 2, 54329 children: [ 54330 isEditing && canUpdate && (0, import_jsx_runtime15.jsx)(Button, { 54331 type: "button", 54332 variant: "danger-light", 54333 onClick: () => setShowConfirmDialog(true), 54334 name: "delete", 54335 disabled: !canUpdate || isEditFolderLoading, 54336 children: formatMessage({ 54337 id: getTrad("modal.folder.create.delete"), 54338 defaultMessage: "Delete folder" 54339 }) 54340 }), 54341 (0, import_jsx_runtime15.jsx)(Button, { 54342 name: "submit", 54343 loading: isEditFolderLoading, 54344 disabled: formDisabled, 54345 type: "submit", 54346 children: formatMessage(isEditing ? { 54347 id: getTrad("modal.folder.edit.submit"), 54348 defaultMessage: "Save" 54349 } : { 54350 id: getTrad("modal.folder.create.submit"), 54351 defaultMessage: "Create" 54352 }) 54353 }) 54354 ] 54355 }) 54356 ] 54357 }) 54358 ] 54359 }); 54360 } 54361 }), 54362 (0, import_jsx_runtime15.jsx)(RemoveFolderDialog, { 54363 open: showConfirmDialog, 54364 onClose: () => setShowConfirmDialog(false), 54365 onConfirm: handleDelete 54366 }) 54367 ] 54368 }); 54369}; 54370var EditFolderDialog = ({ open, onClose, ...restProps }) => { 54371 return (0, import_jsx_runtime15.jsx)(Modal.Root, { 54372 open, 54373 onOpenChange: onClose, 54374 children: (0, import_jsx_runtime15.jsx)(Modal.Content, { 54375 children: (0, import_jsx_runtime15.jsx)(EditFolderContent, { 54376 ...restProps, 54377 onClose, 54378 open 54379 }) 54380 }) 54381 }); 54382}; 54383
vendor: 1,063 bytes, lines 54384-54428
54384// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/hooks/useFolder.mjs 54385var import_qs13 = __toESM(require_lib(), 1); 54386var useFolder = (id, { enabled = true } = {}) => { 54387 const { toggleNotification } = useNotification(); 54388 const { get } = useFetchClient(); 54389 const { formatMessage } = useIntl(); 54390 const { data, error, isLoading } = useQuery([ 54391 pluginId, 54392 "folder", 54393 id 54394 ], async () => { 54395 const { data: { data: data2 } } = await get(`/upload/folders/${id}`, { 54396 params: { 54397 populate: { 54398 parent: { 54399 populate: { 54400 parent: "*" 54401 } 54402 } 54403 } 54404 } 54405 }); 54406 return data2; 54407 }, { 54408 retry: false, 54409 enabled, 54410 staleTime: 0, 54411 cacheTime: 0, 54412 onError() { 54413 toggleNotification({ 54414 type: "danger", 54415 message: formatMessage({ 54416 id: getTrad("notification.warning.404"), 54417 defaultMessage: "Not found" 54418 }) 54419 }); 54420 } 54421 }); 54422 return { 54423 data, 54424 error, 54425 isLoading 54426 }; 54427}; 54428
vendor: 718 bytes, lines 54429-54454
54429// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/hooks/usePersistentState.mjs 54430var import_react15 = __toESM(require_react(), 1); 54431var usePersistentState = (key, defaultValue) => { 54432 const [value, setValue] = (0, import_react15.useState)(() => { 54433 const stickyValue = window.localStorage.getItem(key); 54434 if (stickyValue !== null) { 54435 try { 54436 return JSON.parse(stickyValue); 54437 } catch { 54438 return stickyValue; 54439 } 54440 } 54441 return defaultValue; 54442 }); 54443 (0, import_react15.useEffect)(() => { 54444 window.localStorage.setItem(key, JSON.stringify(value)); 54445 }, [ 54446 key, 54447 value 54448 ]); 54449 return [ 54450 value, 54451 setValue 54452 ]; 54453}; 54454
vendor: 222 bytes, lines 54455-54457
54455// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/AssetGridList/AssetGridList.mjs 54456var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1); 54457
vendor: 259 bytes, lines 54458-54461
54458// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/AssetCard/AssetCard.mjs 54459var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1); 54460var import_qs17 = __toESM(require_lib(), 1); 54461
vendor: 219 bytes, lines 54462-54464
54462// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/AssetCard/AudioAssetCard.mjs 54463var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1); 54464
vendor: 3,762 bytes, lines 54465-54582
54465// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/AssetCard/AssetCardBase.mjs 54466var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1); 54467var import_react16 = __toESM(require_react(), 1); 54468var import_qs14 = __toESM(require_lib(), 1); 54469var Extension = dt.span` 54470 text-transform: uppercase; 54471`; 54472var CardActionsContainer = dt(CardActionImpl)` 54473 opacity: 0; 54474 z-index: 1; 54475 54476 &:focus-within { 54477 opacity: 1; 54478 } 54479`; 54480var CardCheckboxWrapper = dt.div` 54481 z-index: 1; 54482`; 54483var CardContainer = dt(Card)` 54484 cursor: pointer; 54485 54486 &:hover { 54487 ${CardActionsContainer} { 54488 opacity: 1; 54489 } 54490 } 54491`; 54492var AssetCardBase = ({ children, extension, isSelectable = false, name, onSelect, onRemove, onEdit, selected = false, subtitle = "", variant = "Image", className }) => { 54493 const { formatMessage } = useIntl(); 54494 const handleClick = (e) => { 54495 if (onEdit) { 54496 onEdit(e); 54497 } 54498 }; 54499 const handlePropagationClick = (e) => { 54500 e.stopPropagation(); 54501 }; 54502 return (0, import_jsx_runtime16.jsxs)(CardContainer, { 54503 className, 54504 role: "button", 54505 height: "100%", 54506 tabIndex: -1, 54507 onClick: handleClick, 54508 children: [ 54509 (0, import_jsx_runtime16.jsxs)(CardHeader, { 54510 children: [ 54511 isSelectable && (0, import_jsx_runtime16.jsx)(CardCheckboxWrapper, { 54512 onClick: handlePropagationClick, 54513 children: (0, import_jsx_runtime16.jsx)(CardCheckbox, { 54514 checked: selected, 54515 onCheckedChange: onSelect 54516 }) 54517 }), 54518 (onRemove || onEdit) && (0, import_jsx_runtime16.jsxs)(CardActionsContainer, { 54519 onClick: handlePropagationClick, 54520 position: "end", 54521 children: [ 54522 onRemove && (0, import_jsx_runtime16.jsx)(IconButton, { 54523 label: formatMessage({ 54524 id: getTrad("control-card.remove-selection"), 54525 defaultMessage: "Remove from selection" 54526 }), 54527 onClick: onRemove, 54528 children: (0, import_jsx_runtime16.jsx)(ForwardRef$b, {}) 54529 }), 54530 onEdit && (0, import_jsx_runtime16.jsx)(IconButton, { 54531 label: formatMessage({ 54532 id: getTrad("control-card.edit"), 54533 defaultMessage: "Edit" 54534 }), 54535 onClick: onEdit, 54536 children: (0, import_jsx_runtime16.jsx)(ForwardRef$N, {}) 54537 }) 54538 ] 54539 }), 54540 children 54541 ] 54542 }), 54543 (0, import_jsx_runtime16.jsxs)(CardBody, { 54544 children: [ 54545 (0, import_jsx_runtime16.jsxs)(CardContent, { 54546 children: [ 54547 (0, import_jsx_runtime16.jsx)(Box, { 54548 paddingTop: 1, 54549 children: (0, import_jsx_runtime16.jsx)(Typography, { 54550 tag: "h2", 54551 children: (0, import_jsx_runtime16.jsx)(CardTitle, { 54552 tag: "span", 54553 children: name 54554 }) 54555 }) 54556 }), 54557 (0, import_jsx_runtime16.jsxs)(CardSubtitle, { 54558 children: [ 54559 (0, import_jsx_runtime16.jsx)(Extension, { 54560 children: extension 54561 }), 54562 subtitle 54563 ] 54564 }) 54565 ] 54566 }), 54567 (0, import_jsx_runtime16.jsx)(Flex, { 54568 paddingTop: 1, 54569 grow: 1, 54570 children: (0, import_jsx_runtime16.jsx)(CardBadge, { 54571 children: formatMessage({ 54572 id: getTrad(`settings.section.${variant.toLowerCase()}.label`), 54573 defaultMessage: variant 54574 }) 54575 }) 54576 }) 54577 ] 54578 }) 54579 ] 54580 }); 54581}; 54582
vendor: 431 bytes, lines 54583-54594
54583// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/AssetCard/AudioPreview.mjs 54584var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1); 54585var AudioPreview = ({ url, alt }) => { 54586 return (0, import_jsx_runtime17.jsx)(Box, { 54587 children: (0, import_jsx_runtime17.jsx)("audio", { 54588 controls: true, 54589 src: url, 54590 children: alt 54591 }) 54592 }); 54593}; 54594
vendor: 923 bytes, lines 54595-54625
54595// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/AssetCard/AudioAssetCard.mjs 54596var AudioPreviewWrapper = dt(Box)` 54597 canvas, 54598 audio { 54599 display: block; 54600 max-width: 100%; 54601 max-height: ${({ size }) => size === "M" ? 16.4 : 8.8}rem; 54602 } 54603`; 54604var AudioAssetCard = ({ name, url, size = "M", selected = false, ...restProps }) => { 54605 return (0, import_jsx_runtime18.jsx)(AssetCardBase, { 54606 name, 54607 selected, 54608 ...restProps, 54609 variant: "Audio", 54610 children: (0, import_jsx_runtime18.jsx)(CardAsset, { 54611 size, 54612 children: (0, import_jsx_runtime18.jsx)(Flex, { 54613 alignItems: "center", 54614 children: (0, import_jsx_runtime18.jsx)(AudioPreviewWrapper, { 54615 size, 54616 children: (0, import_jsx_runtime18.jsx)(AudioPreview, { 54617 url, 54618 alt: name 54619 }) 54620 }) 54621 }) 54622 }) 54623 }); 54624}; 54625
vendor: 1,608 bytes, lines 54626-54673
54626// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/AssetCard/DocAssetCard.mjs 54627var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1); 54628var CardAsset3 = dt(Flex)` 54629 border-radius: ${({ theme }) => theme.borderRadius} ${({ theme }) => theme.borderRadius} 0 0; 54630 background: linear-gradient( 54631 180deg, 54632 ${({ theme }) => theme.colors.neutral0} 0%, 54633 ${({ theme }) => theme.colors.neutral100} 121.48% 54634 ); 54635`; 54636var DocAssetCard = ({ name, extension, size = "M", selected = false, ...restProps }) => { 54637 const { formatMessage } = useIntl(); 54638 const IconComponent = getFileIconComponent(extension); 54639 return (0, import_jsx_runtime19.jsx)(AssetCardBase, { 54640 name, 54641 extension, 54642 selected, 54643 ...restProps, 54644 variant: "Doc", 54645 children: (0, import_jsx_runtime19.jsx)(CardAsset3, { 54646 width: "100%", 54647 height: size === "S" ? `8.8rem` : `16.4rem`, 54648 justifyContent: "center", 54649 children: (0, import_jsx_runtime19.jsxs)(Flex, { 54650 gap: 2, 54651 direction: "column", 54652 alignItems: "center", 54653 children: [ 54654 (0, import_jsx_runtime19.jsx)(IconComponent, { 54655 "aria-label": name, 54656 fill: "neutral500", 54657 width: 24, 54658 height: 24 54659 }), 54660 (0, import_jsx_runtime19.jsx)(Typography, { 54661 textColor: "neutral500", 54662 variant: "pi", 54663 children: formatMessage({ 54664 id: "noPreview", 54665 defaultMessage: "No preview available" 54666 }) 54667 }) 54668 ] 54669 }) 54670 }) 54671 }); 54672}; 54673
vendor: 219 bytes, lines 54674-54676
54674// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/AssetCard/ImageAssetCard.mjs 54675var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1); 54676
vendor: 523 bytes, lines 54677-54690
54677// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/utils/appendSearchParamsToUrl.mjs 54678var appendSearchParamsToUrl = ({ url, params }) => { 54679 if (url === void 0 || typeof params !== "object") { 54680 return url; 54681 } 54682 const urlObj = new URL(url, window.strapi.backendURL); 54683 Object.entries(params).forEach(([key, value]) => { 54684 if (value !== void 0 && value !== null) { 54685 urlObj.searchParams.append(key, value); 54686 } 54687 }); 54688 return urlObj.toString(); 54689}; 54690
vendor: 784 bytes, lines 54691-54713
54691// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/AssetCard/ImageAssetCard.mjs 54692var import_qs15 = __toESM(require_lib(), 1); 54693var ImageAssetCard = ({ height, width, thumbnail, size = "M", alt, isUrlSigned, selected = false, ...props }) => { 54694 const thumbnailUrl = isUrlSigned ? thumbnail : appendSearchParamsToUrl({ 54695 url: thumbnail, 54696 params: { 54697 updatedAt: props.updatedAt 54698 } 54699 }); 54700 const subtitle = height && width ? ` - ${width}â${height}` : void 0; 54701 return (0, import_jsx_runtime20.jsx)(AssetCardBase, { 54702 ...props, 54703 selected, 54704 subtitle, 54705 variant: "Image", 54706 children: (0, import_jsx_runtime20.jsx)(CardAsset, { 54707 src: thumbnailUrl, 54708 size, 54709 alt 54710 }) 54711 }); 54712}; 54713
vendor: 262 bytes, lines 54714-54717
54714// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/AssetCard/VideoAssetCard.mjs 54715var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1); 54716var React18 = __toESM(require_react(), 1); 54717
vendor: 432 bytes, lines 54718-54727
54718// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/utils/formatDuration.mjs 54719var zeroPad = (num) => String(num).padStart(2, "0"); 54720var formatDuration = (durationInSecond) => { 54721 const duration = intervalToDuration({ 54722 start: 0, 54723 end: durationInSecond * 1e3 54724 }); 54725 return `${zeroPad(duration.hours)}:${zeroPad(duration.minutes)}:${zeroPad(duration.seconds)}`; 54726}; 54727
vendor: 202 bytes, lines 54728-54730
54728// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/AssetCard/VideoAssetCard.mjs 54729var import_qs16 = __toESM(require_lib(), 1); 54730
vendor: 1,557 bytes, lines 54731-54775
54731// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/AssetCard/VideoPreview.mjs 54732var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1); 54733var import_react17 = __toESM(require_react(), 1); 54734var HAVE_FUTURE_DATA = 3; 54735var VideoPreview = ({ url, mime, onLoadDuration = () => { 54736}, alt, ...props }) => { 54737 const handleTimeUpdate = (e) => { 54738 var _a3; 54739 if (e.currentTarget.currentTime > 0) { 54740 const video = e.currentTarget; 54741 const canvas = document.createElement("canvas"); 54742 canvas.height = video.videoHeight; 54743 canvas.width = video.videoWidth; 54744 (_a3 = canvas.getContext("2d")) == null ? void 0 : _a3.drawImage(video, 0, 0, video.videoWidth, video.videoHeight); 54745 video.replaceWith(canvas); 54746 onLoadDuration && onLoadDuration(video.duration); 54747 } 54748 }; 54749 const handleThumbnailVisibility = (e) => { 54750 const video = e.currentTarget; 54751 if (video.readyState < HAVE_FUTURE_DATA) return; 54752 video.play(); 54753 }; 54754 return (0, import_jsx_runtime21.jsxs)(Box, { 54755 tag: "figure", 54756 ...props, 54757 children: [ 54758 (0, import_jsx_runtime21.jsx)("video", { 54759 muted: true, 54760 onLoadedData: handleThumbnailVisibility, 54761 src: url, 54762 crossOrigin: "anonymous", 54763 onTimeUpdate: handleTimeUpdate, 54764 children: (0, import_jsx_runtime21.jsx)("source", { 54765 type: mime 54766 }) 54767 }), 54768 (0, import_jsx_runtime21.jsx)(VisuallyHidden, { 54769 tag: "figcaption", 54770 children: alt 54771 }) 54772 ] 54773 }, url); 54774}; 54775
vendor: 1,156 bytes, lines 54776-54813
54776// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/AssetCard/VideoAssetCard.mjs 54777var VideoPreviewWrapper = dt(Box)` 54778 canvas, 54779 video { 54780 display: block; 54781 pointer-events: none; 54782 max-width: 100%; 54783 max-height: ${({ size }) => size === "M" ? 16.4 : 8.8}rem; 54784 } 54785`; 54786var VideoAssetCard = ({ name, url, mime, size = "M", selected = false, ...props }) => { 54787 const [duration, setDuration] = React18.useState(); 54788 const formattedDuration = duration && formatDuration(duration); 54789 return (0, import_jsx_runtime22.jsxs)(AssetCardBase, { 54790 selected, 54791 name, 54792 ...props, 54793 variant: "Video", 54794 children: [ 54795 (0, import_jsx_runtime22.jsx)(CardAsset, { 54796 size, 54797 children: (0, import_jsx_runtime22.jsx)(VideoPreviewWrapper, { 54798 size, 54799 children: (0, import_jsx_runtime22.jsx)(VideoPreview, { 54800 url, 54801 mime, 54802 onLoadDuration: setDuration, 54803 alt: name 54804 }) 54805 }) 54806 }), 54807 (0, import_jsx_runtime22.jsx)(CardTimer, { 54808 children: formattedDuration || "..." 54809 }) 54810 ] 54811 }); 54812}; 54813
vendor: 1,798 bytes, lines 54814-54857
54814// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/AssetCard/AssetCard.mjs 54815var AssetCard = ({ asset, isSelected = false, onSelect, onEdit, onRemove, size = "M", local = false, className }) => { 54816 var _a3, _b, _c, _d, _e5; 54817 const handleSelect = onSelect ? () => onSelect(asset) : void 0; 54818 const commonAssetCardProps = { 54819 id: asset.id, 54820 isSelectable: asset.isSelectable, 54821 extension: getFileExtension(asset.ext), 54822 name: asset.name, 54823 url: local ? asset.url : createAssetUrl(asset, true), 54824 mime: asset.mime, 54825 onEdit: onEdit ? () => onEdit(asset) : void 0, 54826 onSelect: handleSelect, 54827 onRemove: onRemove ? () => onRemove(asset) : void 0, 54828 selected: isSelected, 54829 size, 54830 className 54831 }; 54832 if ((_a3 = asset.mime) == null ? void 0 : _a3.includes(AssetType.Video)) { 54833 return (0, import_jsx_runtime23.jsx)(VideoAssetCard, { 54834 ...commonAssetCardProps 54835 }); 54836 } 54837 if ((_b = asset.mime) == null ? void 0 : _b.includes(AssetType.Image)) { 54838 return (0, import_jsx_runtime23.jsx)(ImageAssetCard, { 54839 alt: asset.alternativeText || asset.name, 54840 height: asset.height, 54841 thumbnail: prefixFileUrlWithBackendUrl(((_d = (_c = asset == null ? void 0 : asset.formats) == null ? void 0 : _c.thumbnail) == null ? void 0 : _d.url) || asset.url), 54842 width: asset.width, 54843 updatedAt: asset.updatedAt, 54844 isUrlSigned: (asset == null ? void 0 : asset.isUrlSigned) || false, 54845 ...commonAssetCardProps 54846 }); 54847 } 54848 if ((_e5 = asset.mime) == null ? void 0 : _e5.includes(AssetType.Audio)) { 54849 return (0, import_jsx_runtime23.jsx)(AudioAssetCard, { 54850 ...commonAssetCardProps 54851 }); 54852 } 54853 return (0, import_jsx_runtime23.jsx)(DocAssetCard, { 54854 ...commonAssetCardProps 54855 }); 54856}; 54857
vendor: 1,062 bytes, lines 54858-54898
54858// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/AssetGridList/Draggable.mjs 54859var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1); 54860var React19 = __toESM(require_react(), 1); 54861var Draggable = ({ children, id, index: index2, moveItem }) => { 54862 const ref = React19.useRef(null); 54863 const [, drop] = useDrop({ 54864 accept: "draggable", 54865 hover(hoveredOverItem) { 54866 if (!ref.current) { 54867 return; 54868 } 54869 if (hoveredOverItem.id !== id) { 54870 moveItem(hoveredOverItem.index, index2); 54871 hoveredOverItem.index = index2; 54872 } 54873 } 54874 }); 54875 const [{ isDragging }, drag] = useDrag({ 54876 type: "draggable", 54877 item() { 54878 return { 54879 index: index2, 54880 id 54881 }; 54882 }, 54883 collect: (monitor) => ({ 54884 isDragging: monitor.isDragging() 54885 }) 54886 }); 54887 const opacity = isDragging ? 0.2 : 1; 54888 drag(drop(ref)); 54889 return (0, import_jsx_runtime24.jsx)("div", { 54890 ref, 54891 style: { 54892 opacity, 54893 cursor: "move" 54894 }, 54895 children 54896 }); 54897}; 54898
vendor: 2,285 bytes, lines 54899-54966
54899// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/AssetGridList/AssetGridList.mjs 54900var DraggableAssetCard = dt(AssetCard)` 54901 && { 54902 cursor: inherit; 54903 } 54904`; 54905var AssetGridList = ({ allowedTypes = [ 54906 "files", 54907 "images", 54908 "videos", 54909 "audios" 54910], assets, onEditAsset, onSelectAsset, selectedAssets, size = "M", onReorderAsset, title = null }) => { 54911 return (0, import_jsx_runtime25.jsxs)(KeyboardNavigable, { 54912 tagName: "article", 54913 children: [ 54914 title && (0, import_jsx_runtime25.jsx)(Box, { 54915 paddingTop: 2, 54916 paddingBottom: 2, 54917 children: (0, import_jsx_runtime25.jsx)(Typography, { 54918 tag: "h2", 54919 variant: "delta", 54920 fontWeight: "semiBold", 54921 children: title 54922 }) 54923 }), 54924 (0, import_jsx_runtime25.jsx)(Grid.Root, { 54925 gap: 4, 54926 children: assets.map((asset, index2) => { 54927 const isSelected = !!selectedAssets.find((currentAsset) => currentAsset.id === asset.id); 54928 if (onReorderAsset) { 54929 return (0, import_jsx_runtime25.jsx)(Grid.Item, { 54930 col: 3, 54931 height: "100%", 54932 children: (0, import_jsx_runtime25.jsx)(Draggable, { 54933 index: index2, 54934 moveItem: onReorderAsset, 54935 id: asset.id, 54936 children: (0, import_jsx_runtime25.jsx)(DraggableAssetCard, { 54937 allowedTypes, 54938 asset, 54939 isSelected, 54940 onEdit: onEditAsset ? () => onEditAsset(asset) : void 0, 54941 onSelect: () => onSelectAsset(asset), 54942 size 54943 }) 54944 }) 54945 }, asset.id); 54946 } 54947 return (0, import_jsx_runtime25.jsx)(Grid.Item, { 54948 col: 3, 54949 height: "100%", 54950 direction: "column", 54951 alignItems: "stretch", 54952 children: (0, import_jsx_runtime25.jsx)(AssetCard, { 54953 allowedTypes, 54954 asset, 54955 isSelected, 54956 onEdit: onEditAsset ? () => onEditAsset(asset) : void 0, 54957 onSelect: () => onSelectAsset(asset), 54958 size 54959 }, asset.id) 54960 }, asset.id); 54961 }) 54962 }) 54963 ] 54964 }); 54965}; 54966
vendor: 539 bytes, lines 54967-54980
54967// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/utils/getFolderURL.mjs 54968var import_qs18 = __toESM(require_lib(), 1); 54969var getFolderURL = (pathname, currentQuery, { folder, folderPath } = {}) => { 54970 const { _q, ...queryParamsWithoutQ } = currentQuery; 54971 const queryParamsString = (0, import_qs18.stringify)({ 54972 ...queryParamsWithoutQ, 54973 folder, 54974 folderPath 54975 }, { 54976 encode: false 54977 }); 54978 return `${pathname}${queryParamsString ? `?${queryParamsString}` : ""}`; 54979}; 54980
vendor: 270 bytes, lines 54981-54984
54981// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/FolderCard/FolderCard/FolderCard.mjs 54982var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1); 54983var React20 = __toESM(require_react(), 1); 54984
vendor: 365 bytes, lines 54985-54991
54985// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/FolderCard/contexts/FolderCard.mjs 54986var import_react18 = __toESM(require_react(), 1); 54987var FolderCardContext = (0, import_react18.createContext)({}); 54988function useFolderCard() { 54989 return (0, import_react18.useContext)(FolderCardContext); 54990} 54991
vendor: 2,618 bytes, lines 54992-55086
54992// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/FolderCard/FolderCard/FolderCard.mjs 54993var FauxClickWrapper = dt.button` 54994 height: 100%; 54995 left: 0; 54996 position: absolute; 54997 opacity: 0; 54998 top: 0; 54999 width: 100%; 55000 55001 &:hover, 55002 &:focus { 55003 text-decoration: none; 55004 } 55005`; 55006var StyledFolder = dt(ForwardRef$1H)` 55007 path { 55008 fill: currentColor; 55009 } 55010`; 55011var CardActionDisplay = dt(Box)` 55012 display: none; 55013`; 55014var Card2 = dt(Box)` 55015 &:hover, 55016 &:focus-within { 55017 ${CardActionDisplay} { 55018 display: ${({ $isCardActions }) => $isCardActions ? "block" : ""}; 55019 } 55020 } 55021`; 55022var FolderCard = React20.forwardRef(({ children, startAction = null, cardActions = null, ariaLabel, onClick, to, ...props }, ref) => { 55023 const generatedId = React20.useId(); 55024 const fodlerCtxValue = React20.useMemo(() => ({ 55025 id: generatedId 55026 }), [ 55027 generatedId 55028 ]); 55029 return (0, import_jsx_runtime26.jsx)(FolderCardContext.Provider, { 55030 value: fodlerCtxValue, 55031 children: (0, import_jsx_runtime26.jsxs)(Card2, { 55032 position: "relative", 55033 tabIndex: 0, 55034 $isCardActions: !!cardActions, 55035 ref, 55036 ...props, 55037 children: [ 55038 (0, import_jsx_runtime26.jsx)(FauxClickWrapper, { 55039 to: to || void 0, 55040 as: to ? NavLink : "button", 55041 type: to ? void 0 : "button", 55042 onClick, 55043 tabIndex: -1, 55044 "aria-label": ariaLabel, 55045 "aria-hidden": true 55046 }), 55047 (0, import_jsx_runtime26.jsxs)(Flex, { 55048 hasRadius: true, 55049 borderStyle: "solid", 55050 borderWidth: "1px", 55051 borderColor: "neutral150", 55052 background: "neutral0", 55053 shadow: "tableShadow", 55054 padding: 3, 55055 gap: 2, 55056 cursor: "pointer", 55057 children: [ 55058 startAction, 55059 (0, import_jsx_runtime26.jsx)(Box, { 55060 hasRadius: true, 55061 background: "secondary100", 55062 color: "secondary500", 55063 paddingBottom: 2, 55064 paddingLeft: 3, 55065 paddingRight: 3, 55066 paddingTop: 2, 55067 children: (0, import_jsx_runtime26.jsx)(StyledFolder, { 55068 width: "2.4rem", 55069 height: "2.4rem" 55070 }) 55071 }), 55072 children, 55073 (0, import_jsx_runtime26.jsx)(CardActionDisplay, { 55074 children: (0, import_jsx_runtime26.jsx)(CardActionImpl, { 55075 right: 4, 55076 position: "end", 55077 children: cardActions 55078 }) 55079 }) 55080 ] 55081 }) 55082 ] 55083 }) 55084 }); 55085}); 55086
vendor: 611 bytes, lines 55087-55105
55087// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/FolderCard/FolderCardBody/FolderCardBody.mjs 55088var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1); 55089var StyledBox = dt(Flex)` 55090 user-select: none; 55091`; 55092var FolderCardBody = (props) => { 55093 const { id } = useFolderCard(); 55094 return (0, import_jsx_runtime27.jsx)(StyledBox, { 55095 ...props, 55096 id: `${id}-title`, 55097 "data-testid": `${id}-title`, 55098 alignItems: "flex-start", 55099 direction: "column", 55100 maxWidth: "100%", 55101 overflow: "hidden", 55102 position: "relative" 55103 }); 55104}; 55105
vendor: 945 bytes, lines 55106-55137
55106// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/FolderCard/FolderCardBodyAction/FolderCardBodyAction.mjs 55107var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1); 55108var BoxOutline = dt(Box)` 55109 &:focus { 55110 outline: 2px solid ${({ theme }) => theme.colors.primary600}; 55111 outline-offset: -2px; 55112 } 55113`; 55114var BoxTextDecoration = dt(BoxOutline)` 55115 text-decoration: none; 55116`; 55117var FolderCardBodyAction = ({ to, ...props }) => { 55118 if (to) { 55119 return (0, import_jsx_runtime28.jsx)(BoxTextDecoration, { 55120 // padding needed to give outline space to appear 55121 // since FolderCardBody needs overflow hidden property 55122 padding: 1, 55123 tag: NavLink, 55124 maxWidth: "100%", 55125 to, 55126 ...props 55127 }); 55128 } 55129 return (0, import_jsx_runtime28.jsx)(BoxOutline, { 55130 padding: 1, 55131 tag: "button", 55132 type: "button", 55133 maxWidth: "100%", 55134 ...props 55135 }); 55136}; 55137
vendor: 806 bytes, lines 55138-55161
55138// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/FolderGridList/FolderGridList.mjs 55139var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1); 55140var import_react19 = __toESM(require_react(), 1); 55141var FolderGridList = ({ title = null, children }) => { 55142 return (0, import_jsx_runtime29.jsxs)(KeyboardNavigable, { 55143 tagName: "article", 55144 children: [ 55145 title && (0, import_jsx_runtime29.jsx)(Box, { 55146 paddingBottom: 2, 55147 children: (0, import_jsx_runtime29.jsx)(Typography, { 55148 tag: "h2", 55149 variant: "delta", 55150 fontWeight: "semiBold", 55151 children: title 55152 }) 55153 }), 55154 (0, import_jsx_runtime29.jsx)(Grid.Root, { 55155 gap: 4, 55156 children 55157 }) 55158 ] 55159 }); 55160}; 55161
vendor: 967 bytes, lines 55162-55188
55162// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/SortPicker/SortPicker.mjs 55163var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1); 55164var import_qs19 = __toESM(require_lib(), 1); 55165var SortPicker = ({ onChangeSort, value }) => { 55166 const { formatMessage } = useIntl(); 55167 return (0, import_jsx_runtime30.jsx)(SingleSelect, { 55168 size: "S", 55169 value, 55170 onChange: (value2) => onChangeSort(value2.toString()), 55171 "aria-label": formatMessage({ 55172 id: getTrad("sort.label"), 55173 defaultMessage: "Sort by" 55174 }), 55175 placeholder: formatMessage({ 55176 id: getTrad("sort.label"), 55177 defaultMessage: "Sort by" 55178 }), 55179 children: sortOptions.map((filter) => (0, import_jsx_runtime30.jsx)(SingleSelectOption, { 55180 value: filter.value, 55181 children: formatMessage({ 55182 id: getTrad(filter.key), 55183 defaultMessage: `${filter.value}` 55184 }) 55185 }, filter.key)) 55186 }); 55187}; 55188
vendor: 259 bytes, lines 55189-55192
55189// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/TableList/TableList.mjs 55190var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1); 55191var import_qs23 = __toESM(require_lib(), 1); 55192
vendor: 259 bytes, lines 55193-55196
55193// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/TableList/TableRows.mjs 55194var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1); 55195var import_qs22 = __toESM(require_lib(), 1); 55196
vendor: 261 bytes, lines 55197-55200
55197// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/TableList/CellContent.mjs 55198var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1); 55199var import_qs21 = __toESM(require_lib(), 1); 55200
vendor: 3,037 bytes, lines 55201-55295
55201// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/TableList/PreviewCell.mjs 55202var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1); 55203var import_qs20 = __toESM(require_lib(), 1); 55204var VideoPreviewWrapper2 = dt(Box)` 55205 figure { 55206 width: ${({ theme }) => theme.spaces[7]}; 55207 height: ${({ theme }) => theme.spaces[7]}; 55208 } 55209 55210 canvas, 55211 video { 55212 width: 100%; 55213 height: 100%; 55214 object-fit: cover; 55215 border-radius: 50%; 55216 } 55217`; 55218var PreviewCell = ({ type, content }) => { 55219 var _a3; 55220 const { formatMessage } = useIntl(); 55221 if (type === "folder") { 55222 return (0, import_jsx_runtime31.jsx)(Flex, { 55223 justifyContent: "center", 55224 background: "secondary100", 55225 width: "3.2rem", 55226 height: "3.2rem", 55227 borderRadius: "50%", 55228 children: (0, import_jsx_runtime31.jsx)(ForwardRef$1H, { 55229 "aria-label": formatMessage({ 55230 id: getTrad("header.actions.add-assets.folder"), 55231 defaultMessage: "folder" 55232 }), 55233 fill: "secondary500", 55234 width: "1.6rem", 55235 height: "1.6rem" 55236 }) 55237 }); 55238 } 55239 const { alternativeText, ext, formats, mime, name, url } = content; 55240 const fileExtension = getFileExtension(ext); 55241 if (mime == null ? void 0 : mime.includes(AssetType.Image)) { 55242 const mediaURL = prefixFileUrlWithBackendUrl((_a3 = formats == null ? void 0 : formats.thumbnail) == null ? void 0 : _a3.url) ?? prefixFileUrlWithBackendUrl(url); 55243 return (0, import_jsx_runtime31.jsx)(Avatar.Item, { 55244 src: mediaURL, 55245 alt: alternativeText || void 0, 55246 preview: true, 55247 fallback: alternativeText 55248 }); 55249 } 55250 if (mime == null ? void 0 : mime.includes(AssetType.Video)) { 55251 return (0, import_jsx_runtime31.jsx)(VideoPreviewWrapper2, { 55252 children: (0, import_jsx_runtime31.jsx)(VideoPreview, { 55253 url: createAssetUrl(content, true) || "", 55254 mime, 55255 alt: alternativeText ?? name 55256 }) 55257 }); 55258 } 55259 if (mime == null ? void 0 : mime.includes(AssetType.Audio)) { 55260 return (0, import_jsx_runtime31.jsx)(Flex, { 55261 background: "neutral100", 55262 borderRadius: "100%", 55263 color: "neutral500", 55264 width: "3.2rem", 55265 height: "3.2rem", 55266 justifyContent: "center", 55267 children: (0, import_jsx_runtime31.jsx)(ForwardRef$4, { 55268 width: 16, 55269 height: 16 55270 }) 55271 }); 55272 } 55273 const DOC_ICON_MAP = { 55274 pdf: ForwardRef$1M, 55275 csv: ForwardRef$1O, 55276 xls: ForwardRef$1L, 55277 zip: ForwardRef$1K 55278 }; 55279 const DocIcon = fileExtension ? DOC_ICON_MAP[fileExtension] || ForwardRef$1P : ForwardRef$1P; 55280 const testId = fileExtension && DOC_ICON_MAP[fileExtension] ? `file-${fileExtension}-icon` : "file-icon"; 55281 return (0, import_jsx_runtime31.jsx)(Flex, { 55282 justifyContent: "center", 55283 borderRadius: "100%", 55284 background: "neutral100", 55285 color: "neutral500", 55286 width: "3.2rem", 55287 height: "3.2rem", 55288 children: (0, import_jsx_runtime31.jsx)(DocIcon, { 55289 width: 16, 55290 height: 16, 55291 "data-testid": testId 55292 }) 55293 }); 55294}; 55295
vendor: 2,134 bytes, lines 55296-55357
55296// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/TableList/CellContent.mjs 55297var CellContent = ({ cellType, contentType, content, name }) => { 55298 var _a3; 55299 const { formatDate, formatMessage } = useIntl(); 55300 const contentValue = content[name]; 55301 switch (cellType) { 55302 case "image": 55303 return (0, import_jsx_runtime32.jsx)(PreviewCell, { 55304 type: contentType, 55305 content 55306 }); 55307 case "date": 55308 if (typeof contentValue === "string") { 55309 return (0, import_jsx_runtime32.jsx)(Typography, { 55310 children: formatDate(parseISO(contentValue), { 55311 dateStyle: "full" 55312 }) 55313 }); 55314 } 55315 case "size": 55316 if (contentType === "folder") return (0, import_jsx_runtime32.jsx)(Typography, { 55317 "aria-label": formatMessage({ 55318 id: "list.table.content.empty-label", 55319 defaultMessage: "This field is empty" 55320 }), 55321 children: "-" 55322 }); 55323 if (typeof contentValue === "string" || typeof contentValue === "number") { 55324 return (0, import_jsx_runtime32.jsx)(Typography, { 55325 children: formatBytes(contentValue) 55326 }); 55327 } 55328 case "ext": 55329 if (contentType === "folder") return (0, import_jsx_runtime32.jsx)(Typography, { 55330 "aria-label": formatMessage({ 55331 id: "list.table.content.empty-label", 55332 defaultMessage: "This field is empty" 55333 }), 55334 children: "-" 55335 }); 55336 if (typeof contentValue === "string") { 55337 return (0, import_jsx_runtime32.jsx)(Typography, { 55338 children: (_a3 = getFileExtension(contentValue)) == null ? void 0 : _a3.toUpperCase() 55339 }); 55340 } 55341 case "text": 55342 if (typeof contentValue === "string") { 55343 return (0, import_jsx_runtime32.jsx)(Typography, { 55344 children: contentValue 55345 }); 55346 } 55347 default: 55348 return (0, import_jsx_runtime32.jsx)(Typography, { 55349 "aria-label": formatMessage({ 55350 id: "list.table.content.empty-label", 55351 defaultMessage: "This field is empty" 55352 }), 55353 children: "-" 55354 }); 55355 } 55356}; 55357
vendor: 3,735 bytes, lines 55358-55445
55358// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/TableList/TableRows.mjs 55359var TableRows = ({ onChangeFolder = null, onEditAsset, onEditFolder, onSelectOne, rows = [], selected = [] }) => { 55360 const { formatMessage } = useIntl(); 55361 const handleRowClickFn = (element, id, path, elementType) => { 55362 if (elementType === "asset") { 55363 onEditAsset(element); 55364 } else { 55365 if (onChangeFolder) { 55366 onChangeFolder(id, path); 55367 } 55368 } 55369 }; 55370 return (0, import_jsx_runtime33.jsx)(Tbody, { 55371 children: rows.map((element) => { 55372 const { path, id, isSelectable, name, folderURL, type: contentType } = element; 55373 const isSelected = !!selected.find((currentRow) => currentRow.id === id && currentRow.type === contentType); 55374 return (0, import_jsx_runtime33.jsxs)(Tr, { 55375 onClick: () => handleRowClickFn(element, id, path || void 0, contentType), 55376 children: [ 55377 (0, import_jsx_runtime33.jsx)(Td, { 55378 onClick: (e) => e.stopPropagation(), 55379 children: (0, import_jsx_runtime33.jsx)(CheckboxImpl, { 55380 "aria-label": formatMessage({ 55381 id: contentType === "asset" ? "list-assets-select" : "list.folder.select", 55382 defaultMessage: contentType === "asset" ? "Select {name} asset" : "Select {name} folder" 55383 }, { 55384 name 55385 }), 55386 disabled: !isSelectable, 55387 onCheckedChange: () => onSelectOne(element), 55388 onPointerDown: (e) => { 55389 e.preventDefault(); 55390 }, 55391 checked: isSelected 55392 }) 55393 }), 55394 tableHeaders.map(({ name: name2, type: cellType }) => { 55395 return (0, import_jsx_runtime33.jsx)(Td, { 55396 children: (0, import_jsx_runtime33.jsx)(CellContent, { 55397 content: element, 55398 cellType, 55399 contentType, 55400 name: name2 55401 }) 55402 }, name2); 55403 }), 55404 (0, import_jsx_runtime33.jsx)(Td, { 55405 onClick: (e) => e.stopPropagation(), 55406 children: (0, import_jsx_runtime33.jsxs)(Flex, { 55407 justifyContent: "flex-end", 55408 children: [ 55409 contentType === "folder" && (folderURL ? (0, import_jsx_runtime33.jsx)(IconButton, { 55410 tag: Link, 55411 label: formatMessage({ 55412 id: getTrad("list.folders.link-label"), 55413 defaultMessage: "Access folder" 55414 }), 55415 to: folderURL, 55416 variant: "ghost", 55417 children: (0, import_jsx_runtime33.jsx)(ForwardRef$1T, {}) 55418 }) : (0, import_jsx_runtime33.jsx)(IconButton, { 55419 tag: "button", 55420 label: formatMessage({ 55421 id: getTrad("list.folders.link-label"), 55422 defaultMessage: "Access folder" 55423 }), 55424 onClick: () => onChangeFolder && onChangeFolder(id), 55425 variant: "ghost", 55426 children: (0, import_jsx_runtime33.jsx)(ForwardRef$1T, {}) 55427 })), 55428 (0, import_jsx_runtime33.jsx)(IconButton, { 55429 label: formatMessage({ 55430 id: getTrad("control-card.edit"), 55431 defaultMessage: "Edit" 55432 }), 55433 onClick: () => contentType === "asset" ? onEditAsset(element) : onEditFolder(element), 55434 variant: "ghost", 55435 children: (0, import_jsx_runtime33.jsx)(ForwardRef$N, {}) 55436 }) 55437 ] 55438 }) 55439 }) 55440 ] 55441 }, id); 55442 }) 55443 }); 55444}; 55445
vendor: 3,819 bytes, lines 55446-55528
55446// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/TableList/TableList.mjs 55447var TableList = ({ assetCount = 0, folderCount = 0, indeterminate = false, onChangeSort = null, onChangeFolder = null, onEditAsset = null, onEditFolder = null, onSelectAll, onSelectOne, rows = [], selected = [], shouldDisableBulkSelect = false, sortQuery = "" }) => { 55448 const { formatMessage } = useIntl(); 55449 const [sortBy, sortOrder] = sortQuery.split(":"); 55450 const handleClickSort = (isSorted, name) => { 55451 const nextSortOrder = isSorted && sortOrder === "ASC" ? "DESC" : "ASC"; 55452 const nextSort = `${name}:${nextSortOrder}`; 55453 onChangeSort && onChangeSort(nextSort); 55454 }; 55455 return (0, import_jsx_runtime34.jsxs)(Table, { 55456 colCount: tableHeaders.length + 2, 55457 rowCount: assetCount + folderCount + 1, 55458 children: [ 55459 (0, import_jsx_runtime34.jsx)(Thead, { 55460 children: (0, import_jsx_runtime34.jsxs)(Tr, { 55461 children: [ 55462 (0, import_jsx_runtime34.jsx)(Th, { 55463 children: (0, import_jsx_runtime34.jsx)(CheckboxImpl, { 55464 "aria-label": formatMessage({ 55465 id: getTrad("bulk.select.label"), 55466 defaultMessage: "Select all folders & assets" 55467 }), 55468 disabled: shouldDisableBulkSelect, 55469 onCheckedChange: (checked) => onSelectAll(checked, rows), 55470 checked: indeterminate && !shouldDisableBulkSelect ? "indeterminate" : (assetCount > 0 || folderCount > 0) && selected.length === assetCount + folderCount 55471 }) 55472 }), 55473 tableHeaders.map(({ metadatas: { label, isSortable }, name, key }) => { 55474 const isSorted = sortBy === name; 55475 const isUp = sortOrder === "ASC"; 55476 const tableHeaderLabel = formatMessage(label); 55477 const sortLabel = formatMessage({ 55478 id: "list.table.header.sort", 55479 defaultMessage: "Sort on {label}" 55480 }, { 55481 label: tableHeaderLabel 55482 }); 55483 return (0, import_jsx_runtime34.jsx)(Th, { 55484 action: isSorted && (0, import_jsx_runtime34.jsx)(IconButton, { 55485 label: sortLabel, 55486 onClick: () => handleClickSort(isSorted, name), 55487 variant: "ghost", 55488 children: isUp ? (0, import_jsx_runtime34.jsx)(ForwardRef$2u, {}) : (0, import_jsx_runtime34.jsx)(ForwardRef$2v, {}) 55489 }), 55490 children: (0, import_jsx_runtime34.jsx)(TooltipImpl, { 55491 label: isSortable ? sortLabel : tableHeaderLabel, 55492 children: isSortable ? (0, import_jsx_runtime34.jsx)(Typography, { 55493 onClick: () => handleClickSort(isSorted, name), 55494 tag: isSorted ? "span" : "button", 55495 textColor: "neutral600", 55496 variant: "sigma", 55497 children: tableHeaderLabel 55498 }) : (0, import_jsx_runtime34.jsx)(Typography, { 55499 textColor: "neutral600", 55500 variant: "sigma", 55501 children: tableHeaderLabel 55502 }) 55503 }) 55504 }, key); 55505 }), 55506 (0, import_jsx_runtime34.jsx)(Th, { 55507 children: (0, import_jsx_runtime34.jsx)(VisuallyHidden, { 55508 children: formatMessage({ 55509 id: getTrad("list.table.header.actions"), 55510 defaultMessage: "actions" 55511 }) 55512 }) 55513 }) 55514 ] 55515 }) 55516 }), 55517 (0, import_jsx_runtime34.jsx)(TableRows, { 55518 onChangeFolder, 55519 onEditAsset, 55520 onEditFolder, 55521 rows, 55522 onSelectOne, 55523 selected 55524 }) 55525 ] 55526 }); 55527}; 55528
vendor: 273 bytes, lines 55529-55532
55529// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/UploadAssetDialog/UploadAssetDialog.mjs 55530var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1); 55531var React25 = __toESM(require_react(), 1); 55532
vendor: 283 bytes, lines 55533-55536
55533// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/UploadAssetDialog/AddAssetStep/AddAssetStep.mjs 55534var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1); 55535var import_qs26 = __toESM(require_lib(), 1); 55536
vendor: 330 bytes, lines 55537-55541
55537// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/UploadAssetDialog/AddAssetStep/FromComputerForm.mjs 55538var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1); 55539var React21 = __toESM(require_react(), 1); 55540var import_qs24 = __toESM(require_lib(), 1); 55541
vendor: 522 bytes, lines 55542-55557
55542// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/utils/rawFileToAsset.mjs 55543var rawFileToAsset = (rawFile, assetSource) => { 55544 return { 55545 size: rawFile.size / 1e3, 55546 createdAt: new Date(rawFile.lastModified).toISOString(), 55547 name: rawFile.name, 55548 source: assetSource, 55549 type: typeFromMime(rawFile.type), 55550 url: URL.createObjectURL(rawFile), 55551 ext: rawFile.name.split(".").pop(), 55552 mime: rawFile.type, 55553 rawFile, 55554 isLocal: true 55555 }; 55556}; 55557
vendor: 4,988 bytes, lines 55558-55710
55558// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/UploadAssetDialog/AddAssetStep/FromComputerForm.mjs 55559var Wrapper2 = dt(Flex)` 55560 flex-direction: column; 55561`; 55562var IconWrapper = dt.div` 55563 font-size: 6rem; 55564 55565 svg path { 55566 fill: ${({ theme }) => theme.colors.primary600}; 55567 } 55568`; 55569var MediaBox = dt(Box)` 55570 border-style: dashed; 55571`; 55572var OpaqueBox = dt(Box)` 55573 opacity: 0; 55574 cursor: pointer; 55575`; 55576var FromComputerForm = ({ onClose, onAddAssets, trackedLocation }) => { 55577 const { formatMessage } = useIntl(); 55578 const [dragOver, setDragOver] = React21.useState(false); 55579 const inputRef = React21.useRef(null); 55580 const { trackUsage } = useTracking(); 55581 const handleDragOver = (event) => { 55582 event.preventDefault(); 55583 }; 55584 const handleDragEnter = (event) => { 55585 event.preventDefault(); 55586 setDragOver(true); 55587 }; 55588 const handleDragLeave = () => setDragOver(false); 55589 const handleChange = () => { 55590 var _a3; 55591 const files = (_a3 = inputRef.current) == null ? void 0 : _a3.files; 55592 const assets = []; 55593 if (files) { 55594 for (let i3 = 0; i3 < files.length; i3++) { 55595 const file = files.item(i3); 55596 if (file) { 55597 const asset = rawFileToAsset(file, AssetSource.Computer); 55598 assets.push(asset); 55599 } 55600 } 55601 } 55602 if (trackedLocation) { 55603 trackUsage("didSelectFile", { 55604 source: "computer", 55605 location: trackedLocation 55606 }); 55607 } 55608 onAddAssets(assets); 55609 }; 55610 const handleDrop = (e) => { 55611 var _a3; 55612 e.preventDefault(); 55613 if ((_a3 = e == null ? void 0 : e.dataTransfer) == null ? void 0 : _a3.files) { 55614 const files = e.dataTransfer.files; 55615 const assets = []; 55616 for (let i3 = 0; i3 < files.length; i3++) { 55617 const file = files.item(i3); 55618 if (file) { 55619 const asset = rawFileToAsset(file, AssetSource.Computer); 55620 assets.push(asset); 55621 } 55622 } 55623 onAddAssets(assets); 55624 } 55625 setDragOver(false); 55626 }; 55627 return (0, import_jsx_runtime35.jsxs)("form", { 55628 children: [ 55629 (0, import_jsx_runtime35.jsx)(Box, { 55630 paddingLeft: 8, 55631 paddingRight: 8, 55632 paddingTop: 6, 55633 paddingBottom: 6, 55634 children: (0, import_jsx_runtime35.jsx)("label", { 55635 children: (0, import_jsx_runtime35.jsx)(MediaBox, { 55636 paddingTop: 11, 55637 paddingBottom: 11, 55638 hasRadius: true, 55639 justifyContent: "center", 55640 borderColor: dragOver ? "primary500" : "neutral300", 55641 background: dragOver ? "primary100" : "neutral100", 55642 position: "relative", 55643 onDragEnter: handleDragEnter, 55644 onDragLeave: handleDragLeave, 55645 onDragOver: handleDragOver, 55646 onDrop: handleDrop, 55647 children: (0, import_jsx_runtime35.jsx)(Flex, { 55648 justifyContent: "center", 55649 children: (0, import_jsx_runtime35.jsxs)(Wrapper2, { 55650 children: [ 55651 (0, import_jsx_runtime35.jsx)(IconWrapper, { 55652 children: (0, import_jsx_runtime35.jsx)(ForwardRef$F, { 55653 "aria-hidden": true, 55654 width: "3.2rem", 55655 height: "3.2rem" 55656 }) 55657 }), 55658 (0, import_jsx_runtime35.jsx)(Box, { 55659 paddingTop: 3, 55660 paddingBottom: 5, 55661 children: (0, import_jsx_runtime35.jsx)(Typography, { 55662 variant: "delta", 55663 textColor: "neutral600", 55664 tag: "span", 55665 children: formatMessage({ 55666 id: getTrad("input.label"), 55667 defaultMessage: "Drag & Drop here or" 55668 }) 55669 }) 55670 }), 55671 (0, import_jsx_runtime35.jsx)(OpaqueBox, { 55672 tag: "input", 55673 position: "absolute", 55674 left: 0, 55675 right: 0, 55676 bottom: 0, 55677 top: 0, 55678 width: "100%", 55679 type: "file", 55680 multiple: true, 55681 name: "files", 55682 "aria-label": formatMessage({ 55683 id: getTrad("input.label"), 55684 defaultMessage: "Drag & Drop here or" 55685 }), 55686 tabIndex: -1, 55687 ref: inputRef, 55688 zIndex: 1, 55689 onChange: handleChange 55690 }) 55691 ] 55692 }) 55693 }) 55694 }) 55695 }) 55696 }), 55697 (0, import_jsx_runtime35.jsx)(Modal.Footer, { 55698 children: (0, import_jsx_runtime35.jsx)(Button, { 55699 onClick: onClose, 55700 variant: "tertiary", 55701 children: formatMessage({ 55702 id: "app.components.Button.cancel", 55703 defaultMessage: "cancel" 55704 }) 55705 }) 55706 }) 55707 ] 55708 }); 55709}; 55710
vendor: 325 bytes, lines 55711-55715
55711// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/UploadAssetDialog/AddAssetStep/FromUrlForm.mjs 55712var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1); 55713var React22 = __toESM(require_react(), 1); 55714var import_qs25 = __toESM(require_lib(), 1); 55715
vendor: 1,094 bytes, lines 55716-55747
55716// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/utils/urlsToAssets.mjs 55717function getFilenameFromURL(url) { 55718 return new URL(url).pathname.split("/").pop(); 55719} 55720var urlsToAssets = async (urls) => { 55721 const assetPromises = urls.map((url) => fetch(url).then(async (res) => { 55722 const blob = await res.blob(); 55723 const loadedFile = new File([ 55724 blob 55725 ], getFilenameFromURL(res.url), { 55726 type: res.headers.get("content-type") || void 0 55727 }); 55728 return { 55729 name: loadedFile.name, 55730 url: res.url, 55731 mime: res.headers.get("content-type"), 55732 rawFile: loadedFile 55733 }; 55734 })); 55735 const assetsResults = await Promise.all(assetPromises); 55736 const assets = assetsResults.map((fullFilledAsset) => ({ 55737 source: AssetSource.Url, 55738 name: fullFilledAsset.name, 55739 type: typeFromMime(fullFilledAsset.mime), 55740 url: fullFilledAsset.url, 55741 ext: fullFilledAsset.url.split(".").pop(), 55742 mime: fullFilledAsset.mime ? fullFilledAsset.mime : void 0, 55743 rawFile: fullFilledAsset.rawFile 55744 })); 55745 return assets; 55746}; 55747
vendor: 3,050 bytes, lines 55748-55837
55748// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/UploadAssetDialog/AddAssetStep/FromUrlForm.mjs 55749var FromUrlForm = ({ onClose, onAddAsset, trackedLocation }) => { 55750 const [loading, setLoading] = React22.useState(false); 55751 const [error, setError] = React22.useState(void 0); 55752 const { formatMessage } = useIntl(); 55753 const { trackUsage } = useTracking(); 55754 const handleSubmit = async ({ urls }) => { 55755 setLoading(true); 55756 const urlArray = urls.split(/\r?\n/); 55757 try { 55758 const assets = await urlsToAssets(urlArray); 55759 if (trackedLocation) { 55760 trackUsage("didSelectFile", { 55761 source: "url", 55762 location: trackedLocation 55763 }); 55764 } 55765 onAddAsset(assets); 55766 } catch (e) { 55767 setError(e); 55768 setLoading(false); 55769 } 55770 }; 55771 return (0, import_jsx_runtime36.jsx)(Formik, { 55772 enableReinitialize: true, 55773 initialValues: { 55774 urls: "" 55775 }, 55776 onSubmit: handleSubmit, 55777 validationSchema: urlSchema, 55778 validateOnChange: false, 55779 children: ({ values, errors, handleChange }) => (0, import_jsx_runtime36.jsxs)(Form, { 55780 noValidate: true, 55781 children: [ 55782 (0, import_jsx_runtime36.jsx)(Box, { 55783 paddingLeft: 8, 55784 paddingRight: 8, 55785 paddingBottom: 6, 55786 paddingTop: 6, 55787 children: (0, import_jsx_runtime36.jsxs)(Field.Root, { 55788 hint: formatMessage({ 55789 id: getTrad("input.url.description"), 55790 defaultMessage: "Separate your URL links by a carriage return." 55791 }), 55792 error: (error == null ? void 0 : error.message) || (errors.urls ? formatMessage({ 55793 id: errors.urls, 55794 defaultMessage: "An error occured" 55795 }) : void 0), 55796 children: [ 55797 (0, import_jsx_runtime36.jsx)(Field.Label, { 55798 children: formatMessage({ 55799 id: getTrad("input.url.label"), 55800 defaultMessage: "URL" 55801 }) 55802 }), 55803 (0, import_jsx_runtime36.jsx)(Textarea, { 55804 name: "urls", 55805 onChange: handleChange, 55806 value: values.urls 55807 }), 55808 (0, import_jsx_runtime36.jsx)(Field.Hint, {}), 55809 (0, import_jsx_runtime36.jsx)(Field.Error, {}) 55810 ] 55811 }) 55812 }), 55813 (0, import_jsx_runtime36.jsxs)(Modal.Footer, { 55814 children: [ 55815 (0, import_jsx_runtime36.jsx)(Button, { 55816 onClick: onClose, 55817 variant: "tertiary", 55818 children: formatMessage({ 55819 id: "app.components.Button.cancel", 55820 defaultMessage: "cancel" 55821 }) 55822 }), 55823 (0, import_jsx_runtime36.jsx)(Button, { 55824 type: "submit", 55825 loading, 55826 children: formatMessage({ 55827 id: getTrad("button.next"), 55828 defaultMessage: "Next" 55829 }) 55830 }) 55831 ] 55832 }) 55833 ] 55834 }) 55835 }); 55836}; 55837
vendor: 2,499 bytes, lines 55838-55906
55838// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/UploadAssetDialog/AddAssetStep/AddAssetStep.mjs 55839var AddAssetStep = ({ onClose, onAddAsset, trackedLocation }) => { 55840 const { formatMessage } = useIntl(); 55841 return (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { 55842 children: [ 55843 (0, import_jsx_runtime37.jsx)(Modal.Header, { 55844 children: (0, import_jsx_runtime37.jsx)(Modal.Title, { 55845 children: formatMessage({ 55846 id: getTrad("header.actions.add-assets"), 55847 defaultMessage: "Add new assets" 55848 }) 55849 }) 55850 }), 55851 (0, import_jsx_runtime37.jsxs)(Tabs.Root, { 55852 variant: "simple", 55853 defaultValue: "computer", 55854 children: [ 55855 (0, import_jsx_runtime37.jsxs)(Box, { 55856 paddingLeft: 8, 55857 paddingRight: 8, 55858 paddingTop: 6, 55859 children: [ 55860 (0, import_jsx_runtime37.jsxs)(Tabs.List, { 55861 "aria-label": formatMessage({ 55862 id: getTrad("tabs.title"), 55863 defaultMessage: "How do you want to upload your assets?" 55864 }), 55865 children: [ 55866 (0, import_jsx_runtime37.jsx)(Tabs.Trigger, { 55867 value: "computer", 55868 children: formatMessage({ 55869 id: getTrad("modal.nav.computer"), 55870 defaultMessage: "From computer" 55871 }) 55872 }), 55873 (0, import_jsx_runtime37.jsx)(Tabs.Trigger, { 55874 value: "url", 55875 children: formatMessage({ 55876 id: getTrad("modal.nav.url"), 55877 defaultMessage: "From URL" 55878 }) 55879 }) 55880 ] 55881 }), 55882 (0, import_jsx_runtime37.jsx)(Divider, {}) 55883 ] 55884 }), 55885 (0, import_jsx_runtime37.jsx)(Tabs.Content, { 55886 value: "computer", 55887 children: (0, import_jsx_runtime37.jsx)(FromComputerForm, { 55888 onClose, 55889 onAddAssets: onAddAsset, 55890 trackedLocation 55891 }) 55892 }), 55893 (0, import_jsx_runtime37.jsx)(Tabs.Content, { 55894 value: "url", 55895 children: (0, import_jsx_runtime37.jsx)(FromUrlForm, { 55896 onClose, 55897 onAddAsset, 55898 trackedLocation 55899 }) 55900 }) 55901 ] 55902 }) 55903 ] 55904 }); 55905}; 55906
vendor: 334 bytes, lines 55907-55911
55907// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/UploadAssetDialog/PendingAssetStep/PendingAssetStep.mjs 55908var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1); 55909var React24 = __toESM(require_react(), 1); 55910var import_qs28 = __toESM(require_lib(), 1); 55911
vendor: 3,956 bytes, lines 55912-56029
55912// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/AssetCard/UploadingAssetCard.mjs 55913var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1); 55914var React23 = __toESM(require_react(), 1); 55915var import_qs27 = __toESM(require_lib(), 1); 55916var UploadProgressWrapper2 = dt.div` 55917 height: 8.8rem; 55918 width: 100%; 55919`; 55920var Extension2 = dt.span` 55921 text-transform: uppercase; 55922`; 55923var UploadingAssetCard = ({ asset, onCancel, onStatusChange, addUploadedFiles, folderId = null }) => { 55924 const { upload, cancel, error, progress, status: status2 } = useUpload(); 55925 const { formatMessage } = useIntl(); 55926 let badgeContent = formatMessage({ 55927 id: getTrad("settings.section.doc.label"), 55928 defaultMessage: "Doc" 55929 }); 55930 if (asset.type === AssetType.Image) { 55931 badgeContent = formatMessage({ 55932 id: getTrad("settings.section.image.label"), 55933 defaultMessage: "Image" 55934 }); 55935 } else if (asset.type === AssetType.Video) { 55936 badgeContent = formatMessage({ 55937 id: getTrad("settings.section.video.label"), 55938 defaultMessage: "Video" 55939 }); 55940 } else if (asset.type === AssetType.Audio) { 55941 badgeContent = formatMessage({ 55942 id: getTrad("settings.section.audio.label"), 55943 defaultMessage: "Audio" 55944 }); 55945 } 55946 React23.useEffect(() => { 55947 const uploadFile = async () => { 55948 const files = await upload(asset, folderId ? Number(folderId) : null); 55949 if (addUploadedFiles) { 55950 addUploadedFiles(files); 55951 } 55952 }; 55953 uploadFile(); 55954 }, []); 55955 React23.useEffect(() => { 55956 onStatusChange(status2); 55957 }, [ 55958 status2, 55959 onStatusChange 55960 ]); 55961 const handleCancel = () => { 55962 cancel(); 55963 onCancel(asset.rawFile); 55964 }; 55965 return (0, import_jsx_runtime38.jsxs)(Flex, { 55966 direction: "column", 55967 alignItems: "stretch", 55968 gap: 1, 55969 children: [ 55970 (0, import_jsx_runtime38.jsxs)(Card, { 55971 borderColor: error ? "danger600" : "neutral150", 55972 children: [ 55973 (0, import_jsx_runtime38.jsx)(CardHeader, { 55974 children: (0, import_jsx_runtime38.jsx)(UploadProgressWrapper2, { 55975 children: (0, import_jsx_runtime38.jsx)(UploadProgress, { 55976 error: error || void 0, 55977 onCancel: handleCancel, 55978 progress 55979 }) 55980 }) 55981 }), 55982 (0, import_jsx_runtime38.jsxs)(CardBody, { 55983 children: [ 55984 (0, import_jsx_runtime38.jsxs)(CardContent, { 55985 children: [ 55986 (0, import_jsx_runtime38.jsx)(Box, { 55987 paddingTop: 1, 55988 children: (0, import_jsx_runtime38.jsx)(Typography, { 55989 tag: "h2", 55990 children: (0, import_jsx_runtime38.jsx)(CardTitle, { 55991 tag: "span", 55992 children: asset.name 55993 }) 55994 }) 55995 }), 55996 (0, import_jsx_runtime38.jsx)(CardSubtitle, { 55997 children: (0, import_jsx_runtime38.jsx)(Extension2, { 55998 children: asset.ext 55999 }) 56000 }) 56001 ] 56002 }), 56003 (0, import_jsx_runtime38.jsx)(Flex, { 56004 paddingTop: 1, 56005 grow: 1, 56006 children: (0, import_jsx_runtime38.jsx)(CardBadge, { 56007 children: badgeContent 56008 }) 56009 }) 56010 ] 56011 }) 56012 ] 56013 }), 56014 error ? (0, import_jsx_runtime38.jsx)(Typography, { 56015 variant: "pi", 56016 fontWeight: "bold", 56017 textColor: "danger600", 56018 children: formatMessage((error == null ? void 0 : error.message) ? { 56019 id: getTrad(`apiError.${error.message}`), 56020 defaultMessage: error.message 56021 } : { 56022 id: getTrad("upload.generic-error"), 56023 defaultMessage: "An error occured while uploading the file." 56024 }) 56025 }) : void 0 56026 ] 56027 }); 56028}; 56029
vendor: 6,484 bytes, lines 56030-56196
56030// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/UploadAssetDialog/PendingAssetStep/PendingAssetStep.mjs 56031var Status = { 56032 Idle: "IDLE", 56033 Uploading: "UPLOADING", 56034 Intermediate: "INTERMEDIATE" 56035}; 56036var PendingAssetStep = ({ addUploadedFiles, folderId, onClose, onEditAsset, onRemoveAsset, assets, onClickAddAsset, onCancelUpload, onUploadSucceed, trackedLocation }) => { 56037 const assetCountRef = React24.useRef(0); 56038 const { formatMessage } = useIntl(); 56039 const { trackUsage } = useTracking(); 56040 const [uploadStatus, setUploadStatus] = React24.useState(Status.Idle); 56041 const handleSubmit = async (e) => { 56042 e.preventDefault(); 56043 e.stopPropagation(); 56044 const assetsCountByType = assets.reduce((acc, asset) => { 56045 const { type } = asset; 56046 if (type !== void 0 && !acc[type]) { 56047 acc[type] = 0; 56048 } 56049 if (type !== void 0) { 56050 const accType = acc[type]; 56051 const currentCount = typeof accType === "string" ? accType : accType.toString(); 56052 acc[type] = `${parseInt(currentCount, 10) + 1}`; 56053 } 56054 return acc; 56055 }, {}); 56056 trackUsage("willAddMediaLibraryAssets", { 56057 location: trackedLocation, 56058 ...assetsCountByType 56059 }); 56060 setUploadStatus(Status.Uploading); 56061 }; 56062 const handleStatusChange = (status2, file) => { 56063 if (status2 === "success" || status2 === "error") { 56064 assetCountRef.current++; 56065 if (assetCountRef.current === assets.length) { 56066 assetCountRef.current = 0; 56067 setUploadStatus(Status.Intermediate); 56068 } 56069 } 56070 if (status2 === "success") { 56071 onUploadSucceed(file); 56072 } 56073 }; 56074 return (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { 56075 children: [ 56076 (0, import_jsx_runtime39.jsx)(Modal.Header, { 56077 children: (0, import_jsx_runtime39.jsx)(Modal.Title, { 56078 children: formatMessage({ 56079 id: getTrad("header.actions.add-assets"), 56080 defaultMessage: "Add new assets" 56081 }) 56082 }) 56083 }), 56084 (0, import_jsx_runtime39.jsx)(Modal.Body, { 56085 children: (0, import_jsx_runtime39.jsxs)(Flex, { 56086 direction: "column", 56087 alignItems: "stretch", 56088 gap: 7, 56089 children: [ 56090 (0, import_jsx_runtime39.jsxs)(Flex, { 56091 justifyContent: "space-between", 56092 children: [ 56093 (0, import_jsx_runtime39.jsxs)(Flex, { 56094 direction: "column", 56095 alignItems: "stretch", 56096 gap: 0, 56097 children: [ 56098 (0, import_jsx_runtime39.jsx)(Typography, { 56099 variant: "pi", 56100 fontWeight: "bold", 56101 textColor: "neutral800", 56102 children: formatMessage({ 56103 id: getTrad("list.assets.to-upload"), 56104 defaultMessage: "{number, plural, =0 {No asset} one {1 asset} other {# assets}} ready to upload" 56105 }, { 56106 number: assets.length 56107 }) 56108 }), 56109 (0, import_jsx_runtime39.jsx)(Typography, { 56110 variant: "pi", 56111 textColor: "neutral600", 56112 children: formatMessage({ 56113 id: getTrad("modal.upload-list.sub-header-subtitle"), 56114 defaultMessage: "Manage the assets before adding them to the Media Library" 56115 }) 56116 }) 56117 ] 56118 }), 56119 (0, import_jsx_runtime39.jsx)(Button, { 56120 size: "S", 56121 onClick: onClickAddAsset, 56122 children: formatMessage({ 56123 id: getTrad("header.actions.add-assets"), 56124 defaultMessage: "Add new assets" 56125 }) 56126 }) 56127 ] 56128 }), 56129 (0, import_jsx_runtime39.jsx)(KeyboardNavigable, { 56130 tagName: "article", 56131 children: (0, import_jsx_runtime39.jsx)(Grid.Root, { 56132 gap: 4, 56133 children: assets.map((asset) => { 56134 const assetKey = asset.url; 56135 if (uploadStatus === Status.Uploading || uploadStatus === Status.Intermediate) { 56136 return (0, import_jsx_runtime39.jsx)(Grid.Item, { 56137 col: 4, 56138 direction: "column", 56139 alignItems: "stretch", 56140 children: (0, import_jsx_runtime39.jsx)(UploadingAssetCard, { 56141 // Props used to store the newly uploaded files 56142 addUploadedFiles, 56143 asset, 56144 id: assetKey, 56145 onCancel: onCancelUpload, 56146 onStatusChange: (status2) => handleStatusChange(status2, asset.rawFile), 56147 size: "S", 56148 folderId 56149 }) 56150 }, assetKey); 56151 } 56152 return (0, import_jsx_runtime39.jsx)(Grid.Item, { 56153 col: 4, 56154 direction: "column", 56155 alignItems: "stretch", 56156 children: (0, import_jsx_runtime39.jsx)(AssetCard, { 56157 asset, 56158 size: "S", 56159 local: true, 56160 alt: asset.name, 56161 onEdit: onEditAsset, 56162 onRemove: onRemoveAsset 56163 }, assetKey) 56164 }, assetKey); 56165 }) 56166 }) 56167 }) 56168 ] 56169 }) 56170 }), 56171 (0, import_jsx_runtime39.jsxs)(Modal.Footer, { 56172 children: [ 56173 (0, import_jsx_runtime39.jsx)(Button, { 56174 onClick: onClose, 56175 variant: "tertiary", 56176 children: formatMessage({ 56177 id: "app.components.Button.cancel", 56178 defaultMessage: "cancel" 56179 }) 56180 }), 56181 (0, import_jsx_runtime39.jsx)(Button, { 56182 onClick: handleSubmit, 56183 loading: uploadStatus === Status.Uploading, 56184 children: formatMessage({ 56185 id: getTrad("modal.upload-list.footer.button"), 56186 defaultMessage: "Upload {number, plural, one {# asset} other {# assets}} to the library" 56187 }, { 56188 number: assets.length 56189 }) 56190 }) 56191 ] 56192 }) 56193 ] 56194 }); 56195}; 56196
vendor: 3,490 bytes, lines 56197-56294
56197// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/UploadAssetDialog/UploadAssetDialog.mjs 56198var Steps = { 56199 AddAsset: "AddAsset", 56200 PendingAsset: "PendingAsset" 56201}; 56202var UploadAssetDialog = ({ initialAssetsToAdd, folderId = null, onClose = () => { 56203}, addUploadedFiles, trackedLocation, open, validateAssetsTypes = (_3, cb) => cb() }) => { 56204 const { formatMessage } = useIntl(); 56205 const [step, setStep] = React25.useState(initialAssetsToAdd ? Steps.PendingAsset : Steps.AddAsset); 56206 const [assets, setAssets] = React25.useState(initialAssetsToAdd || []); 56207 const [assetToEdit, setAssetToEdit] = React25.useState(void 0); 56208 const handleAddToPendingAssets = (nextAssets) => { 56209 validateAssetsTypes(nextAssets, () => { 56210 setAssets((prevAssets) => prevAssets.concat(nextAssets)); 56211 setStep(Steps.PendingAsset); 56212 }); 56213 }; 56214 const moveToAddAsset = () => { 56215 setStep(Steps.AddAsset); 56216 }; 56217 const handleCancelUpload = (file) => { 56218 const nextAssets = assets.filter((asset) => asset.rawFile !== file); 56219 setAssets(nextAssets); 56220 if (nextAssets.length === 0) { 56221 moveToAddAsset(); 56222 } 56223 }; 56224 const handleUploadSuccess = (file) => { 56225 const nextAssets = assets.filter((asset) => asset.rawFile !== file); 56226 setAssets(nextAssets); 56227 if (nextAssets.length === 0) { 56228 onClose(); 56229 } 56230 }; 56231 const handleAssetEditValidation = (nextAsset) => { 56232 if (nextAsset && typeof nextAsset !== "boolean") { 56233 const nextAssets = assets.map((asset) => asset === assetToEdit ? nextAsset : asset); 56234 setAssets(nextAssets); 56235 } 56236 setAssetToEdit(void 0); 56237 }; 56238 const handleClose = () => { 56239 if (step === Steps.PendingAsset && assets.length > 0) { 56240 const confirm = window.confirm(formatMessage({ 56241 id: "window.confirm.close-modal.files", 56242 defaultMessage: "Are you sure? You have some files that have not been uploaded yet." 56243 })); 56244 if (confirm) { 56245 onClose(); 56246 } 56247 } else { 56248 onClose(); 56249 } 56250 }; 56251 const handleRemoveAsset = (assetToRemove) => { 56252 const nextAssets = assets.filter((asset) => asset !== assetToRemove); 56253 setAssets(nextAssets); 56254 }; 56255 return (0, import_jsx_runtime40.jsxs)(Modal.Root, { 56256 open, 56257 onOpenChange: handleClose, 56258 children: [ 56259 step === Steps.AddAsset && (0, import_jsx_runtime40.jsx)(Modal.Content, { 56260 children: (0, import_jsx_runtime40.jsx)(AddAssetStep, { 56261 onClose, 56262 onAddAsset: (assets2) => handleAddToPendingAssets(assets2), 56263 trackedLocation 56264 }) 56265 }), 56266 step === Steps.PendingAsset && (0, import_jsx_runtime40.jsx)(Modal.Content, { 56267 children: (0, import_jsx_runtime40.jsx)(PendingAssetStep, { 56268 onClose: handleClose, 56269 assets, 56270 onEditAsset: setAssetToEdit, 56271 onRemoveAsset: handleRemoveAsset, 56272 onClickAddAsset: moveToAddAsset, 56273 onCancelUpload: handleCancelUpload, 56274 onUploadSucceed: handleUploadSuccess, 56275 initialAssetsToAdd, 56276 addUploadedFiles, 56277 folderId, 56278 trackedLocation 56279 }) 56280 }), 56281 assetToEdit && (0, import_jsx_runtime40.jsx)(Modal.Content, { 56282 children: (0, import_jsx_runtime40.jsx)(EditAssetContent, { 56283 onClose: handleAssetEditValidation, 56284 asset: assetToEdit, 56285 canUpdate: true, 56286 canCopyLink: false, 56287 canDownload: false, 56288 trackedLocation 56289 }) 56290 }) 56291 ] 56292 }); 56293}; 56294
vendor: 218 bytes, lines 56295-56297
56295// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/Breadcrumbs/Breadcrumbs.mjs 56296var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1); 56297
vendor: 270 bytes, lines 56298-56301
56298// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/Breadcrumbs/CrumbSimpleMenuAsync.mjs 56299var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1); 56300var React26 = __toESM(require_react(), 1); 56301
vendor: 862 bytes, lines 56302-56322
56302// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/utils/getFolderParents.mjs 56303var getFolderParents = (folders, currentFolderId) => { 56304 const parents = []; 56305 const flatFolders = flattenTree(folders); 56306 const currentFolder = flatFolders.find((folder) => folder.value === currentFolderId); 56307 if (!currentFolder) { 56308 return []; 56309 } 56310 let { parent } = currentFolder; 56311 while (parent !== void 0) { 56312 const parentToStore = flatFolders.find(({ value }) => value === parent); 56313 parents.push({ 56314 id: parentToStore == null ? void 0 : parentToStore.value, 56315 label: parentToStore == null ? void 0 : parentToStore.label, 56316 path: parentToStore == null ? void 0 : parentToStore.path 56317 }); 56318 parent = parentToStore == null ? void 0 : parentToStore.parent; 56319 } 56320 return parents.reverse(); 56321}; 56322
vendor: 2,160 bytes, lines 56323-56374
56323// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/Breadcrumbs/CrumbSimpleMenuAsync.mjs 56324var CrumbSimpleMenuAsync = ({ parentsToOmit = [], currentFolderId, onChangeFolder }) => { 56325 const [shouldFetch, setShouldFetch] = React26.useState(false); 56326 const { data, isLoading } = useFolderStructure({ 56327 enabled: shouldFetch 56328 }); 56329 const { pathname } = useLocation(); 56330 const navigate = useNavigate(); 56331 const [{ query }] = useQueryParams(); 56332 const { formatMessage } = useIntl(); 56333 const allAscendants = data && getFolderParents(data, currentFolderId); 56334 const filteredAscendants = allAscendants && allAscendants.filter((ascendant) => typeof ascendant.id === "number" && !parentsToOmit.includes(ascendant.id) && ascendant.id !== null); 56335 return (0, import_jsx_runtime41.jsxs)(CrumbSimpleMenu, { 56336 onOpen: () => setShouldFetch(true), 56337 onClose: () => setShouldFetch(false), 56338 "aria-label": formatMessage({ 56339 id: getTrad("header.breadcrumbs.menu.label"), 56340 defaultMessage: "Get more ascendants folders" 56341 }), 56342 label: "...", 56343 children: [ 56344 isLoading && (0, import_jsx_runtime41.jsx)(MenuItem, { 56345 children: (0, import_jsx_runtime41.jsx)(Loader, { 56346 small: true, 56347 children: formatMessage({ 56348 id: getTrad("content.isLoading"), 56349 defaultMessage: "Content is loading." 56350 }) 56351 }) 56352 }), 56353 filteredAscendants && filteredAscendants.map((ascendant) => { 56354 if (onChangeFolder) { 56355 return (0, import_jsx_runtime41.jsx)(MenuItem, { 56356 tag: "button", 56357 type: "button", 56358 onClick: () => onChangeFolder(Number(ascendant.id), ascendant.path), 56359 children: ascendant.label 56360 }, ascendant.id); 56361 } 56362 const url = getFolderURL(pathname, query, { 56363 folder: String(ascendant.id), 56364 folderPath: ascendant == null ? void 0 : ascendant.path 56365 }); 56366 return (0, import_jsx_runtime41.jsx)(MenuItem, { 56367 onClick: () => navigate(url), 56368 children: ascendant.label 56369 }, ascendant.id); 56370 }) 56371 ] 56372 }); 56373}; 56374
vendor: 2,201 bytes, lines 56375-56415
56375// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/Breadcrumbs/Breadcrumbs.mjs 56376var Breadcrumbs2 = ({ breadcrumbs, onChangeFolder, currentFolderId, ...props }) => { 56377 const { formatMessage } = useIntl(); 56378 return (0, import_jsx_runtime42.jsx)(Breadcrumbs, { 56379 ...props, 56380 children: breadcrumbs.map((crumb, index2) => { 56381 var _a3, _b, _c; 56382 if (Array.isArray(crumb)) { 56383 return (0, import_jsx_runtime42.jsx)(CrumbSimpleMenuAsync, { 56384 parentsToOmit: [ 56385 ...breadcrumbs 56386 ].splice(index2 + 1, breadcrumbs.length - 1).map((parent) => parent.id), 56387 currentFolderId, 56388 onChangeFolder 56389 }, `breadcrumb-${(crumb == null ? void 0 : crumb.id) ?? "menu"}`); 56390 } 56391 const isCurrentFolderMediaLibrary = crumb.id === null && currentFolderId === void 0; 56392 if (currentFolderId !== crumb.id && !isCurrentFolderMediaLibrary) { 56393 if (onChangeFolder) { 56394 return (0, import_jsx_runtime42.jsx)(CrumbLink, { 56395 type: "button", 56396 onClick: () => onChangeFolder(crumb.id, crumb.path), 56397 children: typeof crumb.label !== "string" && ((_a3 = crumb.label) == null ? void 0 : _a3.id) ? formatMessage(crumb.label) : crumb.label 56398 }, `breadcrumb-${(crumb == null ? void 0 : crumb.id) ?? "root"}`); 56399 } 56400 return (0, import_jsx_runtime42.jsx)(CrumbLink, { 56401 to: crumb.href, 56402 // eslint-disable-next-line @typescript-eslint/ban-ts-comment 56403 // @ts-ignore - `tag` prop is not defined in the `BaseLinkProps` type 56404 tag: Link, 56405 children: typeof crumb.label !== "string" && ((_b = crumb.label) == null ? void 0 : _b.id) ? formatMessage(crumb.label) : crumb.label 56406 }, `breadcrumb-${(crumb == null ? void 0 : crumb.id) ?? "root"}`); 56407 } 56408 return (0, import_jsx_runtime42.jsx)(Crumb, { 56409 isCurrent: index2 + 1 === breadcrumbs.length, 56410 children: typeof crumb.label !== "string" && ((_c = crumb.label) == null ? void 0 : _c.id) ? formatMessage(crumb.label) : crumb.label 56411 }, `breadcrumb-${(crumb == null ? void 0 : crumb.id) ?? "root"}`); 56412 }) 56413 }); 56414}; 56415
vendor: 218 bytes, lines 56416-56418
56416// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EmptyAssets/EmptyAssets.mjs 56417var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1); 56418
vendor: 769 bytes, lines 56419-56442
56419// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EmptyAssets/EmptyAssetGrid.mjs 56420var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1); 56421var EmptyAssetCard = dt(Box)` 56422 background: linear-gradient( 56423 180deg, 56424 rgba(234, 234, 239, 0) 0%, 56425 ${({ theme }) => theme.colors.neutral200} 100% 56426 ); 56427 opacity: 0.33; 56428`; 56429var PlaceholderSize = { 56430 S: 138, 56431 M: 234 56432}; 56433var EmptyAssetGrid = ({ count, size }) => { 56434 return (0, import_jsx_runtime43.jsx)(Layouts.Grid, { 56435 size, 56436 children: Array(count).fill(null).map((_3, idx) => (0, import_jsx_runtime43.jsx)(EmptyAssetCard, { 56437 height: `${PlaceholderSize[size]}px`, 56438 hasRadius: true 56439 }, `empty-asset-card-${idx}`)) 56440 }); 56441}; 56442
vendor: 1,368 bytes, lines 56443-56486
56443// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/EmptyAssets/EmptyAssets.mjs 56444var EmptyAssets = ({ icon: Icon = ForwardRef$m, content, action, size = "M", count = 12 }) => { 56445 return (0, import_jsx_runtime44.jsxs)(Box, { 56446 position: "relative", 56447 children: [ 56448 (0, import_jsx_runtime44.jsx)(EmptyAssetGrid, { 56449 size, 56450 count 56451 }), 56452 (0, import_jsx_runtime44.jsx)(Box, { 56453 position: "absolute", 56454 top: 11, 56455 width: "100%", 56456 children: (0, import_jsx_runtime44.jsxs)(Flex, { 56457 direction: "column", 56458 alignItems: "center", 56459 gap: 4, 56460 textAlign: "center", 56461 children: [ 56462 (0, import_jsx_runtime44.jsxs)(Flex, { 56463 direction: "column", 56464 alignItems: "center", 56465 gap: 6, 56466 children: [ 56467 (0, import_jsx_runtime44.jsx)(Icon, { 56468 width: "160px", 56469 height: "88px" 56470 }), 56471 (0, import_jsx_runtime44.jsx)(Typography, { 56472 variant: "delta", 56473 tag: "p", 56474 textColor: "neutral600", 56475 children: content 56476 }) 56477 ] 56478 }), 56479 action 56480 ] 56481 }) 56482 }) 56483 ] 56484 }); 56485}; 56486
vendor: 854 bytes, lines 56487-56535
56487// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/utils/displayedFilters.mjs 56488var displayedFilters = [ 56489 { 56490 name: "createdAt", 56491 fieldSchema: { 56492 type: "date" 56493 }, 56494 metadatas: { 56495 label: "createdAt" 56496 } 56497 }, 56498 { 56499 name: "updatedAt", 56500 fieldSchema: { 56501 type: "date" 56502 }, 56503 metadatas: { 56504 label: "updatedAt" 56505 } 56506 }, 56507 { 56508 name: "mime", 56509 fieldSchema: { 56510 type: "enumeration", 56511 options: [ 56512 { 56513 label: "audio", 56514 value: "audio" 56515 }, 56516 { 56517 label: "file", 56518 value: "file" 56519 }, 56520 { 56521 label: "image", 56522 value: "image" 56523 }, 56524 { 56525 label: "video", 56526 value: "video" 56527 } 56528 ] 56529 }, 56530 metadatas: { 56531 label: "type" 56532 } 56533 } 56534]; 56535
vendor: 216 bytes, lines 56536-56538
56536// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/FilterList/FilterList.mjs 56537var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1); 56538
vendor: 1,471 bytes, lines 56539-56582
56539// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/FilterList/FilterTag.mjs 56540var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1); 56541var FilterTag = ({ attribute, filter, onClick, operator, value }) => { 56542 var _a3; 56543 const { formatMessage, formatDate, formatTime: formatTime2 } = useIntl(); 56544 const handleClick = () => { 56545 onClick(filter); 56546 }; 56547 const { fieldSchema } = attribute; 56548 const type = fieldSchema == null ? void 0 : fieldSchema.type; 56549 let formattedValue = value; 56550 if (type === "date") { 56551 formattedValue = formatDate(value, { 56552 dateStyle: "full" 56553 }); 56554 } 56555 if (type === "datetime") { 56556 formattedValue = formatDate(value, { 56557 dateStyle: "full", 56558 timeStyle: "short" 56559 }); 56560 } 56561 if (type === "time") { 56562 const [hour, minute] = value.split(":"); 56563 const date = /* @__PURE__ */ new Date(); 56564 date.setHours(Number(hour)); 56565 date.setMinutes(Number(minute)); 56566 formattedValue = formatTime2(date, { 56567 hour: "numeric", 56568 minute: "numeric" 56569 }); 56570 } 56571 const content = `${(_a3 = attribute.metadatas) == null ? void 0 : _a3.label} ${formatMessage({ 56572 id: `components.FilterOptions.FILTER_TYPES.${operator}`, 56573 defaultMessage: operator 56574 })} ${formattedValue}`; 56575 return (0, import_jsx_runtime45.jsx)(Tag, { 56576 onClick: handleClick, 56577 icon: (0, import_jsx_runtime45.jsx)(ForwardRef$26, {}), 56578 padding: 1, 56579 children: content 56580 }); 56581}; 56582
vendor: 2,202 bytes, lines 56583-56645
56583// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/FilterList/FilterList.mjs 56584var FilterList = ({ appliedFilters, filtersSchema, onRemoveFilter }) => { 56585 const handleClick = (filter) => { 56586 const nextFilters = appliedFilters.filter((prevFilter) => { 56587 var _a3; 56588 const name = Object.keys(filter)[0]; 56589 const filterName = filter[name]; 56590 if (filterName !== void 0) { 56591 const filterType = Object.keys(filterName)[0]; 56592 const filterValue = filterName[filterType]; 56593 if (typeof filterValue === "string") { 56594 const decodedValue = decodeURIComponent(filterValue); 56595 return ((_a3 = prevFilter[name]) == null ? void 0 : _a3[filterType]) !== decodedValue; 56596 } 56597 } 56598 return true; 56599 }); 56600 onRemoveFilter(nextFilters); 56601 }; 56602 return appliedFilters.map((filter, i3) => { 56603 const attributeName = Object.keys(filter)[0]; 56604 const attribute = filtersSchema.find(({ name }) => name === attributeName); 56605 if (!attribute) { 56606 return null; 56607 } 56608 const filterObj = filter[attributeName]; 56609 const operator = Object.keys(filterObj)[0]; 56610 let value = filterObj[operator]; 56611 if (Array.isArray(value)) { 56612 value = value.join(", "); 56613 } else if (typeof value === "object") { 56614 value = Object.values(value).join(", "); 56615 } else { 56616 value = Array.isArray(value) || typeof value === "object" ? Object.values(value).join(", ") : decodeURIComponent(value); 56617 } 56618 let displayedOperator = operator; 56619 if ((attribute == null ? void 0 : attribute.name) === "mime") { 56620 displayedOperator = operator === "$contains" ? "$eq" : "$ne"; 56621 if (operator === "$not") { 56622 value = "file"; 56623 displayedOperator = "$eq"; 56624 } 56625 if ([ 56626 "image", 56627 "video" 56628 ].includes(value[0]) && [ 56629 "image", 56630 "video" 56631 ].includes(value[1])) { 56632 value = "file"; 56633 displayedOperator = "$ne"; 56634 } 56635 } 56636 return (0, import_jsx_runtime46.jsx)(FilterTag, { 56637 attribute, 56638 filter, 56639 onClick: handleClick, 56640 operator: displayedOperator, 56641 value 56642 }, `${attributeName}-${i3}`); 56643 }); 56644}; 56645
vendor: 265 bytes, lines 56646-56649
56646// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/FilterPopover/FilterPopover.mjs 56647var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1); 56648var React27 = __toESM(require_react(), 1); 56649
vendor: 1,233 bytes, lines 56650-56682
56650// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/FilterPopover/FilterValueInput.mjs 56651var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1); 56652var FilterValueInput = ({ label = "", onChange: onChange2, options: options2 = [], type, value = "" }) => { 56653 const { formatMessage } = useIntl(); 56654 if (type === "date") { 56655 return (0, import_jsx_runtime47.jsx)(DateTimePicker, { 56656 clearLabel: formatMessage({ 56657 id: "clearLabel", 56658 defaultMessage: "Clear" 56659 }), 56660 "aria-label": label, 56661 name: "datetimepicker", 56662 onChange: (date) => { 56663 const formattedDate = date ? new Date(date).toISOString() : ""; 56664 onChange2(formattedDate); 56665 }, 56666 onClear: () => onChange2(""), 56667 value: value ? new Date(value) : void 0 56668 }); 56669 } 56670 return (0, import_jsx_runtime47.jsx)(SingleSelect, { 56671 "aria-label": label, 56672 onChange: (value2) => onChange2(value2.toString()), 56673 value, 56674 children: options2 == null ? void 0 : options2.map((option) => { 56675 return (0, import_jsx_runtime47.jsx)(SingleSelectOption, { 56676 value: option.value, 56677 children: option.label 56678 }, option.value); 56679 }) 56680 }); 56681}; 56682
vendor: 2,922 bytes, lines 56683-56791
56683// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/FilterPopover/utils/getFilterList.mjs 56684var getFilterList = ({ fieldSchema: { type: fieldType, mainField } }) => { 56685 const type = (mainField == null ? void 0 : mainField.schema.type) ? mainField.schema.type : fieldType; 56686 switch (type) { 56687 case "enumeration": { 56688 return [ 56689 { 56690 intlLabel: { 56691 id: "components.FilterOptions.FILTER_TYPES.$eq", 56692 defaultMessage: "is" 56693 }, 56694 value: "$contains" 56695 }, 56696 { 56697 intlLabel: { 56698 id: "components.FilterOptions.FILTER_TYPES.$ne", 56699 defaultMessage: "is not" 56700 }, 56701 value: "$notContains" 56702 } 56703 ]; 56704 } 56705 case "date": { 56706 return [ 56707 { 56708 intlLabel: { 56709 id: "components.FilterOptions.FILTER_TYPES.$eq", 56710 defaultMessage: "is" 56711 }, 56712 value: "$eq" 56713 }, 56714 { 56715 intlLabel: { 56716 id: "components.FilterOptions.FILTER_TYPES.$ne", 56717 defaultMessage: "is not" 56718 }, 56719 value: "$ne" 56720 }, 56721 { 56722 intlLabel: { 56723 id: "components.FilterOptions.FILTER_TYPES.$gt", 56724 defaultMessage: "is greater than" 56725 }, 56726 value: "$gt" 56727 }, 56728 { 56729 intlLabel: { 56730 id: "components.FilterOptions.FILTER_TYPES.$gte", 56731 defaultMessage: "is greater than or equal to" 56732 }, 56733 value: "$gte" 56734 }, 56735 { 56736 intlLabel: { 56737 id: "components.FilterOptions.FILTER_TYPES.$lt", 56738 defaultMessage: "is less than" 56739 }, 56740 value: "$lt" 56741 }, 56742 { 56743 intlLabel: { 56744 id: "components.FilterOptions.FILTER_TYPES.$lte", 56745 defaultMessage: "is less than or equal to" 56746 }, 56747 value: "$lte" 56748 } 56749 ]; 56750 } 56751 default: 56752 return [ 56753 { 56754 intlLabel: { 56755 id: "components.FilterOptions.FILTER_TYPES.$eq", 56756 defaultMessage: "is" 56757 }, 56758 value: "$eq" 56759 }, 56760 { 56761 intlLabel: { 56762 id: "components.FilterOptions.FILTER_TYPES.$eqi", 56763 defaultMessage: "is (case insensitive)" 56764 }, 56765 value: "$eqi" 56766 }, 56767 { 56768 intlLabel: { 56769 id: "components.FilterOptions.FILTER_TYPES.$ne", 56770 defaultMessage: "is not" 56771 }, 56772 value: "$ne" 56773 }, 56774 { 56775 intlLabel: { 56776 id: "components.FilterOptions.FILTER_TYPES.$null", 56777 defaultMessage: "is null" 56778 }, 56779 value: "$null" 56780 }, 56781 { 56782 intlLabel: { 56783 id: "components.FilterOptions.FILTER_TYPES.$notNull", 56784 defaultMessage: "is not null" 56785 }, 56786 value: "$notNull" 56787 } 56788 ]; 56789 } 56790}; 56791
vendor: 10,240 bytes, lines 56792-57111
56792// node_modules/.pnpm/@[email protected]_dd8ff2e8c6d898efa6aebeed0368847a/node_modules/@strapi/upload/dist/admin/components/FilterPopover/FilterPopover.mjs 56793var FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit, onToggle }) => { 56794 const { formatMessage } = useIntl(); 56795 const [modifiedData, setModifiedData] = React27.useState({ 56796 name: "createdAt", 56797 filter: "$eq", 56798 value: "" 56799 }); 56800 const handleChangeFilterField = (value) => { 56801 const nextField = displayedFilters2.find((f) => f.name === value); 56802 if (!nextField) { 56803 return; 56804 } 56805 const { fieldSchema: { type, options: options2 } } = nextField; 56806 let filterValue = ""; 56807 if (type === "enumeration") { 56808 filterValue = (options2 == null ? void 0 : options2[0].value) || ""; 56809 } 56810 const filter = getFilterList(nextField)[0].value; 56811 setModifiedData({ 56812 name: value.toString(), 56813 filter, 56814 value: filterValue 56815 }); 56816 }; 56817 const handleChangeOperator = (operator) => { 56818 if (modifiedData.name === "mime") { 56819 setModifiedData((prev2) => ({ 56820 ...prev2, 56821 filter: operator.toString(), 56822 value: "image" 56823 })); 56824 } else { 56825 setModifiedData((prev2) => ({ 56826 ...prev2, 56827 filter: operator.toString(), 56828 value: "" 56829 })); 56830 } 56831 }; 56832 const handleSubmit = (e) => { 56833 e.preventDefault(); 56834 e.stopPropagation(); 56835 const encodedValue = encodeURIComponent(modifiedData.value); 56836 if (encodedValue) { 56837 if (modifiedData.name === "mime") { 56838 const alreadyAppliedFilters = filters.filter((filter) => { 56839 return Object.keys(filter)[0] === "mime"; 56840 }); 56841 if (modifiedData.value === "file") { 56842 const filtersWithoutMimeType = filters.filter((filter) => { 56843 return Object.keys(filter)[0] !== "mime"; 56844 }); 56845 let hasCurrentFilter = false; 56846 let filterToAdd2; 56847 if (modifiedData.filter === "$contains") { 56848 hasCurrentFilter = alreadyAppliedFilters.find((filter) => { 56849 var _a3, _b, _c, _d; 56850 if (typeof ((_a3 = filter.mime) == null ? void 0 : _a3.$not) !== "string" && !Array.isArray((_b = filter.mime) == null ? void 0 : _b.$not)) { 56851 return ((_d = (_c = filter.mime) == null ? void 0 : _c.$not) == null ? void 0 : _d.$contains) !== void 0; 56852 } 56853 }) !== void 0; 56854 filterToAdd2 = { 56855 mime: { 56856 $not: { 56857 $contains: [ 56858 "image", 56859 "video" 56860 ] 56861 } 56862 } 56863 }; 56864 } else { 56865 hasCurrentFilter = alreadyAppliedFilters.find((filter) => { 56866 var _a3; 56867 return Array.isArray((_a3 = filter.mime) == null ? void 0 : _a3.$contains); 56868 }) !== void 0; 56869 filterToAdd2 = { 56870 mime: { 56871 $contains: [ 56872 "image", 56873 "video" 56874 ] 56875 } 56876 }; 56877 } 56878 if (hasCurrentFilter) { 56879 onToggle(); 56880 return; 56881 } 56882 const nextFilters = [ 56883 ...filtersWithoutMimeType, 56884 filterToAdd2 56885 ]; 56886 onSubmit(nextFilters); 56887 onToggle(); 56888 return; 56889 } 56890 const hasFilter2 = alreadyAppliedFilters.find((filter) => { 56891 const modifiedDataFilter = modifiedData.filter; 56892 return filter.mime && filter.mime[modifiedDataFilter] === modifiedData.value; 56893 }) !== void 0; 56894 if (hasFilter2) { 56895 onToggle(); 56896 return; 56897 } 56898 const filtersWithoutFile = filters.filter((filter) => { 56899 var _a3, _b, _c, _d, _e5; 56900 const filterType = Object.keys(filter)[0]; 56901 if (filterType !== "mime") { 56902 return true; 56903 } 56904 if (typeof ((_a3 = filter.mime) == null ? void 0 : _a3.$not) !== "string" && !Array.isArray((_b = filter.mime) == null ? void 0 : _b.$not) && ((_d = (_c = filter.mime) == null ? void 0 : _c.$not) == null ? void 0 : _d.$contains) !== void 0) { 56905 return false; 56906 } 56907 if (Array.isArray((_e5 = filter == null ? void 0 : filter.mime) == null ? void 0 : _e5.$contains)) { 56908 return false; 56909 } 56910 return true; 56911 }); 56912 const oppositeFilter = modifiedData.filter === "$contains" ? "$notContains" : "$contains"; 56913 const oppositeFilterIndex = filtersWithoutFile.findIndex((filter) => { 56914 var _a3; 56915 return ((_a3 = filter.mime) == null ? void 0 : _a3[oppositeFilter]) === modifiedData.value; 56916 }); 56917 const hasOppositeFilter = oppositeFilterIndex !== -1; 56918 const filterToAdd = { 56919 [modifiedData.name]: { 56920 [modifiedData.filter]: modifiedData.value 56921 } 56922 }; 56923 if (!hasOppositeFilter) { 56924 const nextFilters = [ 56925 ...filtersWithoutFile, 56926 filterToAdd 56927 ]; 56928 onSubmit(nextFilters); 56929 onToggle(); 56930 return; 56931 } 56932 if (hasOppositeFilter) { 56933 const nextFilters = filtersWithoutFile.slice(); 56934 nextFilters.splice(oppositeFilterIndex, 1, filterToAdd); 56935 onSubmit(nextFilters); 56936 onToggle(); 56937 } 56938 return; 56939 } 56940 const hasFilter = filters.find((filter) => { 56941 var _a3; 56942 const modifiedDataName = modifiedData.name; 56943 return filter[modifiedDataName] && ((_a3 = filter[modifiedDataName]) == null ? void 0 : _a3[modifiedDataName]) === encodedValue; 56944 }) !== void 0; 56945 if (!hasFilter) { 56946 const filterToAdd = { 56947 [modifiedData.name]: { 56948 [modifiedData.filter]: encodedValue 56949 } 56950 }; 56951 const nextFilters = [ 56952 ...filters, 56953 filterToAdd 56954 ]; 56955 onSubmit(nextFilters); 56956 } 56957 } 56958 onToggle(); 56959 }; 56960 const appliedFilter = displayedFilters2.find((filter) => filter.name === modifiedData.name); 56961 return (0, import_jsx_runtime48.jsx)(Popover.Content, { 56962 sideOffset: 4, 56963 style: { 56964 zIndex: 499 56965 }, 56966 children: (0, import_jsx_runtime48.jsx)("form", { 56967 onSubmit: handleSubmit, 56968 children: (0, import_jsx_runtime48.jsxs)(Flex, { 56969 padding: 3, 56970 direction: "column", 56971 alignItems: "stretch", 56972 gap: 1, 56973 style: { 56974 minWidth: 184 56975 }, 56976 children: [ 56977 (0, import_jsx_runtime48.jsx)(Box, { 56978 children: (0, import_jsx_runtime48.jsx)(SingleSelect, { 56979 "aria-label": formatMessage({ 56980 id: "app.utils.select-field", 56981 defaultMessage: "Select field" 56982 }), 56983 name: "name", 56984 size: "M", 56985 onChange: handleChangeFilterField, 56986 value: modifiedData.name, 56987 children: displayedFilters2.map((filter) => { 56988 var _a3; 56989 return (0, import_jsx_runtime48.jsx)(SingleSelectOption, { 56990 value: filter.name, 56991 children: (_a3 = filter.metadatas) == null ? void 0 : _a3.label 56992 }, filter.name); 56993 }) 56994 }) 56995 }), 56996 (0, import_jsx_runtime48.jsx)(Box, { 56997 children: (0, import_jsx_runtime48.jsx)(SingleSelect, { 56998 "aria-label": formatMessage({ 56999 id: "app.utils.select-filter", 57000 defaultMessage: "Select filter" 57001 }), 57002 name: "filter", 57003 size: "M", 57004 value: modifiedData.filter, 57005 onChange: handleChangeOperator, 57006 children: getFilterList(appliedFilter).map((option) => { 57007 return (0, import_jsx_runtime48.jsx)(SingleSelectOption, { 57008 value: option.value, 57009 children: formatMessage(option.intlLabel) 57010 }, option.value); 57011 }) 57012 }) 57013 }), 57014 (0, import_jsx_runtime48.jsx)(Box, { 57015 children: (0, import_jsx_runtime48.jsx)(FilterValueInput, { 57016 ...appliedFilter == null ? void 0 : appliedFilter.metadatas, 57017 ...appliedFilter == null ? void 0 : appliedFilter.fieldSchema, 57018 value: modifiedData.value, 57019 onChange: (value) => setModifiedData((prev2) => ({ 57020 ...prev2, 57021 value 57022 })) 57023 }) 57024 }), 57025 (0, import_jsx_runtime48.jsx)(Box, { 57026 children: (0, import_jsx_runtime48.jsx)(Button, { 57027 size: "L", 57028 variant: "secondary", 57029 startIcon: (0, import_jsx_runtime48.jsx)(ForwardRef$G, {}), 57030 type: "submit", 57031 fullWidth: true, 57032 children: formatMessage({ 57033 id: "app.utils.add-filter", 57034 defaultMessage: "Add filter" 57035 }) 57036 }) 57037 }) 57038 ] 57039 }) 57040 }) 57041 }); 57042}; 57043 57044export { 57045 useAssets, 57046 useFolders, 57047 useMediaLibraryPermissions, 57048 useSelectionState, 57049 containsAssetFilter, 57050 useFolderStructure, 57051 formatBytes, 57052 getFileExtension, 57053 SelectTree, 57054 useUpload, 57055 prefixFileUrlWithBackendUrl, 57056 createAssetUrl, 57057 CopyLinkButton, 57058 useRemoveAsset, 57059 getFileIconComponent, 57060 EditAssetContent, 57061 EditAssetDialog, 57062 useBulkRemove, 57063 normalizeAPIError, 57064 EditFolderContent, 57065 EditFolderDialog, 57066 useFolder, 57067 usePersistentState, 57068 AudioPreview, 57069 formatDuration, 57070 VideoPreview, 57071 AssetGridList, 57072 getFolderURL, 57073 Breadcrumbs2 as Breadcrumbs, 57074 EmptyAssets, 57075 useFolderCard, 57076 FolderCard, 57077 FolderCardBody, 57078 FolderCardBodyAction, 57079 FolderGridList, 57080 SortPicker, 57081 TableList, 57082 displayedFilters, 57083 FilterList, 57084 FilterPopover, 57085 rawFileToAsset, 57086 AddAssetStep, 57087 UploadAssetDialog 57088}; 57089/*! Bundled license information: 57090 57091cropperjs/dist/cropper.esm.js: 57092 (*! 57093 * Cropper.js v1.6.1 57094 * https://fengyuanchen.github.io/cropperjs 57095 * 57096 * Copyright 2015-present Chen Fengyuan 57097 * Released under the MIT license 57098 * 57099 * Date: 2023-09-17T03:44:19.860Z 57100 *) 57101 57102mux-embed/dist/mux.mjs: 57103 (*! 57104 * JavaScript Cookie v2.1.3 57105 * https://github.com/js-cookie/js-cookie 57106 * 57107 * Copyright 2006, 2015 Klaus Hartl & Fagner Brack 57108 * Released under the MIT license 57109 *) 57110*/ 57111//# sourceMappingURL=chunk-TXTKOM3F.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.