hyperframes 0.7.75 → 0.7.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -50,7 +50,7 @@ var VERSION;
50
50
  var init_version = __esm({
51
51
  "src/version.ts"() {
52
52
  "use strict";
53
- VERSION = true ? "0.7.75" : "0.0.0-dev";
53
+ VERSION = true ? "0.7.76" : "0.0.0-dev";
54
54
  }
55
55
  });
56
56
 
@@ -125538,6 +125538,14 @@ function isExtractionCacheCompleteSentinelPath(path2) {
125538
125538
  const segments = path2.split("/");
125539
125539
  return segments.length === 3 && segments[0] === "video-frames" && segments[1] !== "" && segments[2] === EXTRACTION_CACHE_COMPLETE_SENTINEL;
125540
125540
  }
125541
+ function resolveExtractedVideoOutputDir(planDir, videoId) {
125542
+ const videoRoot = resolve36(planDir, "video-frames");
125543
+ const outputDir = resolve36(videoRoot, videoId);
125544
+ if (outputDir === videoRoot || !outputDir.startsWith(`${videoRoot}${sep10}`)) {
125545
+ throw new PlanV2IntegrityError(`unsafe extracted video id: ${JSON.stringify(videoId)}`);
125546
+ }
125547
+ return outputDir;
125548
+ }
125541
125549
  function artifactTargets(path2, videoDependencies) {
125542
125550
  if (path2 === PLAN_AUDIO_RELATIVE_PATH) return { chunks: [], assembler: true };
125543
125551
  if (path2 === "plan.json" || path2 === "meta/chunks.json" || path2 === "meta/encoder.json") {
@@ -125556,7 +125564,7 @@ function artifactTargets(path2, videoDependencies) {
125556
125564
  }
125557
125565
  function listVideoFramePaths(planV1Dir, videos) {
125558
125566
  return videos.extracted.map((video) => {
125559
- const outputDir = join68(planV1Dir, "video-frames", video.videoId);
125567
+ const outputDir = resolveExtractedVideoOutputDir(planV1Dir, video.videoId);
125560
125568
  const frameNames = readdirSync19(outputDir).sort();
125561
125569
  const framePaths = /* @__PURE__ */ new Map();
125562
125570
  for (const frameName of frameNames) {
@@ -125670,6 +125678,14 @@ function parsePlanVideosJson(value) {
125670
125678
  });
125671
125679
  return { videos, extracted };
125672
125680
  }
125681
+ function materializeExtractedVideoDirectories(planDir) {
125682
+ const videosPath = join68(planDir, PLAN_VIDEOS_META_RELATIVE_PATH);
125683
+ if (!existsSync59(videosPath)) return;
125684
+ const videos = parsePlanVideosJson(readJsonFile(videosPath, PLAN_VIDEOS_META_RELATIVE_PATH));
125685
+ for (const video of videos.extracted) {
125686
+ mkdirSync31(resolveExtractedVideoOutputDir(planDir, video.videoId), { recursive: true });
125687
+ }
125688
+ }
125673
125689
  function parseChunkSlices(value) {
125674
125690
  if (!Array.isArray(value)) {
125675
125691
  throw new PlanV2IntegrityError("meta/chunks.json must be an array");
@@ -126077,6 +126093,7 @@ function materializePlanV2Target(planV2Dir, target, destinationDir) {
126077
126093
  mkdirSync31(dirname30(destinationPath), { recursive: true });
126078
126094
  copyFileSync8(sourcePath, destinationPath);
126079
126095
  }
126096
+ if (target.role === "chunk") materializeExtractedVideoDirectories(tempDir);
126080
126097
  writeFileSync23(
126081
126098
  join68(tempDir, PLAN_V2_MATERIALIZATION_MARKER),
126082
126099
  canonicalJsonStringify({ manifest, target }),
@@ -139770,13 +139787,63 @@ function hasEnoughRotationSamples(group) {
139770
139787
  function isActuallySpinning(group) {
139771
139788
  return maxAngleSpread(group.map((s2) => s2.angle)) > ROTATION_MIN_ANGLE_SPREAD_DEG;
139772
139789
  }
139790
+ function aabbForRotatedRect(elemW, elemH, angleDeg) {
139791
+ const rad = angleDeg * Math.PI / 180;
139792
+ const cosAbs = Math.abs(Math.cos(rad));
139793
+ const sinAbs = Math.abs(Math.sin(rad));
139794
+ return { w: elemW * cosAbs + elemH * sinAbs, h: elemW * sinAbs + elemH * cosAbs };
139795
+ }
139796
+ function unrotatedSizeFromSample(sample) {
139797
+ const rad = sample.angle * Math.PI / 180;
139798
+ const cosAbs = Math.abs(Math.cos(rad));
139799
+ const sinAbs = Math.abs(Math.sin(rad));
139800
+ const det = cosAbs * cosAbs - sinAbs * sinAbs;
139801
+ if (Math.abs(det) < ROTATION_RIGID_ESTIMATE_MIN_DET) return null;
139802
+ const elemW = (cosAbs * sample.w - sinAbs * sample.h) / det;
139803
+ const elemH = (cosAbs * sample.h - sinAbs * sample.w) / det;
139804
+ if (!(elemW > 0) || !(elemH > 0)) return null;
139805
+ return { w: elemW, h: elemH };
139806
+ }
139807
+ function aabbMatchesSample(expected, sample) {
139808
+ if (expected.w <= 0 || expected.h <= 0 || sample.w <= 0 || sample.h <= 0) return false;
139809
+ return Math.max(expected.w, sample.w) / Math.min(expected.w, sample.w) <= ROTATION_RIGID_AABB_RATIO && Math.max(expected.h, sample.h) / Math.min(expected.h, sample.h) <= ROTATION_RIGID_AABB_RATIO;
139810
+ }
139811
+ function isSingularRotationAngle(angleDeg) {
139812
+ const rad = angleDeg * Math.PI / 180;
139813
+ const cosAbs = Math.abs(Math.cos(rad));
139814
+ const sinAbs = Math.abs(Math.sin(rad));
139815
+ return Math.abs(cosAbs * cosAbs - sinAbs * sinAbs) < ROTATION_RIGID_ESTIMATE_MIN_DET;
139816
+ }
139817
+ function isNearSquareAabb(sample) {
139818
+ if (sample.w <= 0 || sample.h <= 0) return false;
139819
+ return Math.max(sample.w, sample.h) / Math.min(sample.w, sample.h) <= ROTATION_RIGID_AABB_RATIO;
139820
+ }
139821
+ function fitsSingularPhaseRigidProjection(group) {
139822
+ if (group.length === 0 || !group.every((s2) => isSingularRotationAngle(s2.angle))) return false;
139823
+ if (!group.every(isNearSquareAabb)) return false;
139824
+ const ref2 = group[0];
139825
+ if (!ref2) return false;
139826
+ return group.every((sample) => aabbMatchesSample({ w: ref2.w, h: ref2.h }, sample));
139827
+ }
139828
+ function fitsOneRigidRectangle(group) {
139829
+ for (const ref2 of group) {
139830
+ const size = unrotatedSizeFromSample(ref2);
139831
+ if (!size) continue;
139832
+ if (group.every(
139833
+ (sample) => aabbMatchesSample(aabbForRotatedRect(size.w, size.h, sample.angle), sample)
139834
+ )) {
139835
+ return true;
139836
+ }
139837
+ }
139838
+ return fitsSingularPhaseRigidProjection(group);
139839
+ }
139773
139840
  function isRotationSizeStable(group) {
139774
- const widths = group.map((s2) => s2.w);
139775
- const heights = group.map((s2) => s2.h);
139776
- const minWidth = Math.min(...widths);
139777
- const minHeight = Math.min(...heights);
139778
- if (minWidth <= 0 || minHeight <= 0) return false;
139779
- return Math.max(...widths) / minWidth <= ROTATION_MAX_SIZE_RATIO && Math.max(...heights) / minHeight <= ROTATION_MAX_SIZE_RATIO;
139841
+ if (group.some((s2) => s2.w <= 0 || s2.h <= 0)) return false;
139842
+ const longSides = group.map((s2) => Math.max(s2.w, s2.h));
139843
+ const minLong = Math.min(...longSides);
139844
+ if (minLong <= 0) return false;
139845
+ if (Math.max(...longSides) / minLong > ROTATION_MAX_SIZE_RATIO) return false;
139846
+ return fitsOneRigidRectangle(group);
139780
139847
  }
139781
139848
  function isSizableRotation(group) {
139782
139849
  return median(group.map((s2) => s2.w * s2.h)) >= ROTATION_MIN_MEDIAN_AREA_PX;
@@ -140337,7 +140404,7 @@ async function captureFindingCrops2(project, options, requests) {
140337
140404
  const module = await Promise.resolve().then(() => (init_checkBrowser(), checkBrowser_exports));
140338
140405
  return module.captureFindingCrops(project, options, requests);
140339
140406
  }
140340
- var MOTION_FPS2, MOTION_MAX_SAMPLES2, ZERO_BBOX, FRAME_BREACH_FLOOR_PX, FRAME_BREACH_FLOOR_FRACTION, DEFAULT_CHECK_OPTIONS, OVERLAP_SAMPLE_FPS, OVERLAP_MAX_SAMPLES, SWEEP_STATIC_MIN_DURATION_SEC, ZERO_LAYOUT_RECT, ROTATION_MIN_SAMPLES, ROTATION_MIN_ANGLE_SPREAD_DEG, ROTATION_MAX_SIZE_RATIO, ROTATION_MIN_MEDIAN_AREA_PX, ROTATION_DRIFT_SIZE_FRACTION, ROTATION_DRIFT_VIEWPORT_FRACTION, INDICATOR_MIN_SAMPLES, INDICATOR_MIN_ANGLE_SPREAD_DEG, INDICATOR_MIN_HUB_CIRCLES, INDICATOR_MAX_FIT_RESIDUAL_FRACTION, INDICATOR_MAX_RIGID_LEN_VARIATION, INDICATOR_DRIFT_LENGTH_FRACTION, INDICATOR_MIN_HUB_PRESENCE_FRACTION, MAX_FINDING_CROPS, DEFAULT_DEPENDENCIES;
140407
+ var MOTION_FPS2, MOTION_MAX_SAMPLES2, ZERO_BBOX, FRAME_BREACH_FLOOR_PX, FRAME_BREACH_FLOOR_FRACTION, DEFAULT_CHECK_OPTIONS, OVERLAP_SAMPLE_FPS, OVERLAP_MAX_SAMPLES, SWEEP_STATIC_MIN_DURATION_SEC, ZERO_LAYOUT_RECT, ROTATION_MIN_SAMPLES, ROTATION_MIN_ANGLE_SPREAD_DEG, ROTATION_MAX_SIZE_RATIO, ROTATION_RIGID_AABB_RATIO, ROTATION_RIGID_ESTIMATE_MIN_DET, ROTATION_MIN_MEDIAN_AREA_PX, ROTATION_DRIFT_SIZE_FRACTION, ROTATION_DRIFT_VIEWPORT_FRACTION, INDICATOR_MIN_SAMPLES, INDICATOR_MIN_ANGLE_SPREAD_DEG, INDICATOR_MIN_HUB_CIRCLES, INDICATOR_MAX_FIT_RESIDUAL_FRACTION, INDICATOR_MAX_RIGID_LEN_VARIATION, INDICATOR_DRIFT_LENGTH_FRACTION, INDICATOR_MIN_HUB_PRESENCE_FRACTION, MAX_FINDING_CROPS, DEFAULT_DEPENDENCIES;
140341
140408
  var init_checkPipeline = __esm({
140342
140409
  "src/utils/checkPipeline.ts"() {
140343
140410
  "use strict";
@@ -140380,6 +140447,8 @@ var init_checkPipeline = __esm({
140380
140447
  ROTATION_MIN_SAMPLES = 3;
140381
140448
  ROTATION_MIN_ANGLE_SPREAD_DEG = 20;
140382
140449
  ROTATION_MAX_SIZE_RATIO = 1.6;
140450
+ ROTATION_RIGID_AABB_RATIO = 1.15;
140451
+ ROTATION_RIGID_ESTIMATE_MIN_DET = 0.15;
140383
140452
  ROTATION_MIN_MEDIAN_AREA_PX = 2500;
140384
140453
  ROTATION_DRIFT_SIZE_FRACTION = 0.1;
140385
140454
  ROTATION_DRIFT_VIEWPORT_FRACTION = 0.02;
@@ -1198,6 +1198,7 @@
1198
1198
  return issues;
1199
1199
  }
1200
1200
 
1201
+ // Soft prior only — the counterfactual attach test (below) is what makes detachment a finding.
1201
1202
  const CONNECTOR_NAME = /\b(conn(ector)?|arrow|edge|link|flow|wire)\b/i;
1202
1203
  const CONNECTOR_SKIP_CONTAINERS = "defs, marker, clipPath, mask, symbol, pattern";
1203
1204
 
@@ -1207,14 +1208,16 @@
1207
1208
  return `${element.id || ""} ${className}`;
1208
1209
  }
1209
1210
 
1210
- // Screen-space endpoints via the browser: getScreenCTM covers viewBox, preserveAspectRatio and group transforms.
1211
- function pathScreenEndpoints(svg, path) {
1212
- if (
1213
- typeof path.getTotalLength !== "function" ||
1214
- typeof path.getPointAtLength !== "function" ||
1215
- typeof path.getScreenCTM !== "function" ||
1216
- typeof svg.createSVGPoint !== "function"
1217
- ) {
1211
+ function isConnectorPath(svg, path) {
1212
+ if (path.hasAttribute("marker-start") || path.hasAttribute("marker-end")) return true;
1213
+ return (
1214
+ CONNECTOR_NAME.test(connectorNameFor(svg)) || CONNECTOR_NAME.test(connectorNameFor(path))
1215
+ );
1216
+ }
1217
+
1218
+ /** Raw `d`-space endpoints (no CTM) — the mapping authors use when they paste screen coords into `d`. */
1219
+ function pathUserEndpoints(path) {
1220
+ if (typeof path.getTotalLength !== "function" || typeof path.getPointAtLength !== "function") {
1218
1221
  return null;
1219
1222
  }
1220
1223
  let total;
@@ -1224,6 +1227,20 @@
1224
1227
  return null;
1225
1228
  }
1226
1229
  if (!Number.isFinite(total) || total <= 0) return null;
1230
+ const start = path.getPointAtLength(0);
1231
+ const end = path.getPointAtLength(total);
1232
+ return { start: { x: start.x, y: start.y }, end: { x: end.x, y: end.y } };
1233
+ }
1234
+
1235
+ // Screen endpoints via getScreenCTM (viewBox, preserveAspectRatio, group transforms).
1236
+ function pathScreenEndpoints(svg, path, user) {
1237
+ if (
1238
+ !user ||
1239
+ typeof path.getScreenCTM !== "function" ||
1240
+ typeof svg.createSVGPoint !== "function"
1241
+ ) {
1242
+ return null;
1243
+ }
1227
1244
  const matrix = path.getScreenCTM();
1228
1245
  if (!matrix) return null;
1229
1246
  const toScreen = (local) => {
@@ -1233,10 +1250,7 @@
1233
1250
  const mapped = point.matrixTransform(matrix);
1234
1251
  return { x: mapped.x, y: mapped.y };
1235
1252
  };
1236
- return {
1237
- start: toScreen(path.getPointAtLength(0)),
1238
- end: toScreen(path.getPointAtLength(total)),
1239
- };
1253
+ return { start: toScreen(user.start), end: toScreen(user.end) };
1240
1254
  }
1241
1255
 
1242
1256
  function distanceToRect(point, rect) {
@@ -1246,6 +1260,7 @@
1246
1260
  }
1247
1261
 
1248
1262
  // Solid, compact elements a connector could plausibly anchor to.
1263
+ // Both tiers keep `element` so attachment identity is stable across containment vs near-miss.
1249
1264
  function connectorAnchorRects(root, rootRect) {
1250
1265
  const compact = [];
1251
1266
  const painted = [];
@@ -1261,42 +1276,57 @@
1261
1276
  if (area < 400) continue;
1262
1277
  // Containment tier: large opaque targets only — a text-bearing wrapper contains its own diagram's endpoints.
1263
1278
  if (opaque && area <= rootArea * 0.6) painted.push({ rect, element });
1264
- if (area <= rootArea * 0.15) compact.push(rect);
1279
+ if (area <= rootArea * 0.15) compact.push({ rect, element });
1265
1280
  }
1266
1281
  return { compact, painted };
1267
1282
  }
1268
1283
 
1269
- function isConnectorPath(svg, path) {
1270
- if (path.hasAttribute("marker-start") || path.hasAttribute("marker-end")) return true;
1271
- return (
1272
- CONNECTOR_NAME.test(connectorNameFor(svg)) || CONNECTOR_NAME.test(connectorNameFor(path))
1273
- );
1274
- }
1275
-
1276
- // A connector whose BOTH endpoints land far from every anchorable element was drawn in the wrong frame.
1277
- // min over the two endpoints is intentional: a half-attached connector is a design choice, not frame drift.
1284
+ // Flag only the documented bug: rendered endpoints miss, but user-space-as-screen would attach.
1278
1285
  function connectorDetachmentIssues(root, rootRect, time) {
1279
1286
  const issues = [];
1280
1287
  let anchors = null;
1288
+ // Attach near-miss tolerance (screen px). Separate from the closed-glyph chord floor.
1281
1289
  const threshold = Math.max(32, Math.min(rootRect.width, rootRect.height) * 0.02);
1290
+ const MIN_CONNECTOR_CHORD_PX = 8;
1282
1291
  for (const svg of Array.from(root.querySelectorAll("svg"))) {
1283
1292
  if (!isVisibleElement(svg) || hasAllowOverflowFlag(svg)) continue;
1284
1293
  for (const path of Array.from(svg.querySelectorAll("path"))) {
1285
1294
  if (path.closest(CONNECTOR_SKIP_CONTAINERS)) continue;
1286
1295
  if (!isConnectorPath(svg, path)) continue;
1287
- const endpoints = pathScreenEndpoints(svg, path);
1288
- if (!endpoints) continue;
1296
+ const user = pathUserEndpoints(path);
1297
+ const rendered = pathScreenEndpoints(svg, path, user);
1298
+ if (!user || !rendered) continue;
1299
+ // Closed/glyph paths collapse to one point — compare in screen px (not user units).
1300
+ const renderedChord = Math.hypot(
1301
+ rendered.end.x - rendered.start.x,
1302
+ rendered.end.y - rendered.start.y,
1303
+ );
1304
+ if (renderedChord < MIN_CONNECTOR_CHORD_PX) continue;
1289
1305
  if (anchors === null) anchors = connectorAnchorRects(root, rootRect);
1290
1306
  if (anchors.compact.length < 2) return issues;
1291
- const attached = (point) =>
1292
- anchors.painted.some(
1293
- (anchor) => !anchor.element.contains(svg) && distanceToRect(point, anchor.rect) === 0,
1294
- ) || anchors.compact.some((rect) => distanceToRect(point, rect) <= threshold);
1295
- if (attached(endpoints.start) || attached(endpoints.end)) continue;
1307
+ // Stable DOM identity across painted (inside) and compact (near-miss) tiers.
1308
+ const attachmentKey = (point) => {
1309
+ for (const anchor of anchors.painted) {
1310
+ if (!anchor.element.contains(svg) && distanceToRect(point, anchor.rect) === 0) {
1311
+ return anchor.element;
1312
+ }
1313
+ }
1314
+ for (const anchor of anchors.compact) {
1315
+ if (distanceToRect(point, anchor.rect) <= threshold) return anchor.element;
1316
+ }
1317
+ return null;
1318
+ };
1319
+ const attached = (point) => attachmentKey(point) !== null;
1320
+ // Half-attached as drawn is allowed; only full render-miss proceeds.
1321
+ if (attached(rendered.start) || attached(rendered.end)) continue;
1322
+ // Paste-into-`d` bug: both raw endpoints land on distinct anchors as screen pixels.
1323
+ const userStartKey = attachmentKey(user.start);
1324
+ const userEndKey = attachmentKey(user.end);
1325
+ if (!userStartKey || !userEndKey || userStartKey === userEndKey) continue;
1296
1326
  const gap = Math.round(
1297
1327
  Math.min(
1298
- Math.min(...anchors.compact.map((rect) => distanceToRect(endpoints.start, rect))),
1299
- Math.min(...anchors.compact.map((rect) => distanceToRect(endpoints.end, rect))),
1328
+ Math.min(...anchors.compact.map((a) => distanceToRect(rendered.start, a.rect))),
1329
+ Math.min(...anchors.compact.map((a) => distanceToRect(rendered.end, a.rect))),
1300
1330
  ),
1301
1331
  );
1302
1332
  issues.push({
@@ -1305,17 +1335,17 @@
1305
1335
  time,
1306
1336
  selector: selectorFor(path),
1307
1337
  containerSelector: selectorFor(svg),
1308
- message: `Connector path endpoints are ${gap}px from the nearest anchorable element measured coordinates were likely drawn into an SVG with a different origin.`,
1338
+ message: `Connector path endpoints render ${gap}px from the nearest anchorable element, but the path's user-space coordinates would attach if read as screen pixels — screen/viewport numbers were likely written into SVG \`d\` without inverting the CTM.`,
1309
1339
  rect: toRect({
1310
- left: Math.min(endpoints.start.x, endpoints.end.x),
1311
- top: Math.min(endpoints.start.y, endpoints.end.y),
1312
- right: Math.max(endpoints.start.x, endpoints.end.x),
1313
- bottom: Math.max(endpoints.start.y, endpoints.end.y),
1314
- width: Math.abs(endpoints.end.x - endpoints.start.x),
1315
- height: Math.abs(endpoints.end.y - endpoints.start.y),
1340
+ left: Math.min(rendered.start.x, rendered.end.x),
1341
+ top: Math.min(rendered.start.y, rendered.end.y),
1342
+ right: Math.max(rendered.start.x, rendered.end.x),
1343
+ bottom: Math.max(rendered.start.y, rendered.end.y),
1344
+ width: Math.abs(rendered.end.x - rendered.start.x),
1345
+ height: Math.abs(rendered.end.y - rendered.start.y),
1316
1346
  }),
1317
1347
  fixHint:
1318
- "Subtract the SVG's own rect when converting measured coordinates, and keep the SVG a direct child of the stage.",
1348
+ "Convert measured screen coordinates into the SVG's user space (subtract the SVG rect / invert getScreenCTM) before writing path `d`, and keep the SVG a direct child of the stage.",
1319
1349
  });
1320
1350
  }
1321
1351
  }
@@ -1,4 +1,4 @@
1
- "use strict";var HyperframesPlayer=(()=>{var J=Object.defineProperty;var Ge=Object.getOwnPropertyDescriptor;var qe=Object.getOwnPropertyNames;var Ye=Object.prototype.hasOwnProperty;var Xe=(i,e)=>{for(var t in e)J(i,t,{get:e[t],enumerable:!0})},Ze=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of qe(e))!Ye.call(i,n)&&n!==t&&J(i,n,{get:()=>e[n],enumerable:!(r=Ge(e,n))||r.enumerable});return i};var Qe=i=>Ze(J({},"__esModule",{value:!0}),i);var Lt={};Xe(Lt,{HyperframesPlayer:()=>Q,SPEED_PRESETS:()=>te,formatSpeed:()=>N,formatTime:()=>$});function ye(i){return i.hasRuntime||i.runtimeInjected?!1:!!(i.hasNestedCompositions||i.hasTimelines&&i.attempts>=5)}function I(i){return typeof i=="object"&&i!==null}function Ee(i){return I(i)&&typeof i.getDuration=="function"}function Se(i){return I(i)&&typeof i.duration=="function"&&typeof i.time=="function"&&typeof i.seek=="function"&&typeof i.play=="function"&&typeof i.pause=="function"}var Je="https://cdn.jsdelivr.net/npm/@hyperframes/core@0.7.75/dist/hyperframe.runtime.iife.js";function D(i){if(i===null)return null;let e=Number.parseInt(i,10);return Number.isFinite(e)&&e>0?e:null}function Ke(i){let e=i?.querySelector("[data-composition-id][data-width][data-height]")??i?.querySelector("[data-width][data-height]");if(!e)return null;let t=D(e.getAttribute("data-width")),r=D(e.getAttribute("data-height"));return t!==null&&r!==null?{width:t,height:r}:null}var j=class{constructor(e,t){this._iframe=e;this._callbacks=t}_iframe;_callbacks;_interval=null;_runtimeInjected=!1;get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let e=0;this._interval=setInterval(()=>{e++;try{let t=this._iframe.contentWindow;if(!t)return;let r=!!(t.__hf||t.__player),n=!!(t.__timelines&&Object.keys(t.__timelines).length>0),o=!!this._iframe.contentDocument?.querySelector("[data-composition-src]");if(ye({hasRuntime:r,hasTimelines:n,hasNestedCompositions:o,runtimeInjected:this._runtimeInjected,attempts:e})){this._injectRuntime();return}if(this._runtimeInjected&&!r)return;let s=this._resolvePlaybackDurationAdapter(t);if(s&&s.getDuration()>0){this.stop();let l=Ke(this._iframe.contentDocument);this._callbacks.onReady({duration:s.getDuration(),adapter:s,compositionSize:l});return}}catch{}e>=40&&(this.stop(),this._callbacks.onError("Composition timeline not found after 8s"))},200)}stop(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{let e=this._iframe.contentWindow;return e?this._resolveDirectTimelineAdapterFromWindow(e):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(e){return this._resolveDirectTimelineAdapterFromWindow(e)}hasRuntimeBridge(e){return Reflect.get(e,"__hf")!==void 0||I(Reflect.get(e,"__player"))}_injectRuntime(){this._runtimeInjected=!0;try{let e=this._iframe.contentDocument;if(!e)return;let t=e.createElement("script");t.src=Je,(e.head||e.documentElement).appendChild(t),this._callbacks.onRuntimeInjected?.()}catch{}}_resolveDirectTimelineAdapterFromWindow(e){if(this.hasRuntimeBridge(e))return null;let t=Reflect.get(e,"__timelines");if(!I(t))return null;let r=Object.keys(t);if(r.length===0)return null;let n=this._iframe.contentDocument?.querySelector("[data-composition-id]")?.getAttribute("data-composition-id"),o=n&&n in t?n:r[r.length-1],s=t[o];return Se(s)?s:null}_resolvePlaybackDurationAdapter(e){let t=Reflect.get(e,"__player");if(Ee(t))return{kind:"runtime",getDuration:()=>t.getDuration()};let r=this._resolveDirectTimelineAdapterFromWindow(e);return r?{kind:"direct-timeline",timeline:r,getDuration:()=>r.duration()}:null}};var Te=`
1
+ "use strict";var HyperframesPlayer=(()=>{var J=Object.defineProperty;var Ge=Object.getOwnPropertyDescriptor;var qe=Object.getOwnPropertyNames;var Ye=Object.prototype.hasOwnProperty;var Xe=(i,e)=>{for(var t in e)J(i,t,{get:e[t],enumerable:!0})},Ze=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of qe(e))!Ye.call(i,n)&&n!==t&&J(i,n,{get:()=>e[n],enumerable:!(r=Ge(e,n))||r.enumerable});return i};var Qe=i=>Ze(J({},"__esModule",{value:!0}),i);var Lt={};Xe(Lt,{HyperframesPlayer:()=>Q,SPEED_PRESETS:()=>te,formatSpeed:()=>N,formatTime:()=>$});function ye(i){return i.hasRuntime||i.runtimeInjected?!1:!!(i.hasNestedCompositions||i.hasTimelines&&i.attempts>=5)}function I(i){return typeof i=="object"&&i!==null}function Ee(i){return I(i)&&typeof i.getDuration=="function"}function Se(i){return I(i)&&typeof i.duration=="function"&&typeof i.time=="function"&&typeof i.seek=="function"&&typeof i.play=="function"&&typeof i.pause=="function"}var Je="https://cdn.jsdelivr.net/npm/@hyperframes/core@0.7.76/dist/hyperframe.runtime.iife.js";function D(i){if(i===null)return null;let e=Number.parseInt(i,10);return Number.isFinite(e)&&e>0?e:null}function Ke(i){let e=i?.querySelector("[data-composition-id][data-width][data-height]")??i?.querySelector("[data-width][data-height]");if(!e)return null;let t=D(e.getAttribute("data-width")),r=D(e.getAttribute("data-height"));return t!==null&&r!==null?{width:t,height:r}:null}var j=class{constructor(e,t){this._iframe=e;this._callbacks=t}_iframe;_callbacks;_interval=null;_runtimeInjected=!1;get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let e=0;this._interval=setInterval(()=>{e++;try{let t=this._iframe.contentWindow;if(!t)return;let r=!!(t.__hf||t.__player),n=!!(t.__timelines&&Object.keys(t.__timelines).length>0),o=!!this._iframe.contentDocument?.querySelector("[data-composition-src]");if(ye({hasRuntime:r,hasTimelines:n,hasNestedCompositions:o,runtimeInjected:this._runtimeInjected,attempts:e})){this._injectRuntime();return}if(this._runtimeInjected&&!r)return;let s=this._resolvePlaybackDurationAdapter(t);if(s&&s.getDuration()>0){this.stop();let l=Ke(this._iframe.contentDocument);this._callbacks.onReady({duration:s.getDuration(),adapter:s,compositionSize:l});return}}catch{}e>=40&&(this.stop(),this._callbacks.onError("Composition timeline not found after 8s"))},200)}stop(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{let e=this._iframe.contentWindow;return e?this._resolveDirectTimelineAdapterFromWindow(e):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(e){return this._resolveDirectTimelineAdapterFromWindow(e)}hasRuntimeBridge(e){return Reflect.get(e,"__hf")!==void 0||I(Reflect.get(e,"__player"))}_injectRuntime(){this._runtimeInjected=!0;try{let e=this._iframe.contentDocument;if(!e)return;let t=e.createElement("script");t.src=Je,(e.head||e.documentElement).appendChild(t),this._callbacks.onRuntimeInjected?.()}catch{}}_resolveDirectTimelineAdapterFromWindow(e){if(this.hasRuntimeBridge(e))return null;let t=Reflect.get(e,"__timelines");if(!I(t))return null;let r=Object.keys(t);if(r.length===0)return null;let n=this._iframe.contentDocument?.querySelector("[data-composition-id]")?.getAttribute("data-composition-id"),o=n&&n in t?n:r[r.length-1],s=t[o];return Se(s)?s:null}_resolvePlaybackDurationAdapter(e){let t=Reflect.get(e,"__player");if(Ee(t))return{kind:"runtime",getDuration:()=>t.getDuration()};let r=this._resolveDirectTimelineAdapterFromWindow(e);return r?{kind:"direct-timeline",timeline:r,getDuration:()=>r.duration()}:null}};var Te=`
2
2
  :host {
3
3
  display: block;
4
4
  position: relative;
@@ -1,4 +1,4 @@
1
- var ce=Object.defineProperty;var pe=(r,t,e)=>t in r?ce(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var c=(r,t,e)=>pe(r,typeof t!="symbol"?t+"":t,e);import{r as ne,i as me,a as fe}from"./index-DzDajONI.js";function _e(r){return r.hasRuntime||r.runtimeInjected?!1:!!(r.hasNestedCompositions||r.hasTimelines&&r.attempts>=5)}function F(r){return typeof r=="object"&&r!==null}function ge(r){return F(r)&&typeof r.getDuration=="function"}function ye(r){return F(r)&&typeof r.duration=="function"&&typeof r.time=="function"&&typeof r.seek=="function"&&typeof r.play=="function"&&typeof r.pause=="function"}function ve(r){if(!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(r))throw new Error(`Invalid HyperFrames runtime version: ${r}`);return`https://cdn.jsdelivr.net/npm/@hyperframes/core@${r}/dist/hyperframe.runtime.iife.js`}const be=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:ve("0.0.0-dev");function H(r){if(r===null)return null;const t=Number.parseInt(r,10);return Number.isFinite(t)&&t>0?t:null}function we(r){const t=(r==null?void 0:r.querySelector("[data-composition-id][data-width][data-height]"))??(r==null?void 0:r.querySelector("[data-width][data-height]"));if(!t)return null;const e=H(t.getAttribute("data-width")),i=H(t.getAttribute("data-height"));return e!==null&&i!==null?{width:e,height:i}:null}class Ae{constructor(t,e){c(this,"_interval",null);c(this,"_runtimeInjected",!1);this._iframe=t,this._callbacks=e}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let t=0;this._interval=setInterval(()=>{var e;t++;try{const i=this._iframe.contentWindow;if(!i)return;const s=!!(i.__hf||i.__player),o=!!(i.__timelines&&Object.keys(i.__timelines).length>0),d=!!((e=this._iframe.contentDocument)!=null&&e.querySelector("[data-composition-src]"));if(_e({hasRuntime:s,hasTimelines:o,hasNestedCompositions:d,runtimeInjected:this._runtimeInjected,attempts:t})){this._injectRuntime();return}if(this._runtimeInjected&&!s)return;const a=this._resolvePlaybackDurationAdapter(i);if(a&&a.getDuration()>0){this.stop();const h=we(this._iframe.contentDocument);this._callbacks.onReady({duration:a.getDuration(),adapter:a,compositionSize:h});return}}catch{}t>=40&&(this.stop(),this._callbacks.onError("Composition timeline not found after 8s"))},200)}stop(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{const t=this._iframe.contentWindow;return t?this._resolveDirectTimelineAdapterFromWindow(t):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(t){return this._resolveDirectTimelineAdapterFromWindow(t)}hasRuntimeBridge(t){return Reflect.get(t,"__hf")!==void 0||F(Reflect.get(t,"__player"))}_injectRuntime(){var t,e;this._runtimeInjected=!0;try{const i=this._iframe.contentDocument;if(!i)return;const s=i.createElement("script");s.src=be,(i.head||i.documentElement).appendChild(s),(e=(t=this._callbacks).onRuntimeInjected)==null||e.call(t)}catch{}}_resolveDirectTimelineAdapterFromWindow(t){var a,h;if(this.hasRuntimeBridge(t))return null;const e=Reflect.get(t,"__timelines");if(!F(e))return null;const i=Object.keys(e);if(i.length===0)return null;const s=(h=(a=this._iframe.contentDocument)==null?void 0:a.querySelector("[data-composition-id]"))==null?void 0:h.getAttribute("data-composition-id"),o=s&&s in e?s:i[i.length-1],d=e[o];return ye(d)?d:null}_resolvePlaybackDurationAdapter(t){const e=Reflect.get(t,"__player");if(ge(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const i=this._resolveDirectTimelineAdapterFromWindow(t);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}}const Ee=`
1
+ var ce=Object.defineProperty;var pe=(r,t,e)=>t in r?ce(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var c=(r,t,e)=>pe(r,typeof t!="symbol"?t+"":t,e);import{r as ne,i as me,a as fe}from"./index-BdOfFsR8.js";function _e(r){return r.hasRuntime||r.runtimeInjected?!1:!!(r.hasNestedCompositions||r.hasTimelines&&r.attempts>=5)}function F(r){return typeof r=="object"&&r!==null}function ge(r){return F(r)&&typeof r.getDuration=="function"}function ye(r){return F(r)&&typeof r.duration=="function"&&typeof r.time=="function"&&typeof r.seek=="function"&&typeof r.play=="function"&&typeof r.pause=="function"}function ve(r){if(!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(r))throw new Error(`Invalid HyperFrames runtime version: ${r}`);return`https://cdn.jsdelivr.net/npm/@hyperframes/core@${r}/dist/hyperframe.runtime.iife.js`}const be=typeof __HYPERFRAMES_RUNTIME_CDN_URL__=="string"?__HYPERFRAMES_RUNTIME_CDN_URL__:ve("0.0.0-dev");function H(r){if(r===null)return null;const t=Number.parseInt(r,10);return Number.isFinite(t)&&t>0?t:null}function we(r){const t=(r==null?void 0:r.querySelector("[data-composition-id][data-width][data-height]"))??(r==null?void 0:r.querySelector("[data-width][data-height]"));if(!t)return null;const e=H(t.getAttribute("data-width")),i=H(t.getAttribute("data-height"));return e!==null&&i!==null?{width:e,height:i}:null}class Ae{constructor(t,e){c(this,"_interval",null);c(this,"_runtimeInjected",!1);this._iframe=t,this._callbacks=e}get runtimeInjected(){return this._runtimeInjected}start(){this.stop(),this._runtimeInjected=!1;let t=0;this._interval=setInterval(()=>{var e;t++;try{const i=this._iframe.contentWindow;if(!i)return;const s=!!(i.__hf||i.__player),o=!!(i.__timelines&&Object.keys(i.__timelines).length>0),d=!!((e=this._iframe.contentDocument)!=null&&e.querySelector("[data-composition-src]"));if(_e({hasRuntime:s,hasTimelines:o,hasNestedCompositions:d,runtimeInjected:this._runtimeInjected,attempts:t})){this._injectRuntime();return}if(this._runtimeInjected&&!s)return;const a=this._resolvePlaybackDurationAdapter(i);if(a&&a.getDuration()>0){this.stop();const h=we(this._iframe.contentDocument);this._callbacks.onReady({duration:a.getDuration(),adapter:a,compositionSize:h});return}}catch{}t>=40&&(this.stop(),this._callbacks.onError("Composition timeline not found after 8s"))},200)}stop(){this._interval!==null&&(clearInterval(this._interval),this._interval=null)}resolveDirectTimelineAdapter(){try{const t=this._iframe.contentWindow;return t?this._resolveDirectTimelineAdapterFromWindow(t):null}catch{return null}}resolveDirectTimelineAdapterFromWindow(t){return this._resolveDirectTimelineAdapterFromWindow(t)}hasRuntimeBridge(t){return Reflect.get(t,"__hf")!==void 0||F(Reflect.get(t,"__player"))}_injectRuntime(){var t,e;this._runtimeInjected=!0;try{const i=this._iframe.contentDocument;if(!i)return;const s=i.createElement("script");s.src=be,(i.head||i.documentElement).appendChild(s),(e=(t=this._callbacks).onRuntimeInjected)==null||e.call(t)}catch{}}_resolveDirectTimelineAdapterFromWindow(t){var a,h;if(this.hasRuntimeBridge(t))return null;const e=Reflect.get(t,"__timelines");if(!F(e))return null;const i=Object.keys(e);if(i.length===0)return null;const s=(h=(a=this._iframe.contentDocument)==null?void 0:a.querySelector("[data-composition-id]"))==null?void 0:h.getAttribute("data-composition-id"),o=s&&s in e?s:i[i.length-1],d=e[o];return ye(d)?d:null}_resolvePlaybackDurationAdapter(t){const e=Reflect.get(t,"__player");if(ge(e))return{kind:"runtime",getDuration:()=>e.getDuration()};const i=this._resolveDirectTimelineAdapterFromWindow(t);return i?{kind:"direct-timeline",timeline:i,getDuration:()=>i.duration()}:null}}const Ee=`
2
2
  :host {
3
3
  display: block;
4
4
  position: relative;
@@ -1 +1 @@
1
- import{g as P}from"./index-DzDajONI.js";function j(c,d){for(var s=0;s<d.length;s++){const a=d[s];if(typeof a!="string"&&!Array.isArray(a)){for(const i in a)if(i!=="default"&&!(i in c)){const l=Object.getOwnPropertyDescriptor(a,i);l&&Object.defineProperty(c,i,l.get?l:{enumerable:!0,get:()=>a[i]})}}}return Object.freeze(Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}))}var v={},w;function k(){if(w)return v;w=1,Object.defineProperty(v,"__esModule",{value:!0}),v.default=d;var c=window.OfflineAudioContext||window.webkitOfflineAudioContext;function d(e){var r=a(e);return r.start(0),[i,y,O(e.sampleRate),s].reduce(function(t,o){return o(t)},r.buffer.getChannelData(0))}function s(e){return e.sort(function(r,t){return t.count-r.count}).splice(0,5)[0].tempo}function a(e){var r=e.length,t=e.numberOfChannels,o=e.sampleRate,n=new c(t,r,o),u=n.createBufferSource();u.buffer=e;var f=n.createBiquadFilter();return f.type="lowpass",u.connect(f),f.connect(n.destination),u}function i(e){for(var r=[],t=.9,o=.3,n=15;r.length<n&&t>=o;)r=l(e,t),t-=.05;if(r.length<n)throw new Error("Could not find enough samples for a reliable detection.");return r}function l(e,r){for(var t=[],o=0,n=e.length;o<n;o+=1)e[o]>r&&(t.push(o),o+=1e4);return t}function y(e){var r=[];return e.forEach(function(t,o){for(var n=function(x){var g=e[o+x]-t,_=r.some(function(h){if(h.interval===g)return h.count+=1});_||r.push({interval:g,count:1})},u=0;u<10;u+=1)n(u)}),r}function O(e){return function(r){var t=[];return r.forEach(function(o){if(o.interval!==0){for(var n=60/(o.interval/e);n<90;)n*=2;for(;n>180;)n/=2;n=Math.round(n);var u=t.some(function(f){if(f.tempo===n)return f.count+=o.count});u||t.push({tempo:n,count:o.count})}}),t}}return v}var p,b;function q(){return b||(b=1,p=k().default),p}var m=q();const A=P(m),D=j({__proto__:null,default:A},[m]);export{D as i};
1
+ import{g as P}from"./index-BdOfFsR8.js";function j(c,d){for(var s=0;s<d.length;s++){const a=d[s];if(typeof a!="string"&&!Array.isArray(a)){for(const i in a)if(i!=="default"&&!(i in c)){const l=Object.getOwnPropertyDescriptor(a,i);l&&Object.defineProperty(c,i,l.get?l:{enumerable:!0,get:()=>a[i]})}}}return Object.freeze(Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}))}var v={},w;function k(){if(w)return v;w=1,Object.defineProperty(v,"__esModule",{value:!0}),v.default=d;var c=window.OfflineAudioContext||window.webkitOfflineAudioContext;function d(e){var r=a(e);return r.start(0),[i,y,O(e.sampleRate),s].reduce(function(t,o){return o(t)},r.buffer.getChannelData(0))}function s(e){return e.sort(function(r,t){return t.count-r.count}).splice(0,5)[0].tempo}function a(e){var r=e.length,t=e.numberOfChannels,o=e.sampleRate,n=new c(t,r,o),u=n.createBufferSource();u.buffer=e;var f=n.createBiquadFilter();return f.type="lowpass",u.connect(f),f.connect(n.destination),u}function i(e){for(var r=[],t=.9,o=.3,n=15;r.length<n&&t>=o;)r=l(e,t),t-=.05;if(r.length<n)throw new Error("Could not find enough samples for a reliable detection.");return r}function l(e,r){for(var t=[],o=0,n=e.length;o<n;o+=1)e[o]>r&&(t.push(o),o+=1e4);return t}function y(e){var r=[];return e.forEach(function(t,o){for(var n=function(x){var g=e[o+x]-t,_=r.some(function(h){if(h.interval===g)return h.count+=1});_||r.push({interval:g,count:1})},u=0;u<10;u+=1)n(u)}),r}function O(e){return function(r){var t=[];return r.forEach(function(o){if(o.interval!==0){for(var n=60/(o.interval/e);n<90;)n*=2;for(;n>180;)n/=2;n=Math.round(n);var u=t.some(function(f){if(f.tempo===n)return f.count+=o.count});u||t.push({tempo:n,count:o.count})}}),t}}return v}var p,b;function q(){return b||(b=1,p=k().default),p}var m=q();const A=P(m),D=j({__proto__:null,default:A},[m]);export{D as i};