@leafer-game/miniapp 1.0.10 → 1.1.0

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/miniapp.cjs CHANGED
@@ -70,7 +70,7 @@ function updateStyle(leaf, style, type) {
70
70
  const fromStyle = transition ? getFromStyle(leaf, style) : undefined;
71
71
  leaf.killAnimate('transition');
72
72
  if (normalStyle)
73
- leaf.set(normalStyle, true);
73
+ leaf.set(normalStyle, 'temp');
74
74
  const statesStyle = getStyle(leaf);
75
75
  if (statesStyle) {
76
76
  const { animation } = statesStyle;
@@ -84,14 +84,14 @@ function updateStyle(leaf, style, type) {
84
84
  delete statesStyle.animation;
85
85
  }
86
86
  leaf.normalStyle = filterStyle(statesStyle, leaf);
87
- leaf.set(statesStyle, true);
87
+ leaf.set(statesStyle, 'temp');
88
88
  }
89
89
  else {
90
90
  leaf.normalStyle = undefined;
91
91
  }
92
92
  if (transition) {
93
93
  const toStyle = filterStyle(fromStyle, leaf);
94
- leaf.set(fromStyle, true);
94
+ leaf.set(fromStyle, 'temp');
95
95
  leaf.animate([fromStyle, toStyle], transition, 'transition', true);
96
96
  }
97
97
  leaf.__layout.stateStyleChanged = false;
@@ -336,23 +336,40 @@ const gaussNodes = [0.1488743389, 0.4333953941, 0.6794095682, 0.8650633666, 0.97
336
336
  const gaussWeights = [0.2955242247, 0.2692667193, 0.2190863625, 0.1494513491, 0.0666713443];
337
337
  const { sqrt } = Math;
338
338
  const HighBezierHelper = {
339
- getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY) {
340
- let distance = 0, t1, t2, d1X, d1Y, d2X, d2Y;
339
+ getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY, t = 1) {
340
+ let distance = 0, t1, t2, d1X, d1Y, d2X, d2Y, half = t / 2;
341
341
  for (let i = 0; i < gaussNodes.length; i++) {
342
- t1 = 0.5 * (1 + gaussNodes[i]);
343
- t2 = 0.5 * (1 - gaussNodes[i]);
342
+ t1 = half * (1 + gaussNodes[i]);
343
+ t2 = half * (1 - gaussNodes[i]);
344
344
  d1X = getDerivative(t1, fromX, x1, x2, toX);
345
345
  d1Y = getDerivative(t1, fromY, y1, y2, toY);
346
346
  d2X = getDerivative(t2, fromX, x1, x2, toX);
347
347
  d2Y = getDerivative(t2, fromY, y1, y2, toY);
348
348
  distance += gaussWeights[i] * (sqrt(d1X * d1X + d1Y * d1Y) + sqrt(d2X * d2X + d2Y * d2Y));
349
349
  }
350
- return distance * 0.5;
350
+ return distance * half;
351
351
  },
352
352
  getDerivative(t, fromV, v1, v2, toV) {
353
353
  const o = 1 - t;
354
354
  return 3 * o * o * (v1 - fromV) + 6 * o * t * (v2 - v1) + 3 * t * t * (toV - v2);
355
355
  },
356
+ getRotation(t, fromX, fromY, x1, y1, x2, y2, toX, toY) {
357
+ const dx = getDerivative(t, fromX, x1, x2, toX);
358
+ const dy = getDerivative(t, fromY, y1, y2, toY);
359
+ return Math.atan2(dy, dx) / draw.OneRadian;
360
+ },
361
+ getT(distance, totalDistance, fromX, fromY, x1, y1, x2, y2, toX, toY, precision = 1) {
362
+ let low = 0, high = 1, middle = distance / totalDistance, realPrecision = precision / totalDistance / 3;
363
+ if (middle >= 1)
364
+ return 1;
365
+ if (middle <= 0)
366
+ return 0;
367
+ while (high - low > realPrecision) {
368
+ getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY, middle) < distance ? low = middle : high = middle;
369
+ middle = (low + high) / 2;
370
+ }
371
+ return middle;
372
+ },
356
373
  cut(data, t, fromX, fromY, x1, y1, x2, y2, toX, toY) {
357
374
  const o = 1 - t;
358
375
  const ax = o * fromX + t * x1, ay = o * fromY + t * y1;
@@ -364,7 +381,7 @@ const HighBezierHelper = {
364
381
  data.push(draw.PathCommandMap.C, ax, ay, bx, by, cx, cy);
365
382
  }
366
383
  };
367
- const { getDerivative } = HighBezierHelper;
384
+ const { getDerivative, getDistance } = HighBezierHelper;
368
385
 
369
386
  const { M, L, C, Z } = draw.PathCommandMap;
370
387
  const tempPoint = {}, tempFrom = {};
@@ -432,11 +449,12 @@ const HighCurveHelper = {
432
449
  }
433
450
  return { total, segments, data };
434
451
  },
435
- getDistancePoint(distanceData, motionDistance) {
452
+ getDistancePoint(distanceData, motionDistance, motionPrecision) {
436
453
  const { segments, data } = distanceData;
437
454
  motionDistance = draw.UnitConvert.number(motionDistance, distanceData.total);
438
455
  let total = 0, distance, to = {};
439
456
  let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
457
+ let x1, y1, x2, y2, t;
440
458
  const len = data.length;
441
459
  while (i < len) {
442
460
  command = data[i];
@@ -466,11 +484,10 @@ const HighCurveHelper = {
466
484
  toY = data[i + 6];
467
485
  distance = segments[index];
468
486
  if (total + distance > motionDistance) {
469
- const x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
470
- motionDistance -= total;
471
- draw.BezierHelper.getPointAndSet(motionDistance / distance, x, y, x1, y1, x2, y2, toX, toY, to);
472
- draw.BezierHelper.getPointAndSet(Math.max(0, motionDistance - 0.1) / distance, x, y, x1, y1, x2, y2, toX, toY, tempFrom);
473
- to.rotation = draw.PointHelper.getAngle(tempFrom, to);
487
+ x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
488
+ t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
489
+ draw.BezierHelper.getPointAndSet(t, x, y, x1, y1, x2, y2, toX, toY, to);
490
+ to.rotation = HighBezierHelper.getRotation(t, x, y, x1, y1, x2, y2, toX, toY);
474
491
  return to;
475
492
  }
476
493
  x = toX;
@@ -487,11 +504,12 @@ const HighCurveHelper = {
487
504
  }
488
505
  return to;
489
506
  },
490
- getDistancePath(distanceData, motionDistance) {
507
+ getDistancePath(distanceData, motionDistance, motionPrecision) {
491
508
  const { segments, data } = distanceData, path = [];
492
509
  motionDistance = draw.UnitConvert.number(motionDistance, distanceData.total);
493
510
  let total = 0, distance, to = {};
494
511
  let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
512
+ let x1, y1, x2, y2, t;
495
513
  const len = data.length;
496
514
  while (i < len) {
497
515
  command = data[i];
@@ -518,12 +536,13 @@ const HighCurveHelper = {
518
536
  path.push(command, x, y);
519
537
  break;
520
538
  case C:
521
- const x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
539
+ x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
522
540
  toX = data[i + 5];
523
541
  toY = data[i + 6];
524
542
  distance = segments[index];
525
543
  if (total + distance > motionDistance) {
526
- HighBezierHelper.cut(path, (motionDistance - total) / distance, x, y, x1, y1, x2, y2, toX, toY);
544
+ t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
545
+ HighBezierHelper.cut(path, t, x, y, x1, y1, x2, y2, toX, toY);
527
546
  return path;
528
547
  }
529
548
  x = toX;
@@ -572,6 +591,7 @@ const ui = draw.UI.prototype;
572
591
  const { updateMatrix, updateAllMatrix } = draw.LeafHelper;
573
592
  const { updateBounds } = draw.BranchHelper;
574
593
  motionPathType()(ui, 'motionPath');
594
+ motionPathType(1)(ui, 'motionPrecision');
575
595
  motionPathType()(ui, 'motion');
576
596
  motionPathType(true)(ui, 'motionRotation');
577
597
  ui.getMotionPathData = function () {
@@ -582,7 +602,7 @@ ui.getMotionPoint = function (motionDistance) {
582
602
  const data = getMotionPathData(path);
583
603
  if (!data.total)
584
604
  return {};
585
- const point = HighCurveHelper.getDistancePoint(data, motionDistance);
605
+ const point = HighCurveHelper.getDistancePoint(data, motionDistance, path.motionPrecision);
586
606
  draw.MatrixHelper.toOuterPoint(path.localTransform, point);
587
607
  const { motionRotation } = this;
588
608
  if (motionRotation === false)
@@ -622,7 +642,7 @@ function updateMotion(leaf) {
622
642
  if (leaf.motionPath) {
623
643
  const data = getMotionPathData(leaf);
624
644
  if (data.total)
625
- leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion);
645
+ leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion, leaf.motionPrecision);
626
646
  }
627
647
  else {
628
648
  leaf.set(leaf.getMotionPoint(motion));
@@ -1,6 +1,6 @@
1
1
  export * from '@leafer-ui/miniapp';
2
2
  export * from '@leafer-in/robot';
3
- import { decorateLeafAttr, attr, State, PathCommandMap, MatrixHelper, PointHelper, UnitConvert, BezierHelper, isNull as isNull$1, Transition, UI as UI$1, LeafHelper, BranchHelper } from '@leafer-ui/draw';
3
+ import { decorateLeafAttr, attr, State, OneRadian, PathCommandMap, MatrixHelper, PointHelper, UnitConvert, BezierHelper, isNull as isNull$1, Transition, UI as UI$1, LeafHelper, BranchHelper } from '@leafer-ui/draw';
4
4
  import { MathHelper, State as State$1, isNull, PointerEvent, UI, dataType } from '@leafer-ui/core';
5
5
  export * from '@leafer-in/animate';
6
6
  import { LeaferImage, Platform, MatrixHelper as MatrixHelper$1 } from '@leafer/core';
@@ -68,7 +68,7 @@ function updateStyle(leaf, style, type) {
68
68
  const fromStyle = transition ? getFromStyle(leaf, style) : undefined;
69
69
  leaf.killAnimate('transition');
70
70
  if (normalStyle)
71
- leaf.set(normalStyle, true);
71
+ leaf.set(normalStyle, 'temp');
72
72
  const statesStyle = getStyle(leaf);
73
73
  if (statesStyle) {
74
74
  const { animation } = statesStyle;
@@ -82,14 +82,14 @@ function updateStyle(leaf, style, type) {
82
82
  delete statesStyle.animation;
83
83
  }
84
84
  leaf.normalStyle = filterStyle(statesStyle, leaf);
85
- leaf.set(statesStyle, true);
85
+ leaf.set(statesStyle, 'temp');
86
86
  }
87
87
  else {
88
88
  leaf.normalStyle = undefined;
89
89
  }
90
90
  if (transition) {
91
91
  const toStyle = filterStyle(fromStyle, leaf);
92
- leaf.set(fromStyle, true);
92
+ leaf.set(fromStyle, 'temp');
93
93
  leaf.animate([fromStyle, toStyle], transition, 'transition', true);
94
94
  }
95
95
  leaf.__layout.stateStyleChanged = false;
@@ -334,23 +334,40 @@ const gaussNodes = [0.1488743389, 0.4333953941, 0.6794095682, 0.8650633666, 0.97
334
334
  const gaussWeights = [0.2955242247, 0.2692667193, 0.2190863625, 0.1494513491, 0.0666713443];
335
335
  const { sqrt } = Math;
336
336
  const HighBezierHelper = {
337
- getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY) {
338
- let distance = 0, t1, t2, d1X, d1Y, d2X, d2Y;
337
+ getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY, t = 1) {
338
+ let distance = 0, t1, t2, d1X, d1Y, d2X, d2Y, half = t / 2;
339
339
  for (let i = 0; i < gaussNodes.length; i++) {
340
- t1 = 0.5 * (1 + gaussNodes[i]);
341
- t2 = 0.5 * (1 - gaussNodes[i]);
340
+ t1 = half * (1 + gaussNodes[i]);
341
+ t2 = half * (1 - gaussNodes[i]);
342
342
  d1X = getDerivative(t1, fromX, x1, x2, toX);
343
343
  d1Y = getDerivative(t1, fromY, y1, y2, toY);
344
344
  d2X = getDerivative(t2, fromX, x1, x2, toX);
345
345
  d2Y = getDerivative(t2, fromY, y1, y2, toY);
346
346
  distance += gaussWeights[i] * (sqrt(d1X * d1X + d1Y * d1Y) + sqrt(d2X * d2X + d2Y * d2Y));
347
347
  }
348
- return distance * 0.5;
348
+ return distance * half;
349
349
  },
350
350
  getDerivative(t, fromV, v1, v2, toV) {
351
351
  const o = 1 - t;
352
352
  return 3 * o * o * (v1 - fromV) + 6 * o * t * (v2 - v1) + 3 * t * t * (toV - v2);
353
353
  },
354
+ getRotation(t, fromX, fromY, x1, y1, x2, y2, toX, toY) {
355
+ const dx = getDerivative(t, fromX, x1, x2, toX);
356
+ const dy = getDerivative(t, fromY, y1, y2, toY);
357
+ return Math.atan2(dy, dx) / OneRadian;
358
+ },
359
+ getT(distance, totalDistance, fromX, fromY, x1, y1, x2, y2, toX, toY, precision = 1) {
360
+ let low = 0, high = 1, middle = distance / totalDistance, realPrecision = precision / totalDistance / 3;
361
+ if (middle >= 1)
362
+ return 1;
363
+ if (middle <= 0)
364
+ return 0;
365
+ while (high - low > realPrecision) {
366
+ getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY, middle) < distance ? low = middle : high = middle;
367
+ middle = (low + high) / 2;
368
+ }
369
+ return middle;
370
+ },
354
371
  cut(data, t, fromX, fromY, x1, y1, x2, y2, toX, toY) {
355
372
  const o = 1 - t;
356
373
  const ax = o * fromX + t * x1, ay = o * fromY + t * y1;
@@ -362,7 +379,7 @@ const HighBezierHelper = {
362
379
  data.push(PathCommandMap.C, ax, ay, bx, by, cx, cy);
363
380
  }
364
381
  };
365
- const { getDerivative } = HighBezierHelper;
382
+ const { getDerivative, getDistance } = HighBezierHelper;
366
383
 
367
384
  const { M, L, C, Z } = PathCommandMap;
368
385
  const tempPoint = {}, tempFrom = {};
@@ -430,11 +447,12 @@ const HighCurveHelper = {
430
447
  }
431
448
  return { total, segments, data };
432
449
  },
433
- getDistancePoint(distanceData, motionDistance) {
450
+ getDistancePoint(distanceData, motionDistance, motionPrecision) {
434
451
  const { segments, data } = distanceData;
435
452
  motionDistance = UnitConvert.number(motionDistance, distanceData.total);
436
453
  let total = 0, distance, to = {};
437
454
  let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
455
+ let x1, y1, x2, y2, t;
438
456
  const len = data.length;
439
457
  while (i < len) {
440
458
  command = data[i];
@@ -464,11 +482,10 @@ const HighCurveHelper = {
464
482
  toY = data[i + 6];
465
483
  distance = segments[index];
466
484
  if (total + distance > motionDistance) {
467
- const x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
468
- motionDistance -= total;
469
- BezierHelper.getPointAndSet(motionDistance / distance, x, y, x1, y1, x2, y2, toX, toY, to);
470
- BezierHelper.getPointAndSet(Math.max(0, motionDistance - 0.1) / distance, x, y, x1, y1, x2, y2, toX, toY, tempFrom);
471
- to.rotation = PointHelper.getAngle(tempFrom, to);
485
+ x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
486
+ t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
487
+ BezierHelper.getPointAndSet(t, x, y, x1, y1, x2, y2, toX, toY, to);
488
+ to.rotation = HighBezierHelper.getRotation(t, x, y, x1, y1, x2, y2, toX, toY);
472
489
  return to;
473
490
  }
474
491
  x = toX;
@@ -485,11 +502,12 @@ const HighCurveHelper = {
485
502
  }
486
503
  return to;
487
504
  },
488
- getDistancePath(distanceData, motionDistance) {
505
+ getDistancePath(distanceData, motionDistance, motionPrecision) {
489
506
  const { segments, data } = distanceData, path = [];
490
507
  motionDistance = UnitConvert.number(motionDistance, distanceData.total);
491
508
  let total = 0, distance, to = {};
492
509
  let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
510
+ let x1, y1, x2, y2, t;
493
511
  const len = data.length;
494
512
  while (i < len) {
495
513
  command = data[i];
@@ -516,12 +534,13 @@ const HighCurveHelper = {
516
534
  path.push(command, x, y);
517
535
  break;
518
536
  case C:
519
- const x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
537
+ x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
520
538
  toX = data[i + 5];
521
539
  toY = data[i + 6];
522
540
  distance = segments[index];
523
541
  if (total + distance > motionDistance) {
524
- HighBezierHelper.cut(path, (motionDistance - total) / distance, x, y, x1, y1, x2, y2, toX, toY);
542
+ t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
543
+ HighBezierHelper.cut(path, t, x, y, x1, y1, x2, y2, toX, toY);
525
544
  return path;
526
545
  }
527
546
  x = toX;
@@ -570,6 +589,7 @@ const ui = UI$1.prototype;
570
589
  const { updateMatrix, updateAllMatrix } = LeafHelper;
571
590
  const { updateBounds } = BranchHelper;
572
591
  motionPathType()(ui, 'motionPath');
592
+ motionPathType(1)(ui, 'motionPrecision');
573
593
  motionPathType()(ui, 'motion');
574
594
  motionPathType(true)(ui, 'motionRotation');
575
595
  ui.getMotionPathData = function () {
@@ -580,7 +600,7 @@ ui.getMotionPoint = function (motionDistance) {
580
600
  const data = getMotionPathData(path);
581
601
  if (!data.total)
582
602
  return {};
583
- const point = HighCurveHelper.getDistancePoint(data, motionDistance);
603
+ const point = HighCurveHelper.getDistancePoint(data, motionDistance, path.motionPrecision);
584
604
  MatrixHelper.toOuterPoint(path.localTransform, point);
585
605
  const { motionRotation } = this;
586
606
  if (motionRotation === false)
@@ -620,7 +640,7 @@ function updateMotion(leaf) {
620
640
  if (leaf.motionPath) {
621
641
  const data = getMotionPathData(leaf);
622
642
  if (data.total)
623
- leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion);
643
+ leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion, leaf.motionPrecision);
624
644
  }
625
645
  else {
626
646
  leaf.set(leaf.getMotionPoint(motion));
@@ -1 +1 @@
1
- export*from"@leafer-ui/miniapp";export*from"@leafer-in/robot";import{decorateLeafAttr as t,attr as e,State as n,PathCommandMap as o,MatrixHelper as i,PointHelper as s,UnitConvert as a,BezierHelper as r,isNull as c,Transition as l,UI as u,LeafHelper as f,BranchHelper as h}from"@leafer-ui/draw";import{MathHelper as d,State as y,isNull as m,PointerEvent as g,UI as S,dataType as p}from"@leafer-ui/core";export*from"@leafer-in/animate";import{LeaferImage as b,Platform as _,MatrixHelper as P}from"@leafer/core";function v(o,i){return t(o,(t=>e({set(e){this.__setAttr(t,e),this.waitLeafer((()=>i?n.setStyleName(this,i,e):n.set(this,e)))}})))}function x(n){return t(n,(t=>e({set(e){this.__setAttr(t,e),this.__layout.stateStyleChanged=!0}})))}function D(t,e){if(e&&!0!==e)return e;if(!t.button){let{parent:e}=t;for(let t=0;t<2;t++)if(e){if(e.button)return e;e=e.parent}}return null}function M(t,e){"object"!=typeof e&&(e=void 0),A(t,e,"in")}function k(t,e){const{normalStyle:n}=t;"object"!=typeof e&&(e=void 0),n&&(e||(e=n),A(t,e,"out"))}const w={};function A(t,e,n){const{normalStyle:o}=t;e||(e=w),e.scale&&(d.assignScale(e,e.scale),delete e.scale),e!==w&&y.canAnimate||(n=null);let i=!!n&&function(t,e,n){let o="in"===t?"transition":"transitionOut";"out"===t&&m(n[o])&&m(e[o])&&(o="transition");return m(e[o])?n[o]:e[o]}(n,e,t);const s=i?function(t,e){const n=E(e,t),o=t.animate();o&&E(n,t,o.fromStyle);return n}(t,e):void 0;t.killAnimate("transition"),o&&t.set(o,!0);const a=F(t);if(a){const{animation:o}=a;if(o){const s=t.animate(o,void 0,"animation",!0);Object.assign(a,s.endingStyle),"in"!==n||e.animation!==o?s.kill():i=!1,delete a.animation}t.normalStyle=C(a,t),t.set(a,!0)}else t.normalStyle=void 0;if(i){const e=C(s,t);t.set(s,!0),t.animate([s,e],i,"transition",!0)}t.__layout.stateStyleChanged=!1}function F(t){let e;const n={},{state:o}=t,i=D(t),s=o&&t.states[o];s&&y.isState(o,t,i)&&(e=O(n,s));const a=n.selectedStyle||t.selectedStyle;if(a&&y.isSelected(t,i)&&(e=O(n,a)),y.isDisabled(t,i)){const o=n.disabledStyle||t.disabledStyle;o&&(e=O(n,o))}else{const o=n.focusStyle||t.focusStyle;o&&y.isFocus(t,i)&&(e=O(n,o));const s=n.hoverStyle||t.hoverStyle;s&&y.isHover(t,i)&&(e=O(n,s));const a=n.pressStyle||t.pressStyle;a&&y.isPress(t,i)&&(e=O(n,a))}return e?n:void 0}function C(t,e,n,o){const i=n?t:{},s=n||t;for(let t in s)o&&y.animateExcludes[t]||(i[t]=e[t]);return i}function E(t,e,n){return C(t,e,n,!0)}function O(t,e){return Object.assign(t,e),!0}function T(t,e){const n=t[e];n&&M(t,n),t.button&&R(t.children,e)}function j(t,e,n){n||(n=t.states[e]),M(t,n),t.button&&R(t.children,null,e)}function R(t,e,n){if(!t)return;let o,i;for(let s=0,a=t.length;s<a;s++){if(o=t[s],e){switch(i=!0,e){case"hoverStyle":y.isHover(o)&&(i=!1);break;case"pressStyle":y.isPress(o)&&(i=!1);break;case"focusStyle":y.isFocus(o)&&(i=!1)}i&&T(o,e)}else n&&j(o,n);o.isBranch&&R(o.children,e,n)}}function H(t,e){const n=t[e];n&&k(t,n),t.button&&N(t.children,e)}function L(t,e,n){k(t,n),t.button&&N(t.children,null,e)}function N(t,e,n){if(!t)return;let o;for(let i=0,s=t.length;i<s;i++)o=t[i],e?H(o,e):n&&L(o,n),o.isBranch&&N(o.children,e,n)}function B(t,e,n){let o;const i=e.leafer?e.leafer.interaction:null;if(i&&(o=i[t](e),!o&&n)){const s=D(e,n);s&&(o=i[t](s))}return o}function I(t,e,n){let o=e[t];if(!o&&n){const i=D(e,n);i&&(o=i[t])}return o}y.animateExcludes={animation:1,animationOut:1,transition:1,transitionOut:1,states:1,state:1,normalStyle:1,hoverStyle:1,pressStyle:1,focusStyle:1,selectedStyle:1,disabledStyle:1},y.isState=function(t,e,n){return function(t,e,n){let o=e.states[t];if(!o&&n){const i=D(e,n);i&&(o=i.states[t])}return!!o}(t,e,n)},y.isSelected=function(t,e){return I("selected",t,e)},y.isDisabled=function(t,e){return I("disabled",t,e)},y.isFocus=function(t,e){return B("isFocus",t,e)},y.isHover=function(t,e){return B("isHover",t,e)},y.isPress=function(t,e){return B("isPress",t,e)},y.isDrag=function(t,e){return B("isDrag",t,e)},y.setStyleName=function(t,e,n){n?j(t,e,t[e]):L(t,e,t[e])},y.set=function(t,e){const n=t.states[e];n?j(t,e,n):L(t,e,n)},y.getStyle=F,y.updateStyle=A,y.updateEventStyle=function(t,e){switch(e){case g.ENTER:T(t,"hoverStyle");break;case g.LEAVE:H(t,"hoverStyle");break;case g.DOWN:T(t,"pressStyle");break;case g.UP:H(t,"pressStyle")}};const U=S.prototype;v(!1,"selectedStyle")(U,"selected"),v(!1,"disabledStyle")(U,"disabled"),x({})(U,"states"),v("")(U,"state"),p()(U,"normalStyle"),x()(U,"hoverStyle"),x()(U,"pressStyle"),x()(U,"focusStyle"),x()(U,"selectedStyle"),x()(U,"disabledStyle"),p(!1)(U,"button"),U.focus=function(t=!0){this.waitLeafer((()=>{let{focusData:e}=this.app.interaction;t?(e&&e.focus(!1),e=this):e=null,this.app.interaction.focusData=e,t?T(this,"focusStyle"):H(this,"focusStyle")}))},U.updateState=function(){y.updateStyle(this,void 0,"in")};const q=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],z=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:V}=Math,W={getDistance(t,e,n,o,i,s,a,r){let c,l,u,f,h,d,y=0;for(let m=0;m<q.length;m++)c=.5*(1+q[m]),l=.5*(1-q[m]),u=Z(c,t,n,i,a),f=Z(c,e,o,s,r),h=Z(l,t,n,i,a),d=Z(l,e,o,s,r),y+=z[m]*(V(u*u+f*f)+V(h*h+d*d));return.5*y},getDerivative(t,e,n,o,i){const s=1-t;return 3*s*s*(n-e)+6*s*t*(o-n)+3*t*t*(i-o)},cut(t,e,n,i,s,a,r,c,l,u){const f=1-e,h=f*n+e*s,d=f*i+e*a,y=f*s+e*r,m=f*a+e*c,g=f*h+e*y,S=f*d+e*m,p=f*g+e*(f*y+e*(f*r+e*l)),b=f*S+e*(f*m+e*(f*c+e*u));t.push(o.C,h,d,g,S,p,b)}},{getDerivative:Z}=W,{M:G,L:J,C:K,Z:Q}=o,X={},Y={},$={transform(t,e){let n,o=0;const i=t.length;for(;o<i;)switch(n=t[o],n){case G:case J:$.transformPoints(t,e,o,1),o+=3;break;case K:$.transformPoints(t,e,o,3),o+=7;break;case Q:o+=1}},transformPoints(t,e,n,o){for(let s=n+1,a=s+2*o;s<a;s+=2)X.x=t[s],X.y=t[s+1],i.toOuterPoint(e,X),t[s]=X.x,t[s+1]=X.y},getMotionPathData(t){let e,n,o,i,a=0,r=[],c=0,l=0,u=0;const f=t.length;for(;c<f;){switch(i=t[c],i){case G:case J:n=t[c+1],o=t[c+2],e=i===J&&c>0?s.getDistanceFrom(l,u,n,o):0,l=n,u=o,c+=3;break;case K:n=t[c+5],o=t[c+6],e=W.getDistance(l,u,t[c+1],t[c+2],t[c+3],t[c+4],n,o),l=n,u=o,c+=7;break;case Q:c+=1;default:e=0}r.push(e),a+=e}return{total:a,segments:r,data:t}},getDistancePoint(t,e){const{segments:n,data:o}=t;e=a.number(e,t.total);let i,c,l,u,f=0,h={},d=0,y=0,m=0,g=0;const S=o.length;for(;d<S;){switch(u=o[d],u){case G:case J:if(c=o[d+1],l=o[d+2],i=n[y],f+i>e||!t.total)return d||(m=c,g=l),Y.x=m,Y.y=g,h.x=c,h.y=l,s.getDistancePoint(Y,h,e-f,!0),h.rotation=s.getAngle(Y,h),h;m=c,g=l,d+=3;break;case K:if(c=o[d+5],l=o[d+6],i=n[y],f+i>e){const t=o[d+1],n=o[d+2],a=o[d+3],u=o[d+4];return e-=f,r.getPointAndSet(e/i,m,g,t,n,a,u,c,l,h),r.getPointAndSet(Math.max(0,e-.1)/i,m,g,t,n,a,u,c,l,Y),h.rotation=s.getAngle(Y,h),h}m=c,g=l,d+=7;break;case Q:d+=1;default:i=0}y++,f+=i}return h},getDistancePath(t,e){const{segments:n,data:o}=t,i=[];e=a.number(e,t.total);let r,c,l,u,f=0,h={},d=0,y=0,m=0,g=0;const S=o.length;for(;d<S;){switch(u=o[d],u){case G:case J:if(c=o[d+1],l=o[d+2],r=n[y],f+r>e||!t.total)return d||(m=c,g=l),Y.x=m,Y.y=g,h.x=c,h.y=l,s.getDistancePoint(Y,h,e-f,!0),i.push(u,h.x,h.y),i;m=c,g=l,d+=3,i.push(u,m,g);break;case K:const a=o[d+1],S=o[d+2],p=o[d+3],b=o[d+4];if(c=o[d+5],l=o[d+6],r=n[y],f+r>e)return W.cut(i,(e-f)/r,m,g,a,S,p,b,c,l),i;m=c,g=l,d+=7,i.push(u,a,S,p,b,c,l);break;case Q:d+=1,i.push(u);default:r=0}y++,f+=r}return i}};function tt(n){return t(n,(t=>e({set(e){this.__setAttr(t,e),this.__hasMotionPath=this.motionPath||!c(this.motion),this.__layout.matrixChanged||this.__layout.matrixChange()}})))}l.register("motion",(function(t,e,n,o){return t?"object"==typeof t&&(t=a.number(t,o.getMotionTotal())):t=0,e?"object"==typeof e&&(e=a.number(e,o.getMotionTotal())):e=0,l.number(t,e,n)})),l.register("motionRotation",(function(t,e,n){return l.number(t,e,n)}));const et=u.prototype,{updateMatrix:nt,updateAllMatrix:ot}=f,{updateBounds:it}=h;function st(t){const{motion:e,leaferIsCreated:n}=t;if(!c(e)){if(n&&(t.leafer.created=!1),t.motionPath){const n=rt(t);n.total&&(t.__.__pathForRender=$.getDistancePath(n,e))}else t.set(t.getMotionPoint(e)),t.__hasAutoLayout||(t.isBranch?(ot(t),it(t,t)):nt(t));n&&(t.leafer.created=!0)}}function at(t){const{parent:e}=t;if(!t.motionPath&&e){const{children:t}=e;for(let e=0;e<t.length;e++)if(t[e].motionPath)return t[e]}return t}function rt(t){const e=t.__;return e.__pathForMotion?e.__pathForMotion:e.__pathForMotion=$.getMotionPathData(t.getPath(!0,!0))}tt()(et,"motionPath"),tt()(et,"motion"),tt(!0)(et,"motionRotation"),et.getMotionPathData=function(){return rt(at(this))},et.getMotionPoint=function(t){const e=at(this),n=rt(e);if(!n.total)return{};const o=$.getDistancePoint(n,t);i.toOuterPoint(e.localTransform,o);const{motionRotation:s}=this;return!1===s?delete o.rotation:"number"==typeof s&&(o.rotation+=s),o},et.getMotionTotal=function(){return this.getMotionPathData().total},et.__updateMotionPath=function(){const t=this.__;if(this.__layout.resized&&t.__pathForMotion&&(t.__pathForMotion=void 0),this.motionPath){let t;const{children:e}=this.parent,{leaferIsReady:n}=this;for(let o=0;o<e.length;o++)t=e[o],c(t.motion)||t.__layout.matrixChanged||(n&&t!==this&&this.leafer.layouter.addExtra(t),st(t))}else st(this)};"ios"===wx.getSystemInfoSync().platform&&(b.prototype.getPattern=function(t,e,n,o){const i=_.canvas.createPattern(this.view,e),{width:s,height:a}=t;this.width===s&&this.height===a||(n||(n=P.get()),P.scale(n,s/this.width,a/this.height));try{n&&i.setTransform&&(i.setTransform(n),n=null)}catch(t){}return o&&(o.transform=n),i});export{W as HighBezierHelper,$ as HighCurveHelper,tt as motionPathType,x as stateStyleType,v as stateType};
1
+ export*from"@leafer-ui/miniapp";export*from"@leafer-in/robot";import{decorateLeafAttr as t,attr as e,State as n,OneRadian as o,PathCommandMap as i,MatrixHelper as s,PointHelper as r,UnitConvert as a,BezierHelper as c,isNull as l,Transition as u,UI as f,LeafHelper as h,BranchHelper as d}from"@leafer-ui/draw";import{MathHelper as m,State as y,isNull as g,PointerEvent as p,UI as S,dataType as b}from"@leafer-ui/core";export*from"@leafer-in/animate";import{LeaferImage as _,Platform as P,MatrixHelper as v}from"@leafer/core";function D(o,i){return t(o,(t=>e({set(e){this.__setAttr(t,e),this.waitLeafer((()=>i?n.setStyleName(this,i,e):n.set(this,e)))}})))}function M(n){return t(n,(t=>e({set(e){this.__setAttr(t,e),this.__layout.stateStyleChanged=!0}})))}function x(t,e){if(e&&!0!==e)return e;if(!t.button){let{parent:e}=t;for(let t=0;t<2;t++)if(e){if(e.button)return e;e=e.parent}}return null}function k(t,e){"object"!=typeof e&&(e=void 0),A(t,e,"in")}function w(t,e){const{normalStyle:n}=t;"object"!=typeof e&&(e=void 0),n&&(e||(e=n),A(t,e,"out"))}const F={};function A(t,e,n){const{normalStyle:o}=t;e||(e=F),e.scale&&(m.assignScale(e,e.scale),delete e.scale),e!==F&&y.canAnimate||(n=null);let i=!!n&&function(t,e,n){let o="in"===t?"transition":"transitionOut";"out"===t&&g(n[o])&&g(e[o])&&(o="transition");return g(e[o])?n[o]:e[o]}(n,e,t);const s=i?function(t,e){const n=E(e,t),o=t.animate();o&&E(n,t,o.fromStyle);return n}(t,e):void 0;t.killAnimate("transition"),o&&t.set(o,"temp");const r=T(t);if(r){const{animation:o}=r;if(o){const s=t.animate(o,void 0,"animation",!0);Object.assign(r,s.endingStyle),"in"!==n||e.animation!==o?s.kill():i=!1,delete r.animation}t.normalStyle=C(r,t),t.set(r,"temp")}else t.normalStyle=void 0;if(i){const e=C(s,t);t.set(s,"temp"),t.animate([s,e],i,"transition",!0)}t.__layout.stateStyleChanged=!1}function T(t){let e;const n={},{state:o}=t,i=x(t),s=o&&t.states[o];s&&y.isState(o,t,i)&&(e=O(n,s));const r=n.selectedStyle||t.selectedStyle;if(r&&y.isSelected(t,i)&&(e=O(n,r)),y.isDisabled(t,i)){const o=n.disabledStyle||t.disabledStyle;o&&(e=O(n,o))}else{const o=n.focusStyle||t.focusStyle;o&&y.isFocus(t,i)&&(e=O(n,o));const s=n.hoverStyle||t.hoverStyle;s&&y.isHover(t,i)&&(e=O(n,s));const r=n.pressStyle||t.pressStyle;r&&y.isPress(t,i)&&(e=O(n,r))}return e?n:void 0}function C(t,e,n,o){const i=n?t:{},s=n||t;for(let t in s)o&&y.animateExcludes[t]||(i[t]=e[t]);return i}function E(t,e,n){return C(t,e,n,!0)}function O(t,e){return Object.assign(t,e),!0}function R(t,e){const n=t[e];n&&k(t,n),t.button&&H(t.children,e)}function j(t,e,n){n||(n=t.states[e]),k(t,n),t.button&&H(t.children,null,e)}function H(t,e,n){if(!t)return;let o,i;for(let s=0,r=t.length;s<r;s++){if(o=t[s],e){switch(i=!0,e){case"hoverStyle":y.isHover(o)&&(i=!1);break;case"pressStyle":y.isPress(o)&&(i=!1);break;case"focusStyle":y.isFocus(o)&&(i=!1)}i&&R(o,e)}else n&&j(o,n);o.isBranch&&H(o.children,e,n)}}function L(t,e){const n=t[e];n&&w(t,n),t.button&&B(t.children,e)}function N(t,e,n){w(t,n),t.button&&B(t.children,null,e)}function B(t,e,n){if(!t)return;let o;for(let i=0,s=t.length;i<s;i++)o=t[i],e?L(o,e):n&&N(o,n),o.isBranch&&B(o.children,e,n)}function I(t,e,n){let o;const i=e.leafer?e.leafer.interaction:null;if(i&&(o=i[t](e),!o&&n)){const s=x(e,n);s&&(o=i[t](s))}return o}function U(t,e,n){let o=e[t];if(!o&&n){const i=x(e,n);i&&(o=i[t])}return o}y.animateExcludes={animation:1,animationOut:1,transition:1,transitionOut:1,states:1,state:1,normalStyle:1,hoverStyle:1,pressStyle:1,focusStyle:1,selectedStyle:1,disabledStyle:1},y.isState=function(t,e,n){return function(t,e,n){let o=e.states[t];if(!o&&n){const i=x(e,n);i&&(o=i.states[t])}return!!o}(t,e,n)},y.isSelected=function(t,e){return U("selected",t,e)},y.isDisabled=function(t,e){return U("disabled",t,e)},y.isFocus=function(t,e){return I("isFocus",t,e)},y.isHover=function(t,e){return I("isHover",t,e)},y.isPress=function(t,e){return I("isPress",t,e)},y.isDrag=function(t,e){return I("isDrag",t,e)},y.setStyleName=function(t,e,n){n?j(t,e,t[e]):N(t,e,t[e])},y.set=function(t,e){const n=t.states[e];n?j(t,e,n):N(t,e,n)},y.getStyle=T,y.updateStyle=A,y.updateEventStyle=function(t,e){switch(e){case p.ENTER:R(t,"hoverStyle");break;case p.LEAVE:L(t,"hoverStyle");break;case p.DOWN:R(t,"pressStyle");break;case p.UP:L(t,"pressStyle")}};const q=S.prototype;D(!1,"selectedStyle")(q,"selected"),D(!1,"disabledStyle")(q,"disabled"),M({})(q,"states"),D("")(q,"state"),b()(q,"normalStyle"),M()(q,"hoverStyle"),M()(q,"pressStyle"),M()(q,"focusStyle"),M()(q,"selectedStyle"),M()(q,"disabledStyle"),b(!1)(q,"button"),q.focus=function(t=!0){this.waitLeafer((()=>{let{focusData:e}=this.app.interaction;t?(e&&e.focus(!1),e=this):e=null,this.app.interaction.focusData=e,t?R(this,"focusStyle"):L(this,"focusStyle")}))},q.updateState=function(){y.updateStyle(this,void 0,"in")};const z=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],V=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:W}=Math,Z={getDistance(t,e,n,o,i,s,r,a,c=1){let l,u,f,h,d,m,y=0,g=c/2;for(let c=0;c<z.length;c++)l=g*(1+z[c]),u=g*(1-z[c]),f=G(l,t,n,i,r),h=G(l,e,o,s,a),d=G(u,t,n,i,r),m=G(u,e,o,s,a),y+=V[c]*(W(f*f+h*h)+W(d*d+m*m));return y*g},getDerivative(t,e,n,o,i){const s=1-t;return 3*s*s*(n-e)+6*s*t*(o-n)+3*t*t*(i-o)},getRotation(t,e,n,i,s,r,a,c,l){const u=G(t,e,i,r,c),f=G(t,n,s,a,l);return Math.atan2(f,u)/o},getT(t,e,n,o,i,s,r,a,c,l,u=1){let f=0,h=1,d=t/e,m=u/e/3;if(d>=1)return 1;if(d<=0)return 0;for(;h-f>m;)J(n,o,i,s,r,a,c,l,d)<t?f=d:h=d,d=(f+h)/2;return d},cut(t,e,n,o,s,r,a,c,l,u){const f=1-e,h=f*n+e*s,d=f*o+e*r,m=f*s+e*a,y=f*r+e*c,g=f*h+e*m,p=f*d+e*y,S=f*g+e*(f*m+e*(f*a+e*l)),b=f*p+e*(f*y+e*(f*c+e*u));t.push(i.C,h,d,g,p,S,b)}},{getDerivative:G,getDistance:J}=Z,{M:K,L:Q,C:X,Z:Y}=i,$={},tt={},et={transform(t,e){let n,o=0;const i=t.length;for(;o<i;)switch(n=t[o],n){case K:case Q:et.transformPoints(t,e,o,1),o+=3;break;case X:et.transformPoints(t,e,o,3),o+=7;break;case Y:o+=1}},transformPoints(t,e,n,o){for(let i=n+1,r=i+2*o;i<r;i+=2)$.x=t[i],$.y=t[i+1],s.toOuterPoint(e,$),t[i]=$.x,t[i+1]=$.y},getMotionPathData(t){let e,n,o,i,s=0,a=[],c=0,l=0,u=0;const f=t.length;for(;c<f;){switch(i=t[c],i){case K:case Q:n=t[c+1],o=t[c+2],e=i===Q&&c>0?r.getDistanceFrom(l,u,n,o):0,l=n,u=o,c+=3;break;case X:n=t[c+5],o=t[c+6],e=Z.getDistance(l,u,t[c+1],t[c+2],t[c+3],t[c+4],n,o),l=n,u=o,c+=7;break;case Y:c+=1;default:e=0}a.push(e),s+=e}return{total:s,segments:a,data:t}},getDistancePoint(t,e,n){const{segments:o,data:i}=t;e=a.number(e,t.total);let s,l,u,f,h,d,m,y,g,p=0,S={},b=0,_=0,P=0,v=0;const D=i.length;for(;b<D;){switch(f=i[b],f){case K:case Q:if(l=i[b+1],u=i[b+2],s=o[_],p+s>e||!t.total)return b||(P=l,v=u),tt.x=P,tt.y=v,S.x=l,S.y=u,r.getDistancePoint(tt,S,e-p,!0),S.rotation=r.getAngle(tt,S),S;P=l,v=u,b+=3;break;case X:if(l=i[b+5],u=i[b+6],s=o[_],p+s>e)return h=i[b+1],d=i[b+2],m=i[b+3],y=i[b+4],g=Z.getT(e-p,s,P,v,h,d,m,y,l,u,n),c.getPointAndSet(g,P,v,h,d,m,y,l,u,S),S.rotation=Z.getRotation(g,P,v,h,d,m,y,l,u),S;P=l,v=u,b+=7;break;case Y:b+=1;default:s=0}_++,p+=s}return S},getDistancePath(t,e,n){const{segments:o,data:i}=t,s=[];e=a.number(e,t.total);let c,l,u,f,h,d,m,y,g,p=0,S={},b=0,_=0,P=0,v=0;const D=i.length;for(;b<D;){switch(f=i[b],f){case K:case Q:if(l=i[b+1],u=i[b+2],c=o[_],p+c>e||!t.total)return b||(P=l,v=u),tt.x=P,tt.y=v,S.x=l,S.y=u,r.getDistancePoint(tt,S,e-p,!0),s.push(f,S.x,S.y),s;P=l,v=u,b+=3,s.push(f,P,v);break;case X:if(h=i[b+1],d=i[b+2],m=i[b+3],y=i[b+4],l=i[b+5],u=i[b+6],c=o[_],p+c>e)return g=Z.getT(e-p,c,P,v,h,d,m,y,l,u,n),Z.cut(s,g,P,v,h,d,m,y,l,u),s;P=l,v=u,b+=7,s.push(f,h,d,m,y,l,u);break;case Y:b+=1,s.push(f);default:c=0}_++,p+=c}return s}};function nt(n){return t(n,(t=>e({set(e){this.__setAttr(t,e),this.__hasMotionPath=this.motionPath||!l(this.motion),this.__layout.matrixChanged||this.__layout.matrixChange()}})))}u.register("motion",(function(t,e,n,o){return t?"object"==typeof t&&(t=a.number(t,o.getMotionTotal())):t=0,e?"object"==typeof e&&(e=a.number(e,o.getMotionTotal())):e=0,u.number(t,e,n)})),u.register("motionRotation",(function(t,e,n){return u.number(t,e,n)}));const ot=f.prototype,{updateMatrix:it,updateAllMatrix:st}=h,{updateBounds:rt}=d;function at(t){const{motion:e,leaferIsCreated:n}=t;if(!l(e)){if(n&&(t.leafer.created=!1),t.motionPath){const n=lt(t);n.total&&(t.__.__pathForRender=et.getDistancePath(n,e,t.motionPrecision))}else t.set(t.getMotionPoint(e)),t.__hasAutoLayout||(t.isBranch?(st(t),rt(t,t)):it(t));n&&(t.leafer.created=!0)}}function ct(t){const{parent:e}=t;if(!t.motionPath&&e){const{children:t}=e;for(let e=0;e<t.length;e++)if(t[e].motionPath)return t[e]}return t}function lt(t){const e=t.__;return e.__pathForMotion?e.__pathForMotion:e.__pathForMotion=et.getMotionPathData(t.getPath(!0,!0))}nt()(ot,"motionPath"),nt(1)(ot,"motionPrecision"),nt()(ot,"motion"),nt(!0)(ot,"motionRotation"),ot.getMotionPathData=function(){return lt(ct(this))},ot.getMotionPoint=function(t){const e=ct(this),n=lt(e);if(!n.total)return{};const o=et.getDistancePoint(n,t,e.motionPrecision);s.toOuterPoint(e.localTransform,o);const{motionRotation:i}=this;return!1===i?delete o.rotation:"number"==typeof i&&(o.rotation+=i),o},ot.getMotionTotal=function(){return this.getMotionPathData().total},ot.__updateMotionPath=function(){const t=this.__;if(this.__layout.resized&&t.__pathForMotion&&(t.__pathForMotion=void 0),this.motionPath){let t;const{children:e}=this.parent,{leaferIsReady:n}=this;for(let o=0;o<e.length;o++)t=e[o],l(t.motion)||t.__layout.matrixChanged||(n&&t!==this&&this.leafer.layouter.addExtra(t),at(t))}else at(this)};"ios"===wx.getSystemInfoSync().platform&&(_.prototype.getPattern=function(t,e,n,o){const i=P.canvas.createPattern(this.view,e),{width:s,height:r}=t;this.width===s&&this.height===r||(n||(n=v.get()),v.scale(n,s/this.width,r/this.height));try{n&&i.setTransform&&(i.setTransform(n),n=null)}catch(t){}return o&&(o.transform=n),i});export{Z as HighBezierHelper,et as HighCurveHelper,nt as motionPathType,M as stateStyleType,D as stateType};
@@ -1 +1 @@
1
- "use strict";var t=require("@leafer-ui/miniapp"),e=require("@leafer-in/robot"),n=require("@leafer-ui/draw"),o=require("@leafer-ui/core"),r=require("@leafer-in/animate"),i=require("@leafer/core");function a(t,e){return n.decorateLeafAttr(t,(t=>n.attr({set(o){this.__setAttr(t,o),this.waitLeafer((()=>e?n.State.setStyleName(this,e,o):n.State.set(this,o)))}})))}function s(t){return n.decorateLeafAttr(t,(t=>n.attr({set(e){this.__setAttr(t,e),this.__layout.stateStyleChanged=!0}})))}function l(t,e){if(e&&!0!==e)return e;if(!t.button){let{parent:e}=t;for(let t=0;t<2;t++)if(e){if(e.button)return e;e=e.parent}}return null}function c(t,e){"object"!=typeof e&&(e=void 0),h(t,e,"in")}function u(t,e){const{normalStyle:n}=t;"object"!=typeof e&&(e=void 0),n&&(e||(e=n),h(t,e,"out"))}const f={};function h(t,e,n){const{normalStyle:r}=t;e||(e=f),e.scale&&(o.MathHelper.assignScale(e,e.scale),delete e.scale),e!==f&&o.State.canAnimate||(n=null);let i=!!n&&function(t,e,n){let r="in"===t?"transition":"transitionOut";"out"===t&&o.isNull(n[r])&&o.isNull(e[r])&&(r="transition");return o.isNull(e[r])?n[r]:e[r]}(n,e,t);const a=i?function(t,e){const n=y(e,t),o=t.animate();o&&y(n,t,o.fromStyle);return n}(t,e):void 0;t.killAnimate("transition"),r&&t.set(r,!0);const s=p(t);if(s){const{animation:o}=s;if(o){const r=t.animate(o,void 0,"animation",!0);Object.assign(s,r.endingStyle),"in"!==n||e.animation!==o?r.kill():i=!1,delete s.animation}t.normalStyle=d(s,t),t.set(s,!0)}else t.normalStyle=void 0;if(i){const e=d(a,t);t.set(a,!0),t.animate([a,e],i,"transition",!0)}t.__layout.stateStyleChanged=!1}function p(t){let e;const n={},{state:r}=t,i=l(t),a=r&&t.states[r];a&&o.State.isState(r,t,i)&&(e=S(n,a));const s=n.selectedStyle||t.selectedStyle;if(s&&o.State.isSelected(t,i)&&(e=S(n,s)),o.State.isDisabled(t,i)){const o=n.disabledStyle||t.disabledStyle;o&&(e=S(n,o))}else{const r=n.focusStyle||t.focusStyle;r&&o.State.isFocus(t,i)&&(e=S(n,r));const a=n.hoverStyle||t.hoverStyle;a&&o.State.isHover(t,i)&&(e=S(n,a));const s=n.pressStyle||t.pressStyle;s&&o.State.isPress(t,i)&&(e=S(n,s))}return e?n:void 0}function d(t,e,n,r){const i=n?t:{},a=n||t;for(let t in a)r&&o.State.animateExcludes[t]||(i[t]=e[t]);return i}function y(t,e,n){return d(t,e,n,!0)}function S(t,e){return Object.assign(t,e),!0}function m(t,e){const n=t[e];n&&c(t,n),t.button&&b(t.children,e)}function g(t,e,n){n||(n=t.states[e]),c(t,n),t.button&&b(t.children,null,e)}function b(t,e,n){if(!t)return;let r,i;for(let a=0,s=t.length;a<s;a++){if(r=t[a],e){switch(i=!0,e){case"hoverStyle":o.State.isHover(r)&&(i=!1);break;case"pressStyle":o.State.isPress(r)&&(i=!1);break;case"focusStyle":o.State.isFocus(r)&&(i=!1)}i&&m(r,e)}else n&&g(r,n);r.isBranch&&b(r.children,e,n)}}function P(t,e){const n=t[e];n&&u(t,n),t.button&&v(t.children,e)}function _(t,e,n){u(t,n),t.button&&v(t.children,null,e)}function v(t,e,n){if(!t)return;let o;for(let r=0,i=t.length;r<i;r++)o=t[r],e?P(o,e):n&&_(o,n),o.isBranch&&v(o.children,e,n)}function x(t,e,n){let o;const r=e.leafer?e.leafer.interaction:null;if(r&&(o=r[t](e),!o&&n)){const i=l(e,n);i&&(o=r[t](i))}return o}function M(t,e,n){let o=e[t];if(!o&&n){const r=l(e,n);r&&(o=r[t])}return o}o.State.animateExcludes={animation:1,animationOut:1,transition:1,transitionOut:1,states:1,state:1,normalStyle:1,hoverStyle:1,pressStyle:1,focusStyle:1,selectedStyle:1,disabledStyle:1},o.State.isState=function(t,e,n){return function(t,e,n){let o=e.states[t];if(!o&&n){const r=l(e,n);r&&(o=r.states[t])}return!!o}(t,e,n)},o.State.isSelected=function(t,e){return M("selected",t,e)},o.State.isDisabled=function(t,e){return M("disabled",t,e)},o.State.isFocus=function(t,e){return x("isFocus",t,e)},o.State.isHover=function(t,e){return x("isHover",t,e)},o.State.isPress=function(t,e){return x("isPress",t,e)},o.State.isDrag=function(t,e){return x("isDrag",t,e)},o.State.setStyleName=function(t,e,n){n?g(t,e,t[e]):_(t,e,t[e])},o.State.set=function(t,e){const n=t.states[e];n?g(t,e,n):_(t,e,n)},o.State.getStyle=p,o.State.updateStyle=h,o.State.updateEventStyle=function(t,e){switch(e){case o.PointerEvent.ENTER:m(t,"hoverStyle");break;case o.PointerEvent.LEAVE:P(t,"hoverStyle");break;case o.PointerEvent.DOWN:m(t,"pressStyle");break;case o.PointerEvent.UP:P(t,"pressStyle")}};const D=o.UI.prototype;a(!1,"selectedStyle")(D,"selected"),a(!1,"disabledStyle")(D,"disabled"),s({})(D,"states"),a("")(D,"state"),o.dataType()(D,"normalStyle"),s()(D,"hoverStyle"),s()(D,"pressStyle"),s()(D,"focusStyle"),s()(D,"selectedStyle"),s()(D,"disabledStyle"),o.dataType(!1)(D,"button"),D.focus=function(t=!0){this.waitLeafer((()=>{let{focusData:e}=this.app.interaction;t?(e&&e.focus(!1),e=this):e=null,this.app.interaction.focusData=e,t?m(this,"focusStyle"):P(this,"focusStyle")}))},D.updateState=function(){o.State.updateStyle(this,void 0,"in")};const H=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],O=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:k}=Math,w={getDistance(t,e,n,o,r,i,a,s){let l,c,u,f,h,p,d=0;for(let y=0;y<H.length;y++)l=.5*(1+H[y]),c=.5*(1-H[y]),u=T(l,t,n,r,a),f=T(l,e,o,i,s),h=T(c,t,n,r,a),p=T(c,e,o,i,s),d+=O[y]*(k(u*u+f*f)+k(h*h+p*p));return.5*d},getDerivative(t,e,n,o,r){const i=1-t;return 3*i*i*(n-e)+6*i*t*(o-n)+3*t*t*(r-o)},cut(t,e,o,r,i,a,s,l,c,u){const f=1-e,h=f*o+e*i,p=f*r+e*a,d=f*i+e*s,y=f*a+e*l,S=f*h+e*d,m=f*p+e*y,g=f*S+e*(f*d+e*(f*s+e*c)),b=f*m+e*(f*y+e*(f*l+e*u));t.push(n.PathCommandMap.C,h,p,S,m,g,b)}},{getDerivative:T}=w,{M:j,L:A,C:C,Z:E}=n.PathCommandMap,F={},L={},N={transform(t,e){let n,o=0;const r=t.length;for(;o<r;)switch(n=t[o],n){case j:case A:N.transformPoints(t,e,o,1),o+=3;break;case C:N.transformPoints(t,e,o,3),o+=7;break;case E:o+=1}},transformPoints(t,e,o,r){for(let i=o+1,a=i+2*r;i<a;i+=2)F.x=t[i],F.y=t[i+1],n.MatrixHelper.toOuterPoint(e,F),t[i]=F.x,t[i+1]=F.y},getMotionPathData(t){let e,o,r,i,a=0,s=[],l=0,c=0,u=0;const f=t.length;for(;l<f;){switch(i=t[l],i){case j:case A:o=t[l+1],r=t[l+2],e=i===A&&l>0?n.PointHelper.getDistanceFrom(c,u,o,r):0,c=o,u=r,l+=3;break;case C:o=t[l+5],r=t[l+6],e=w.getDistance(c,u,t[l+1],t[l+2],t[l+3],t[l+4],o,r),c=o,u=r,l+=7;break;case E:l+=1;default:e=0}s.push(e),a+=e}return{total:a,segments:s,data:t}},getDistancePoint(t,e){const{segments:o,data:r}=t;e=n.UnitConvert.number(e,t.total);let i,a,s,l,c=0,u={},f=0,h=0,p=0,d=0;const y=r.length;for(;f<y;){switch(l=r[f],l){case j:case A:if(a=r[f+1],s=r[f+2],i=o[h],c+i>e||!t.total)return f||(p=a,d=s),L.x=p,L.y=d,u.x=a,u.y=s,n.PointHelper.getDistancePoint(L,u,e-c,!0),u.rotation=n.PointHelper.getAngle(L,u),u;p=a,d=s,f+=3;break;case C:if(a=r[f+5],s=r[f+6],i=o[h],c+i>e){const t=r[f+1],o=r[f+2],l=r[f+3],h=r[f+4];return e-=c,n.BezierHelper.getPointAndSet(e/i,p,d,t,o,l,h,a,s,u),n.BezierHelper.getPointAndSet(Math.max(0,e-.1)/i,p,d,t,o,l,h,a,s,L),u.rotation=n.PointHelper.getAngle(L,u),u}p=a,d=s,f+=7;break;case E:f+=1;default:i=0}h++,c+=i}return u},getDistancePath(t,e){const{segments:o,data:r}=t,i=[];e=n.UnitConvert.number(e,t.total);let a,s,l,c,u=0,f={},h=0,p=0,d=0,y=0;const S=r.length;for(;h<S;){switch(c=r[h],c){case j:case A:if(s=r[h+1],l=r[h+2],a=o[p],u+a>e||!t.total)return h||(d=s,y=l),L.x=d,L.y=y,f.x=s,f.y=l,n.PointHelper.getDistancePoint(L,f,e-u,!0),i.push(c,f.x,f.y),i;d=s,y=l,h+=3,i.push(c,d,y);break;case C:const S=r[h+1],m=r[h+2],g=r[h+3],b=r[h+4];if(s=r[h+5],l=r[h+6],a=o[p],u+a>e)return w.cut(i,(e-u)/a,d,y,S,m,g,b,s,l),i;d=s,y=l,h+=7,i.push(c,S,m,g,b,s,l);break;case E:h+=1,i.push(c);default:a=0}p++,u+=a}return i}};function B(t){return n.decorateLeafAttr(t,(t=>n.attr({set(e){this.__setAttr(t,e),this.__hasMotionPath=this.motionPath||!n.isNull(this.motion),this.__layout.matrixChanged||this.__layout.matrixChange()}})))}n.Transition.register("motion",(function(t,e,o,r){return t?"object"==typeof t&&(t=n.UnitConvert.number(t,r.getMotionTotal())):t=0,e?"object"==typeof e&&(e=n.UnitConvert.number(e,r.getMotionTotal())):e=0,n.Transition.number(t,e,o)})),n.Transition.register("motionRotation",(function(t,e,o){return n.Transition.number(t,e,o)}));const q=n.UI.prototype,{updateMatrix:U,updateAllMatrix:I}=n.LeafHelper,{updateBounds:R}=n.BranchHelper;function z(t){const{motion:e,leaferIsCreated:o}=t;if(!n.isNull(e)){if(o&&(t.leafer.created=!1),t.motionPath){const n=W(t);n.total&&(t.__.__pathForRender=N.getDistancePath(n,e))}else t.set(t.getMotionPoint(e)),t.__hasAutoLayout||(t.isBranch?(I(t),R(t,t)):U(t));o&&(t.leafer.created=!0)}}function V(t){const{parent:e}=t;if(!t.motionPath&&e){const{children:t}=e;for(let e=0;e<t.length;e++)if(t[e].motionPath)return t[e]}return t}function W(t){const e=t.__;return e.__pathForMotion?e.__pathForMotion:e.__pathForMotion=N.getMotionPathData(t.getPath(!0,!0))}B()(q,"motionPath"),B()(q,"motion"),B(!0)(q,"motionRotation"),q.getMotionPathData=function(){return W(V(this))},q.getMotionPoint=function(t){const e=V(this),o=W(e);if(!o.total)return{};const r=N.getDistancePoint(o,t);n.MatrixHelper.toOuterPoint(e.localTransform,r);const{motionRotation:i}=this;return!1===i?delete r.rotation:"number"==typeof i&&(r.rotation+=i),r},q.getMotionTotal=function(){return this.getMotionPathData().total},q.__updateMotionPath=function(){const t=this.__;if(this.__layout.resized&&t.__pathForMotion&&(t.__pathForMotion=void 0),this.motionPath){let t;const{children:e}=this.parent,{leaferIsReady:o}=this;for(let r=0;r<e.length;r++)t=e[r],n.isNull(t.motion)||t.__layout.matrixChanged||(o&&t!==this&&this.leafer.layouter.addExtra(t),z(t))}else z(this)};"ios"===wx.getSystemInfoSync().platform&&(i.LeaferImage.prototype.getPattern=function(t,e,n,o){const r=i.Platform.canvas.createPattern(this.view,e),{width:a,height:s}=t;this.width===a&&this.height===s||(n||(n=i.MatrixHelper.get()),i.MatrixHelper.scale(n,a/this.width,s/this.height));try{n&&r.setTransform&&(r.setTransform(n),n=null)}catch(t){}return o&&(o.transform=n),r}),exports.HighBezierHelper=w,exports.HighCurveHelper=N,exports.motionPathType=B,exports.stateStyleType=s,exports.stateType=a,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})})),Object.keys(r).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return r[t]}})}));
1
+ "use strict";var t=require("@leafer-ui/miniapp"),e=require("@leafer-in/robot"),n=require("@leafer-ui/draw"),o=require("@leafer-ui/core"),i=require("@leafer-in/animate"),r=require("@leafer/core");function a(t,e){return n.decorateLeafAttr(t,(t=>n.attr({set(o){this.__setAttr(t,o),this.waitLeafer((()=>e?n.State.setStyleName(this,e,o):n.State.set(this,o)))}})))}function s(t){return n.decorateLeafAttr(t,(t=>n.attr({set(e){this.__setAttr(t,e),this.__layout.stateStyleChanged=!0}})))}function l(t,e){if(e&&!0!==e)return e;if(!t.button){let{parent:e}=t;for(let t=0;t<2;t++)if(e){if(e.button)return e;e=e.parent}}return null}function c(t,e){"object"!=typeof e&&(e=void 0),h(t,e,"in")}function u(t,e){const{normalStyle:n}=t;"object"!=typeof e&&(e=void 0),n&&(e||(e=n),h(t,e,"out"))}const f={};function h(t,e,n){const{normalStyle:i}=t;e||(e=f),e.scale&&(o.MathHelper.assignScale(e,e.scale),delete e.scale),e!==f&&o.State.canAnimate||(n=null);let r=!!n&&function(t,e,n){let i="in"===t?"transition":"transitionOut";"out"===t&&o.isNull(n[i])&&o.isNull(e[i])&&(i="transition");return o.isNull(e[i])?n[i]:e[i]}(n,e,t);const a=r?function(t,e){const n=y(e,t),o=t.animate();o&&y(n,t,o.fromStyle);return n}(t,e):void 0;t.killAnimate("transition"),i&&t.set(i,"temp");const s=p(t);if(s){const{animation:o}=s;if(o){const i=t.animate(o,void 0,"animation",!0);Object.assign(s,i.endingStyle),"in"!==n||e.animation!==o?i.kill():r=!1,delete s.animation}t.normalStyle=d(s,t),t.set(s,"temp")}else t.normalStyle=void 0;if(r){const e=d(a,t);t.set(a,"temp"),t.animate([a,e],r,"transition",!0)}t.__layout.stateStyleChanged=!1}function p(t){let e;const n={},{state:i}=t,r=l(t),a=i&&t.states[i];a&&o.State.isState(i,t,r)&&(e=S(n,a));const s=n.selectedStyle||t.selectedStyle;if(s&&o.State.isSelected(t,r)&&(e=S(n,s)),o.State.isDisabled(t,r)){const o=n.disabledStyle||t.disabledStyle;o&&(e=S(n,o))}else{const i=n.focusStyle||t.focusStyle;i&&o.State.isFocus(t,r)&&(e=S(n,i));const a=n.hoverStyle||t.hoverStyle;a&&o.State.isHover(t,r)&&(e=S(n,a));const s=n.pressStyle||t.pressStyle;s&&o.State.isPress(t,r)&&(e=S(n,s))}return e?n:void 0}function d(t,e,n,i){const r=n?t:{},a=n||t;for(let t in a)i&&o.State.animateExcludes[t]||(r[t]=e[t]);return r}function y(t,e,n){return d(t,e,n,!0)}function S(t,e){return Object.assign(t,e),!0}function m(t,e){const n=t[e];n&&c(t,n),t.button&&b(t.children,e)}function g(t,e,n){n||(n=t.states[e]),c(t,n),t.button&&b(t.children,null,e)}function b(t,e,n){if(!t)return;let i,r;for(let a=0,s=t.length;a<s;a++){if(i=t[a],e){switch(r=!0,e){case"hoverStyle":o.State.isHover(i)&&(r=!1);break;case"pressStyle":o.State.isPress(i)&&(r=!1);break;case"focusStyle":o.State.isFocus(i)&&(r=!1)}r&&m(i,e)}else n&&g(i,n);i.isBranch&&b(i.children,e,n)}}function P(t,e){const n=t[e];n&&u(t,n),t.button&&v(t.children,e)}function _(t,e,n){u(t,n),t.button&&v(t.children,null,e)}function v(t,e,n){if(!t)return;let o;for(let i=0,r=t.length;i<r;i++)o=t[i],e?P(o,e):n&&_(o,n),o.isBranch&&v(o.children,e,n)}function x(t,e,n){let o;const i=e.leafer?e.leafer.interaction:null;if(i&&(o=i[t](e),!o&&n)){const r=l(e,n);r&&(o=i[t](r))}return o}function M(t,e,n){let o=e[t];if(!o&&n){const i=l(e,n);i&&(o=i[t])}return o}o.State.animateExcludes={animation:1,animationOut:1,transition:1,transitionOut:1,states:1,state:1,normalStyle:1,hoverStyle:1,pressStyle:1,focusStyle:1,selectedStyle:1,disabledStyle:1},o.State.isState=function(t,e,n){return function(t,e,n){let o=e.states[t];if(!o&&n){const i=l(e,n);i&&(o=i.states[t])}return!!o}(t,e,n)},o.State.isSelected=function(t,e){return M("selected",t,e)},o.State.isDisabled=function(t,e){return M("disabled",t,e)},o.State.isFocus=function(t,e){return x("isFocus",t,e)},o.State.isHover=function(t,e){return x("isHover",t,e)},o.State.isPress=function(t,e){return x("isPress",t,e)},o.State.isDrag=function(t,e){return x("isDrag",t,e)},o.State.setStyleName=function(t,e,n){n?g(t,e,t[e]):_(t,e,t[e])},o.State.set=function(t,e){const n=t.states[e];n?g(t,e,n):_(t,e,n)},o.State.getStyle=p,o.State.updateStyle=h,o.State.updateEventStyle=function(t,e){switch(e){case o.PointerEvent.ENTER:m(t,"hoverStyle");break;case o.PointerEvent.LEAVE:P(t,"hoverStyle");break;case o.PointerEvent.DOWN:m(t,"pressStyle");break;case o.PointerEvent.UP:P(t,"pressStyle")}};const D=o.UI.prototype;a(!1,"selectedStyle")(D,"selected"),a(!1,"disabledStyle")(D,"disabled"),s({})(D,"states"),a("")(D,"state"),o.dataType()(D,"normalStyle"),s()(D,"hoverStyle"),s()(D,"pressStyle"),s()(D,"focusStyle"),s()(D,"selectedStyle"),s()(D,"disabledStyle"),o.dataType(!1)(D,"button"),D.focus=function(t=!0){this.waitLeafer((()=>{let{focusData:e}=this.app.interaction;t?(e&&e.focus(!1),e=this):e=null,this.app.interaction.focusData=e,t?m(this,"focusStyle"):P(this,"focusStyle")}))},D.updateState=function(){o.State.updateStyle(this,void 0,"in")};const O=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],H=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:T}=Math,k={getDistance(t,e,n,o,i,r,a,s,l=1){let c,u,f,h,p,d,y=0,S=l/2;for(let l=0;l<O.length;l++)c=S*(1+O[l]),u=S*(1-O[l]),f=w(c,t,n,i,a),h=w(c,e,o,r,s),p=w(u,t,n,i,a),d=w(u,e,o,r,s),y+=H[l]*(T(f*f+h*h)+T(p*p+d*d));return y*S},getDerivative(t,e,n,o,i){const r=1-t;return 3*r*r*(n-e)+6*r*t*(o-n)+3*t*t*(i-o)},getRotation(t,e,o,i,r,a,s,l,c){const u=w(t,e,i,a,l),f=w(t,o,r,s,c);return Math.atan2(f,u)/n.OneRadian},getT(t,e,n,o,i,r,a,s,l,c,u=1){let f=0,h=1,p=t/e,d=u/e/3;if(p>=1)return 1;if(p<=0)return 0;for(;h-f>d;)j(n,o,i,r,a,s,l,c,p)<t?f=p:h=p,p=(f+h)/2;return p},cut(t,e,o,i,r,a,s,l,c,u){const f=1-e,h=f*o+e*r,p=f*i+e*a,d=f*r+e*s,y=f*a+e*l,S=f*h+e*d,m=f*p+e*y,g=f*S+e*(f*d+e*(f*s+e*c)),b=f*m+e*(f*y+e*(f*l+e*u));t.push(n.PathCommandMap.C,h,p,S,m,g,b)}},{getDerivative:w,getDistance:j}=k,{M:C,L:E,C:A,Z:F}=n.PathCommandMap,L={},N={},R={transform(t,e){let n,o=0;const i=t.length;for(;o<i;)switch(n=t[o],n){case C:case E:R.transformPoints(t,e,o,1),o+=3;break;case A:R.transformPoints(t,e,o,3),o+=7;break;case F:o+=1}},transformPoints(t,e,o,i){for(let r=o+1,a=r+2*i;r<a;r+=2)L.x=t[r],L.y=t[r+1],n.MatrixHelper.toOuterPoint(e,L),t[r]=L.x,t[r+1]=L.y},getMotionPathData(t){let e,o,i,r,a=0,s=[],l=0,c=0,u=0;const f=t.length;for(;l<f;){switch(r=t[l],r){case C:case E:o=t[l+1],i=t[l+2],e=r===E&&l>0?n.PointHelper.getDistanceFrom(c,u,o,i):0,c=o,u=i,l+=3;break;case A:o=t[l+5],i=t[l+6],e=k.getDistance(c,u,t[l+1],t[l+2],t[l+3],t[l+4],o,i),c=o,u=i,l+=7;break;case F:l+=1;default:e=0}s.push(e),a+=e}return{total:a,segments:s,data:t}},getDistancePoint(t,e,o){const{segments:i,data:r}=t;e=n.UnitConvert.number(e,t.total);let a,s,l,c,u,f,h,p,d,y=0,S={},m=0,g=0,b=0,P=0;const _=r.length;for(;m<_;){switch(c=r[m],c){case C:case E:if(s=r[m+1],l=r[m+2],a=i[g],y+a>e||!t.total)return m||(b=s,P=l),N.x=b,N.y=P,S.x=s,S.y=l,n.PointHelper.getDistancePoint(N,S,e-y,!0),S.rotation=n.PointHelper.getAngle(N,S),S;b=s,P=l,m+=3;break;case A:if(s=r[m+5],l=r[m+6],a=i[g],y+a>e)return u=r[m+1],f=r[m+2],h=r[m+3],p=r[m+4],d=k.getT(e-y,a,b,P,u,f,h,p,s,l,o),n.BezierHelper.getPointAndSet(d,b,P,u,f,h,p,s,l,S),S.rotation=k.getRotation(d,b,P,u,f,h,p,s,l),S;b=s,P=l,m+=7;break;case F:m+=1;default:a=0}g++,y+=a}return S},getDistancePath(t,e,o){const{segments:i,data:r}=t,a=[];e=n.UnitConvert.number(e,t.total);let s,l,c,u,f,h,p,d,y,S=0,m={},g=0,b=0,P=0,_=0;const v=r.length;for(;g<v;){switch(u=r[g],u){case C:case E:if(l=r[g+1],c=r[g+2],s=i[b],S+s>e||!t.total)return g||(P=l,_=c),N.x=P,N.y=_,m.x=l,m.y=c,n.PointHelper.getDistancePoint(N,m,e-S,!0),a.push(u,m.x,m.y),a;P=l,_=c,g+=3,a.push(u,P,_);break;case A:if(f=r[g+1],h=r[g+2],p=r[g+3],d=r[g+4],l=r[g+5],c=r[g+6],s=i[b],S+s>e)return y=k.getT(e-S,s,P,_,f,h,p,d,l,c,o),k.cut(a,y,P,_,f,h,p,d,l,c),a;P=l,_=c,g+=7,a.push(u,f,h,p,d,l,c);break;case F:g+=1,a.push(u);default:s=0}b++,S+=s}return a}};function q(t){return n.decorateLeafAttr(t,(t=>n.attr({set(e){this.__setAttr(t,e),this.__hasMotionPath=this.motionPath||!n.isNull(this.motion),this.__layout.matrixChanged||this.__layout.matrixChange()}})))}n.Transition.register("motion",(function(t,e,o,i){return t?"object"==typeof t&&(t=n.UnitConvert.number(t,i.getMotionTotal())):t=0,e?"object"==typeof e&&(e=n.UnitConvert.number(e,i.getMotionTotal())):e=0,n.Transition.number(t,e,o)})),n.Transition.register("motionRotation",(function(t,e,o){return n.Transition.number(t,e,o)}));const B=n.UI.prototype,{updateMatrix:U,updateAllMatrix:I}=n.LeafHelper,{updateBounds:z}=n.BranchHelper;function V(t){const{motion:e,leaferIsCreated:o}=t;if(!n.isNull(e)){if(o&&(t.leafer.created=!1),t.motionPath){const n=Z(t);n.total&&(t.__.__pathForRender=R.getDistancePath(n,e,t.motionPrecision))}else t.set(t.getMotionPoint(e)),t.__hasAutoLayout||(t.isBranch?(I(t),z(t,t)):U(t));o&&(t.leafer.created=!0)}}function W(t){const{parent:e}=t;if(!t.motionPath&&e){const{children:t}=e;for(let e=0;e<t.length;e++)if(t[e].motionPath)return t[e]}return t}function Z(t){const e=t.__;return e.__pathForMotion?e.__pathForMotion:e.__pathForMotion=R.getMotionPathData(t.getPath(!0,!0))}q()(B,"motionPath"),q(1)(B,"motionPrecision"),q()(B,"motion"),q(!0)(B,"motionRotation"),B.getMotionPathData=function(){return Z(W(this))},B.getMotionPoint=function(t){const e=W(this),o=Z(e);if(!o.total)return{};const i=R.getDistancePoint(o,t,e.motionPrecision);n.MatrixHelper.toOuterPoint(e.localTransform,i);const{motionRotation:r}=this;return!1===r?delete i.rotation:"number"==typeof r&&(i.rotation+=r),i},B.getMotionTotal=function(){return this.getMotionPathData().total},B.__updateMotionPath=function(){const t=this.__;if(this.__layout.resized&&t.__pathForMotion&&(t.__pathForMotion=void 0),this.motionPath){let t;const{children:e}=this.parent,{leaferIsReady:o}=this;for(let i=0;i<e.length;i++)t=e[i],n.isNull(t.motion)||t.__layout.matrixChanged||(o&&t!==this&&this.leafer.layouter.addExtra(t),V(t))}else V(this)};"ios"===wx.getSystemInfoSync().platform&&(r.LeaferImage.prototype.getPattern=function(t,e,n,o){const i=r.Platform.canvas.createPattern(this.view,e),{width:a,height:s}=t;this.width===a&&this.height===s||(n||(n=r.MatrixHelper.get()),r.MatrixHelper.scale(n,a/this.width,s/this.height));try{n&&i.setTransform&&(i.setTransform(n),n=null)}catch(t){}return o&&(o.transform=n),i}),exports.HighBezierHelper=k,exports.HighCurveHelper=R,exports.motionPathType=q,exports.stateStyleType=s,exports.stateType=a,Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(e).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})})),Object.keys(i).forEach((function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return i[t]}})}));