@microsoft/fast-element 2.0.0-beta.10 → 2.0.0-beta.12

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.
@@ -28,61 +28,6 @@ if (!globalThis.trustedTypes) {
28
28
  createPolicy: (n, r) => r,
29
29
  };
30
30
  }
31
- // ensure FAST global - duplicated in platform.ts
32
- const propConfig$1 = {
33
- configurable: false,
34
- enumerable: false,
35
- writable: false,
36
- };
37
- if (globalThis.FAST === void 0) {
38
- Reflect.defineProperty(globalThis, "FAST", Object.assign({ value: Object.create(null) }, propConfig$1));
39
- }
40
- const FAST$1 = globalThis.FAST;
41
- if (FAST$1.getById === void 0) {
42
- const storage = Object.create(null);
43
- Reflect.defineProperty(FAST$1, "getById", Object.assign({ value(id, initialize) {
44
- let found = storage[id];
45
- if (found === void 0) {
46
- found = initialize ? (storage[id] = initialize()) : null;
47
- }
48
- return found;
49
- } }, propConfig$1));
50
- }
51
- // duplicated from DOM
52
- const supportsAdoptedStyleSheets = Array.isArray(document.adoptedStyleSheets) &&
53
- "replace" in CSSStyleSheet.prototype;
54
- function usableStyleTarget(target) {
55
- return target === document ? document.body : target;
56
- }
57
- let id$1 = 0;
58
- const nextStyleId = () => `fast-${++id$1}`;
59
- class StyleElementStrategy {
60
- constructor(styles) {
61
- this.styles = styles;
62
- this.styleClass = nextStyleId();
63
- }
64
- addStylesTo(target) {
65
- target = usableStyleTarget(target);
66
- const styles = this.styles;
67
- const styleClass = this.styleClass;
68
- for (let i = 0; i < styles.length; i++) {
69
- const element = document.createElement("style");
70
- element.innerHTML = styles[i];
71
- element.className = styleClass;
72
- target.append(element);
73
- }
74
- }
75
- removeStylesFrom(target) {
76
- const styles = target.querySelectorAll(`.${this.styleClass}`);
77
- target = usableStyleTarget(target);
78
- for (let i = 0, ii = styles.length; i < ii; ++i) {
79
- target.removeChild(styles[i]);
80
- }
81
- }
82
- }
83
- if (!supportsAdoptedStyleSheets) {
84
- FAST$1.getById(/* KernelServiceId.styleSheetStrategy */ 5, () => StyleElementStrategy);
85
- }
86
31
 
87
32
  // ensure FAST global - duplicated in polyfills.ts and debug.ts
88
33
  const propConfig = {
@@ -1313,7 +1258,6 @@ function lengthOf(array) {
1313
1258
  return array.length;
1314
1259
  }
1315
1260
 
1316
- const styleSheetCache = new Map();
1317
1261
  let DefaultStyleStrategy;
1318
1262
  function reduceStyles(styles) {
1319
1263
  return styles
@@ -1404,36 +1348,6 @@ class ElementStyles {
1404
1348
  */
1405
1349
  ElementStyles.supportsAdoptedStyleSheets = Array.isArray(document.adoptedStyleSheets) &&
1406
1350
  "replace" in CSSStyleSheet.prototype;
1407
- /**
1408
- * https://wicg.github.io/construct-stylesheets/
1409
- * https://developers.google.com/web/updates/2019/02/constructable-stylesheets
1410
- *
1411
- * @internal
1412
- */
1413
- class AdoptedStyleSheetsStrategy {
1414
- constructor(styles) {
1415
- this.sheets = styles.map((x) => {
1416
- if (x instanceof CSSStyleSheet) {
1417
- return x;
1418
- }
1419
- let sheet = styleSheetCache.get(x);
1420
- if (sheet === void 0) {
1421
- sheet = new CSSStyleSheet();
1422
- sheet.replaceSync(x);
1423
- styleSheetCache.set(x, sheet);
1424
- }
1425
- return sheet;
1426
- });
1427
- }
1428
- addStylesTo(target) {
1429
- target.adoptedStyleSheets = [...target.adoptedStyleSheets, ...this.sheets];
1430
- }
1431
- removeStylesFrom(target) {
1432
- const sheets = this.sheets;
1433
- target.adoptedStyleSheets = target.adoptedStyleSheets.filter((x) => sheets.indexOf(x) === -1);
1434
- }
1435
- }
1436
- ElementStyles.setDefaultStrategy(FAST.getById(5 /* KernelServiceId.styleSheetStrategy */, () => AdoptedStyleSheetsStrategy));
1437
1351
 
1438
1352
  const registry$1 = createTypeRegistry();
1439
1353
  /**
@@ -1613,9 +1527,9 @@ const marker = `fast-${Math.random().toString(36).substring(2, 8)}`;
1613
1527
  const interpolationStart = `${marker}{`;
1614
1528
  const interpolationEnd = `}${marker}`;
1615
1529
  const interpolationEndLength = interpolationEnd.length;
1616
- let id = 0;
1530
+ let id$1 = 0;
1617
1531
  /** @internal */
1618
- const nextId = () => `${marker}-${++id}`;
1532
+ const nextId = () => `${marker}-${++id$1}`;
1619
1533
  /**
1620
1534
  * Common APIs related to markup generation.
1621
1535
  * @public
@@ -2875,10 +2789,11 @@ class RepeatBehavior {
2875
2789
  */
2876
2790
  constructor(directive) {
2877
2791
  this.directive = directive;
2878
- this.views = [];
2879
2792
  this.items = null;
2880
2793
  this.itemsObserver = null;
2881
2794
  this.bindView = bindWithoutPositioning;
2795
+ /** @internal */
2796
+ this.views = [];
2882
2797
  this.itemsBindingObserver = directive.dataBinding.createObserver(directive, this);
2883
2798
  this.templateBindingObserver = directive.templateBinding.createObserver(directive, this);
2884
2799
  if (directive.options.positioning) {
@@ -2996,10 +2911,10 @@ class RepeatBehavior {
2996
2911
  leftoverViews[i].dispose();
2997
2912
  }
2998
2913
  if (this.directive.options.positioning) {
2999
- for (let i = 0, ii = views.length; i < ii; ++i) {
2914
+ for (let i = 0, viewsLength = views.length; i < viewsLength; ++i) {
3000
2915
  const context = views[i].context;
3001
- context.length = i;
3002
- context.index = ii;
2916
+ context.length = viewsLength;
2917
+ context.index = i;
3003
2918
  }
3004
2919
  }
3005
2920
  }
@@ -3800,13 +3715,13 @@ class ElementController extends PropertyChangeNotifier {
3800
3715
  return;
3801
3716
  }
3802
3717
  const source = this.source;
3803
- const target = (_a = getShadowRoot(source)) !== null && _a !== void 0 ? _a : source.getRootNode();
3804
3718
  if (styles instanceof HTMLElement) {
3719
+ const target = (_a = getShadowRoot(source)) !== null && _a !== void 0 ? _a : this.source;
3805
3720
  target.append(styles);
3806
3721
  }
3807
- else if (!styles.isAttachedTo(target)) {
3722
+ else if (!styles.isAttachedTo(source)) {
3808
3723
  const sourceBehaviors = styles.behaviors;
3809
- styles.addStylesTo(target);
3724
+ styles.addStylesTo(source);
3810
3725
  if (sourceBehaviors !== null) {
3811
3726
  for (let i = 0, ii = sourceBehaviors.length; i < ii; ++i) {
3812
3727
  this.addBehavior(sourceBehaviors[i]);
@@ -3824,13 +3739,13 @@ class ElementController extends PropertyChangeNotifier {
3824
3739
  return;
3825
3740
  }
3826
3741
  const source = this.source;
3827
- const target = (_a = getShadowRoot(source)) !== null && _a !== void 0 ? _a : source.getRootNode();
3828
3742
  if (styles instanceof HTMLElement) {
3743
+ const target = (_a = getShadowRoot(source)) !== null && _a !== void 0 ? _a : source;
3829
3744
  target.removeChild(styles);
3830
3745
  }
3831
- else if (styles.isAttachedTo(target)) {
3746
+ else if (styles.isAttachedTo(source)) {
3832
3747
  const sourceBehaviors = styles.behaviors;
3833
- styles.removeStylesFrom(target);
3748
+ styles.removeStylesFrom(source);
3834
3749
  if (sourceBehaviors !== null) {
3835
3750
  for (let i = 0, ii = sourceBehaviors.length; i < ii; ++i) {
3836
3751
  this.addBehavior(sourceBehaviors[i]);
@@ -3965,6 +3880,94 @@ class ElementController extends PropertyChangeNotifier {
3965
3880
  return (element.$fastController = new ElementController(element, definition));
3966
3881
  }
3967
3882
  }
3883
+ /**
3884
+ * Converts a styleTarget into the operative target. When the provided target is an Element
3885
+ * that is a FASTElement, the function will return the ShadowRoot for that element. Otherwise,
3886
+ * it will return the root node for the element.
3887
+ * @param target
3888
+ * @returns
3889
+ */
3890
+ function normalizeStyleTarget(target) {
3891
+ var _a;
3892
+ if ("adoptedStyleSheets" in target) {
3893
+ return target;
3894
+ }
3895
+ else {
3896
+ return ((_a = getShadowRoot(target)) !== null && _a !== void 0 ? _a : target.getRootNode());
3897
+ }
3898
+ }
3899
+ // Default StyleStrategy implementations are defined in this module because they
3900
+ // require access to element shadowRoots, and we don't want to leak shadowRoot
3901
+ // objects out of this module.
3902
+ /**
3903
+ * https://wicg.github.io/construct-stylesheets/
3904
+ * https://developers.google.com/web/updates/2019/02/constructable-stylesheets
3905
+ *
3906
+ * @internal
3907
+ */
3908
+ class AdoptedStyleSheetsStrategy {
3909
+ constructor(styles) {
3910
+ const styleSheetCache = AdoptedStyleSheetsStrategy.styleSheetCache;
3911
+ this.sheets = styles.map((x) => {
3912
+ if (x instanceof CSSStyleSheet) {
3913
+ return x;
3914
+ }
3915
+ let sheet = styleSheetCache.get(x);
3916
+ if (sheet === void 0) {
3917
+ sheet = new CSSStyleSheet();
3918
+ sheet.replaceSync(x);
3919
+ styleSheetCache.set(x, sheet);
3920
+ }
3921
+ return sheet;
3922
+ });
3923
+ }
3924
+ addStylesTo(target) {
3925
+ const t = normalizeStyleTarget(target);
3926
+ t.adoptedStyleSheets = [...t.adoptedStyleSheets, ...this.sheets];
3927
+ }
3928
+ removeStylesFrom(target) {
3929
+ const t = normalizeStyleTarget(target);
3930
+ const sheets = this.sheets;
3931
+ t.adoptedStyleSheets = t.adoptedStyleSheets.filter((x) => sheets.indexOf(x) === -1);
3932
+ }
3933
+ }
3934
+ AdoptedStyleSheetsStrategy.styleSheetCache = new Map();
3935
+ let id = 0;
3936
+ const nextStyleId = () => `fast-${++id}`;
3937
+ function usableStyleTarget(target) {
3938
+ return target === document ? document.body : target;
3939
+ }
3940
+ /**
3941
+ * @internal
3942
+ */
3943
+ class StyleElementStrategy {
3944
+ constructor(styles) {
3945
+ this.styles = styles;
3946
+ this.styleClass = nextStyleId();
3947
+ }
3948
+ addStylesTo(target) {
3949
+ target = usableStyleTarget(normalizeStyleTarget(target));
3950
+ const styles = this.styles;
3951
+ const styleClass = this.styleClass;
3952
+ for (let i = 0; i < styles.length; i++) {
3953
+ const element = document.createElement("style");
3954
+ element.innerHTML = styles[i];
3955
+ element.className = styleClass;
3956
+ target.append(element);
3957
+ }
3958
+ }
3959
+ removeStylesFrom(target) {
3960
+ target = usableStyleTarget(normalizeStyleTarget(target));
3961
+ const styles = target.querySelectorAll(`.${this.styleClass}`);
3962
+ styles[0].parentNode;
3963
+ for (let i = 0, ii = styles.length; i < ii; ++i) {
3964
+ target.removeChild(styles[i]);
3965
+ }
3966
+ }
3967
+ }
3968
+ ElementStyles.setDefaultStrategy(ElementStyles.supportsAdoptedStyleSheets
3969
+ ? AdoptedStyleSheetsStrategy
3970
+ : StyleElementStrategy);
3968
3971
 
3969
3972
  /* eslint-disable-next-line @typescript-eslint/explicit-function-return-type */
3970
3973
  function createFASTElement(BaseType) {
@@ -4043,4 +4046,4 @@ function customElement(nameOrDef) {
4043
4046
  };
4044
4047
  }
4045
4048
 
4046
- export { AdoptedStyleSheetsStrategy, ArrayObserver, Aspect, AttributeConfiguration, AttributeDefinition, Binding, CSSDirective, ChildrenDirective, Compiler, DOM, ElementController, ElementStyles, ExecutionContext, FAST, FASTElement, FASTElementDefinition, HTMLBindingDirective, HTMLDirective, HTMLView, Markup, NodeObservationDirective, Observable, Parser, PropertyChangeNotifier, RefDirective, RepeatBehavior, RepeatDirective, SlottedDirective, SourceLifetime, Splice, SpliceStrategy, SpliceStrategySupport, StatelessAttachedAttributeDirective, SubscriberSet, Updates, ViewBehaviorOrchestrator, ViewTemplate, attr, bind, booleanConverter, children, createMetadataLocator, createTypeRegistry, css, cssDirective, cssPartial, customElement, elements, emptyArray, html, htmlDirective, lengthOf, listener, normalizeBinding, nullableNumberConverter, observable, oneTime, ref, repeat, slotted, volatile, when };
4049
+ export { ArrayObserver, Aspect, AttributeConfiguration, AttributeDefinition, Binding, CSSDirective, ChildrenDirective, Compiler, DOM, ElementController, ElementStyles, ExecutionContext, FAST, FASTElement, FASTElementDefinition, HTMLBindingDirective, HTMLDirective, HTMLView, Markup, NodeObservationDirective, Observable, Parser, PropertyChangeNotifier, RefDirective, RepeatBehavior, RepeatDirective, SlottedDirective, SourceLifetime, Splice, SpliceStrategy, SpliceStrategySupport, StatelessAttachedAttributeDirective, SubscriberSet, Updates, ViewBehaviorOrchestrator, ViewTemplate, attr, bind, booleanConverter, children, createMetadataLocator, createTypeRegistry, css, cssDirective, cssPartial, customElement, elements, emptyArray, html, htmlDirective, lengthOf, listener, normalizeBinding, nullableNumberConverter, observable, oneTime, ref, repeat, slotted, volatile, when };
@@ -1 +1 @@
1
- !function(){if("undefined"==typeof globalThis)if("undefined"!=typeof global)global.globalThis=global;else if("undefined"!=typeof self)self.globalThis=self;else if("undefined"!=typeof window)window.globalThis=window;else{const e=new Function("return this")();e.globalThis=e}}(),globalThis.trustedTypes||(globalThis.trustedTypes={createPolicy:(e,t)=>t});const e={configurable:!1,enumerable:!1,writable:!1};void 0===globalThis.FAST&&Reflect.defineProperty(globalThis,"FAST",Object.assign({value:Object.create(null)},e));const t=globalThis.FAST;if(void 0===t.getById){const s=Object.create(null);Reflect.defineProperty(t,"getById",Object.assign({value(e,t){let i=s[e];return void 0===i&&(i=t?s[e]=t():null),i}},e))}const s=Array.isArray(document.adoptedStyleSheets)&&"replace"in CSSStyleSheet.prototype;function i(e){return e===document?document.body:e}let n=0;class r{constructor(e){this.styles=e,this.styleClass="fast-"+ ++n}addStylesTo(e){e=i(e);const t=this.styles,s=this.styleClass;for(let i=0;i<t.length;i++){const n=document.createElement("style");n.innerHTML=t[i],n.className=s,e.append(n)}}removeStylesFrom(e){const t=e.querySelectorAll(`.${this.styleClass}`);e=i(e);for(let s=0,i=t.length;s<i;++s)e.removeChild(t[s])}}s||t.getById(5,(()=>r));const o={configurable:!1,enumerable:!1,writable:!1};void 0===globalThis.FAST&&Reflect.defineProperty(globalThis,"FAST",Object.assign({value:Object.create(null)},o));const l=globalThis.FAST;if(void 0===l.getById){const e=Object.create(null);Reflect.defineProperty(l,"getById",Object.assign({value(t,s){let i=e[t];return void 0===i&&(i=s?e[t]=s():null),i}},o))}void 0===l.error&&Object.assign(l,{warn(){},error:e=>new Error(`Error ${e}`),addMessages(){}});const a=Object.freeze([]);function h(){const e=new Map;return Object.freeze({register:t=>!e.has(t.type)&&(e.set(t.type,t),!0),getByType:t=>e.get(t),getForInstance(t){if(null!=t)return e.get(t.constructor)}})}function c(){const e=new WeakMap;return function(t){let s=e.get(t);if(void 0===s){let i=Reflect.getPrototypeOf(t);for(;void 0===s&&null!==i;)s=e.get(i),i=Reflect.getPrototypeOf(i);s=void 0===s?[]:s.slice(0),e.set(t,s)}return s}}const d=e=>"function"==typeof e,u=e=>"string"==typeof e,f=l.getById(1,(()=>{const e=[],t=[],s=globalThis.requestAnimationFrame;let i=!0;function n(){if(t.length)throw t.shift()}function r(s){try{s.call()}catch(s){if(!i)throw e.length=0,s;t.push(s),setTimeout(n,0)}}function o(){let t=0;for(;t<e.length;)if(r(e[t]),t++,t>1024){for(let s=0,i=e.length-t;s<i;s++)e[s]=e[s+t];e.length-=t,t=0}e.length=0}function l(t){e.push(t),e.length<2&&(i?s(o):o())}return Object.freeze({enqueue:l,next:()=>new Promise(l),process:o,setMode:e=>i=e})}));class p{constructor(e,t){this.sub1=void 0,this.sub2=void 0,this.spillover=void 0,this.subject=e,this.sub1=t}has(e){return void 0===this.spillover?this.sub1===e||this.sub2===e:-1!==this.spillover.indexOf(e)}subscribe(e){const t=this.spillover;if(void 0===t){if(this.has(e))return;if(void 0===this.sub1)return void(this.sub1=e);if(void 0===this.sub2)return void(this.sub2=e);this.spillover=[this.sub1,this.sub2,e],this.sub1=void 0,this.sub2=void 0}else{-1===t.indexOf(e)&&t.push(e)}}unsubscribe(e){const t=this.spillover;if(void 0===t)this.sub1===e?this.sub1=void 0:this.sub2===e&&(this.sub2=void 0);else{const s=t.indexOf(e);-1!==s&&t.splice(s,1)}}notify(e){const t=this.spillover,s=this.subject;if(void 0===t){const t=this.sub1,i=this.sub2;void 0!==t&&t.handleChange(s,e),void 0!==i&&i.handleChange(s,e)}else for(let i=0,n=t.length;i<n;++i)t[i].handleChange(s,e)}}class g{constructor(e){this.subscribers={},this.subjectSubscribers=null,this.subject=e}notify(e){var t,s;null===(t=this.subscribers[e])||void 0===t||t.notify(e),null===(s=this.subjectSubscribers)||void 0===s||s.notify(e)}subscribe(e,t){var s,i;let n;n=t?null!==(s=this.subscribers[t])&&void 0!==s?s:this.subscribers[t]=new p(this.subject):null!==(i=this.subjectSubscribers)&&void 0!==i?i:this.subjectSubscribers=new p(this.subject),n.subscribe(e)}unsubscribe(e,t){var s,i;t?null===(s=this.subscribers[t])||void 0===s||s.unsubscribe(e):null===(i=this.subjectSubscribers)||void 0===i||i.unsubscribe(e)}}const b=Object.freeze({unknown:void 0,coupled:1}),v=l.getById(2,(()=>{const e=f.enqueue,t=/(:|&&|\|\||if)/,s=new WeakMap;let i,n=e=>{throw l.error(1101)};function r(e){var t;let i=null!==(t=e.$fastController)&&void 0!==t?t:s.get(e);return void 0===i&&(Array.isArray(e)?i=n(e):s.set(e,i=new g(e))),i}const o=c();class a{constructor(e){this.name=e,this.field=`_${e}`,this.callback=`${e}Changed`}getValue(e){return void 0!==i&&i.watch(e,this.name),e[this.field]}setValue(e,t){const s=this.field,i=e[s];if(i!==t){e[s]=t;const n=e[this.callback];d(n)&&n.call(e,i,t),r(e).notify(this.name)}}}class h extends p{constructor(e,t,s=!1){super(e,t),this.expression=e,this.isVolatileBinding=s,this.needsRefresh=!0,this.needsQueue=!0,this.isAsync=!0,this.first=this,this.last=null,this.propertySource=void 0,this.propertyName=void 0,this.notifier=void 0,this.next=void 0}setMode(e){this.isAsync=this.needsQueue=e}bind(e){this.controller=e;const t=this.observe(e.source,e.context);return!e.isBound&&this.requiresUnbind(e)&&e.onUnbind(this),t}requiresUnbind(e){return e.sourceLifetime!==b.coupled||this.first!==this.last||this.first.propertySource!==e.source}unbind(e){this.dispose()}observe(e,t){this.needsRefresh&&null!==this.last&&this.dispose();const s=i;let n;i=this.needsRefresh?this:void 0,this.needsRefresh=this.isVolatileBinding;try{n=this.expression(e,t)}finally{i=s}return n}disconnect(){this.dispose()}dispose(){if(null!==this.last){let e=this.first;for(;void 0!==e;)e.notifier.unsubscribe(this,e.propertyName),e=e.next;this.last=null,this.needsRefresh=this.needsQueue=this.isAsync}}watch(e,t){const s=this.last,n=r(e),o=null===s?this.first:{};if(o.propertySource=e,o.propertyName=t,o.notifier=n,n.subscribe(this,t),null!==s){if(!this.needsRefresh){let t;i=void 0,t=s.propertySource[s.propertyName],i=this,e===t&&(this.needsRefresh=!0)}s.next=o}this.last=o}handleChange(){this.needsQueue?(this.needsQueue=!1,e(this)):this.isAsync||this.call()}call(){null!==this.last&&(this.needsQueue=this.isAsync,this.notify(this))}*records(){let e=this.first;for(;void 0!==e;)yield e,e=e.next}}return Object.freeze({setArrayObserverFactory(e){n=e},getNotifier:r,track(e,t){i&&i.watch(e,t)},trackVolatile(){i&&(i.needsRefresh=!0)},notify(e,t){r(e).notify(t)},defineProperty(e,t){u(t)&&(t=new a(t)),o(e).push(t),Reflect.defineProperty(e,t.name,{enumerable:!0,get(){return t.getValue(this)},set(e){t.setValue(this,e)}})},getAccessors:o,binding(e,t,s=this.isVolatileBinding(e)){return new h(e,t,s)},isVolatileBinding:e=>t.test(e.toString())})}));function y(e,t){v.defineProperty(e,t)}function m(e,t,s){return Object.assign({},s,{get(){return v.trackVolatile(),s.get.apply(this)}})}const w=l.getById(3,(()=>{let e=null;return{get:()=>e,set(t){e=t}}})),C=Object.freeze({default:{index:0,length:0,get event(){return C.getEvent()},eventDetail(){return this.event.detail},eventTarget(){return this.event.target}},getEvent:()=>w.get(),setEvent(e){w.set(e)}});class x{constructor(e,t,s){this.index=e,this.removed=t,this.addedCount=s}adjustTo(e){let t=this.index;const s=e.length;return t>s?t=s-this.addedCount:t<0&&(t=s+this.removed.length+t-this.addedCount),this.index=t<0?0:t,this}}const S=Object.freeze({reset:1,splice:2,optimized:3}),T=new x(0,a,0);T.reset=!0;const O=[T];function B(e,t,s,i,n,r){let o=0,l=0;const h=Math.min(s-t,r-n);if(0===t&&0===n&&(o=function(e,t,s){for(let i=0;i<s;++i)if(e[i]!==t[i])return i;return s}(e,i,h)),s===e.length&&r===i.length&&(l=function(e,t,s){let i=e.length,n=t.length,r=0;for(;r<s&&e[--i]===t[--n];)r++;return r}(e,i,h-o)),n+=o,r-=l,(s-=l)-(t+=o)==0&&r-n==0)return a;if(t===s){const e=new x(t,[],0);for(;n<r;)e.removed.push(i[n++]);return[e]}if(n===r)return[new x(t,[],s-t)];const c=function(e){let t=e.length-1,s=e[0].length-1,i=e[t][s];const n=[];for(;t>0||s>0;){if(0===t){n.push(2),s--;continue}if(0===s){n.push(3),t--;continue}const r=e[t-1][s-1],o=e[t-1][s],l=e[t][s-1];let a;a=o<l?o<r?o:r:l<r?l:r,a===r?(r===i?n.push(0):(n.push(1),i=r),t--,s--):a===o?(n.push(3),t--,i=o):(n.push(2),s--,i=l)}return n.reverse()}(function(e,t,s,i,n,r){const o=r-n+1,l=s-t+1,a=new Array(o);let h,c;for(let e=0;e<o;++e)a[e]=new Array(l),a[e][0]=e;for(let e=0;e<l;++e)a[0][e]=e;for(let s=1;s<o;++s)for(let r=1;r<l;++r)e[t+r-1]===i[n+s-1]?a[s][r]=a[s-1][r-1]:(h=a[s-1][r]+1,c=a[s][r-1]+1,a[s][r]=h<c?h:c);return a}(e,t,s,i,n,r)),d=[];let u,f=t,p=n;for(let e=0;e<c.length;++e)switch(c[e]){case 0:void 0!==u&&(d.push(u),u=void 0),f++,p++;break;case 1:void 0===u&&(u=new x(f,[],0)),u.addedCount++,f++,u.removed.push(i[p]),p++;break;case 2:void 0===u&&(u=new x(f,[],0)),u.addedCount++,f++;break;case 3:void 0===u&&(u=new x(f,[],0)),u.removed.push(i[p]),p++}return void 0!==u&&d.push(u),d}function A(e,t){let s=!1,i=0;for(let a=0;a<t.length;a++){const h=t[a];if(h.index+=i,s)continue;const c=(n=e.index,r=e.index+e.removed.length,o=h.index,l=h.index+h.addedCount,r<o||l<n?-1:r===o||l===n?0:n<o?r<l?r-o:l-o:l<r?l-n:r-n);if(c>=0){t.splice(a,1),a--,i-=h.addedCount-h.removed.length,e.addedCount+=h.addedCount-c;const n=e.removed.length+h.removed.length-c;if(e.addedCount||n){let t=h.removed;if(e.index<h.index){const s=e.removed.slice(0,h.index-e.index);s.push(...t),t=s}if(e.index+e.removed.length>h.index+h.addedCount){const s=e.removed.slice(h.index+h.addedCount-e.index);t.push(...s)}e.removed=t,h.index<e.index&&(e.index=h.index)}else s=!0}else if(e.index<h.index){s=!0,t.splice(a,0,e),a++;const n=e.addedCount-e.removed.length;h.index+=n,i+=n}}var n,r,o,l;s||t.push(e)}let k=Object.freeze({support:S.optimized,normalize:(e,t,s)=>void 0===e?void 0===s?a:s.length>1?function(e,t){let s=[];const i=[];for(let e=0,s=t.length;e<s;e++)A(t[e],i);for(let t=0,n=i.length;t<n;++t){const n=i[t];1!==n.addedCount||1!==n.removed.length?s=s.concat(B(e,n.index,n.index+n.addedCount,n.removed,0,n.removed.length)):n.removed[0]!==e[n.index]&&s.push(n)}return s}(t,s):s:O,pop(e,t,s,i){const n=e.length>0,r=s.apply(e,i);return n&&t.addSplice(new x(e.length,[r],0)),r},push(e,t,s,i){const n=s.apply(e,i);return t.addSplice(new x(e.length-i.length,[],i.length).adjustTo(e)),n},reverse(e,t,s,i){const n=s.apply(e,i);return t.reset(e),n},shift(e,t,s,i){const n=e.length>0,r=s.apply(e,i);return n&&t.addSplice(new x(0,[r],0)),r},sort(e,t,s,i){const n=s.apply(e,i);return t.reset(e),n},splice(e,t,s,i){const n=s.apply(e,i);return t.addSplice(new x(+i[0],n,i.length>2?i.length-2:0).adjustTo(e)),n},unshift(e,t,s,i){const n=s.apply(e,i);return t.addSplice(new x(0,[],i.length).adjustTo(e)),n}});const j=Object.freeze({reset:O,setDefaultStrategy(e){k=e}});function I(e,t,s){Reflect.defineProperty(e,t,{value:s,enumerable:!1})}class $ extends p{constructor(e){super(e),this.oldCollection=void 0,this.splices=void 0,this.needsQueue=!0,this._strategy=null,this._lengthObserver=void 0,this.call=this.flush,I(e,"$fastController",this)}get strategy(){return this._strategy}set strategy(e){this._strategy=e}get lengthObserver(){let e=this._lengthObserver;if(void 0===e){const t=this.subject;this._lengthObserver=e={length:t.length,handleChange(){this.length!==t.length&&(this.length=t.length,v.notify(e,"length"))}},this.subscribe(e)}return e}subscribe(e){this.flush(),super.subscribe(e)}addSplice(e){void 0===this.splices?this.splices=[e]:this.splices.push(e),this.enqueue()}reset(e){this.oldCollection=e,this.enqueue()}flush(){var e;const t=this.splices,s=this.oldCollection;void 0===t&&void 0===s||(this.needsQueue=!0,this.splices=void 0,this.oldCollection=void 0,this.notify((null!==(e=this._strategy)&&void 0!==e?e:k).normalize(s,this.subject,t)))}enqueue(){this.needsQueue&&(this.needsQueue=!1,f.enqueue(this))}}let V=!1;const E=Object.freeze({enable(){if(V)return;V=!0,v.setArrayObserverFactory((e=>new $(e)));const e=Array.prototype;e.$fastPatch||(I(e,"$fastPatch",1),[e.pop,e.push,e.reverse,e.shift,e.sort,e.splice,e.unshift].forEach((t=>{e[t.name]=function(...e){var s;const i=this.$fastController;return void 0===i?t.apply(this,e):(null!==(s=i.strategy)&&void 0!==s?s:k)[t.name](this,i,t,e)}})))}});function N(e){if(!e)return 0;let t=e.$fastController;return void 0===t&&(E.enable(),t=v.getNotifier(e)),v.track(t.lengthObserver,"length"),e.length}const _=new Map;let z;function F(e){return e.map((e=>e instanceof L?F(e.styles):[e])).reduce(((e,t)=>e.concat(t)),[])}class L{constructor(e){this.styles=e,this.targets=new WeakSet,this._strategy=null,this.behaviors=e.map((e=>e instanceof L?e.behaviors:null)).reduce(((e,t)=>null===t?e:null===e?t:e.concat(t)),null)}get strategy(){return null===this._strategy&&this.withStrategy(z),this._strategy}addStylesTo(e){this.strategy.addStylesTo(e),this.targets.add(e)}removeStylesFrom(e){this.strategy.removeStylesFrom(e),this.targets.delete(e)}isAttachedTo(e){return this.targets.has(e)}withBehaviors(...e){return this.behaviors=null===this.behaviors?e:this.behaviors.concat(e),this}withStrategy(e){return this._strategy=new e(F(this.styles)),this}static setDefaultStrategy(e){z=e}static normalize(e){return void 0===e?void 0:Array.isArray(e)?new L(e):e instanceof L?e:new L([e])}}L.supportsAdoptedStyleSheets=Array.isArray(document.adoptedStyleSheets)&&"replace"in CSSStyleSheet.prototype;class M{constructor(e){this.sheets=e.map((e=>{if(e instanceof CSSStyleSheet)return e;let t=_.get(e);return void 0===t&&(t=new CSSStyleSheet,t.replaceSync(e),_.set(e,t)),t}))}addStylesTo(e){e.adoptedStyleSheets=[...e.adoptedStyleSheets,...this.sheets]}removeStylesFrom(e){const t=this.sheets;e.adoptedStyleSheets=e.adoptedStyleSheets.filter((e=>-1===t.indexOf(e)))}}L.setDefaultStrategy(l.getById(5,(()=>M)));const P=h(),R=Object.freeze({getForInstance:P.getForInstance,getByType:P.getByType,define:e=>(P.register({type:e}),e)});function D(){return function(e){R.define(e)}}function H(e,t){const s=[];let i="";const n=[],r=e=>{n.push(e)};for(let n=0,o=e.length-1;n<o;++n){i+=e[n];let o=t[n];void 0!==R.getForInstance(o)&&(o=o.createCSS(r)),o instanceof L||o instanceof CSSStyleSheet?(""!==i.trim()&&(s.push(i),i=""),s.push(o)):i+=o}return i+=e[e.length-1],""!==i.trim()&&s.push(i),{styles:s,behaviors:n}}const U=(e,...t)=>{const{styles:s,behaviors:i}=H(e,t),n=new L(s);return i.length?n.withBehaviors(...i):n};class q{constructor(e,t){this.behaviors=t,this.css="";const s=e.reduce(((e,t)=>(u(t)?this.css+=t:e.push(t),e)),[]);s.length&&(this.styles=new L(s))}createCSS(e){return this.behaviors.forEach(e),this.styles&&e(this),this.css}addedCallback(e){e.addStyles(this.styles)}removedCallback(e){e.removeStyles(this.styles)}}R.define(q);const Q=U.partial=(e,...t)=>{const{styles:s,behaviors:i}=H(e,t);return new q(s,i)},W=Object.freeze({queueUpdate:f.enqueue,nextUpdate:f.next,processUpdates:f.process,setAttribute(e,t,s){null==s?e.removeAttribute(t):e.setAttribute(t,s)},setBooleanAttribute(e,t,s){s?e.setAttribute(t,""):e.removeAttribute(t)}}),G=`fast-${Math.random().toString(36).substring(2,8)}`,J=`${G}{`,K=`}${G}`,X=K.length;let Y=0;const Z=()=>`${G}-${++Y}`,ee=Object.freeze({interpolation:e=>`${J}${e}${K}`,attribute:e=>`${Z()}="${J}${e}${K}"`,comment:e=>`\x3c!--${J}${e}${K}--\x3e`}),te=Object.freeze({parse(e,t){const s=e.split(J);if(1===s.length)return null;const i=[];for(let e=0,n=s.length;e<n;++e){const n=s[e],r=n.indexOf(K);let o;if(-1===r)o=n;else{const e=n.substring(0,r);i.push(t[e]),o=n.substring(r+X)}""!==o&&i.push(o)}return i}}),se=Object.freeze({create(e){const t=[],s={};let i=null,n=!1;return{source:e,context:C.default,targets:s,get isBound(){return n},addBehaviorFactory(e,t){const s=e.nodeId||(e.nodeId=Z());e.id||(e.id=Z()),this.addTarget(s,t),this.addBehavior(e.createBehavior())},addTarget(e,t){s[e]=t},addBehavior(e){t.push(e),n&&e.bind(this)},onUnbind(e){null===i&&(i=[]),i.push(e)},connectedCallback(e){n||(n=!0,t.forEach((e=>e.bind(this))))},disconnectedCallback(e){n&&(n=!1,null!==i&&i.forEach((e=>e.unbind(this))))}}}}),ie=h(),ne=Object.freeze({getForInstance:ie.getForInstance,getByType:ie.getByType,define:(e,t)=>((t=t||{}).type=e,ie.register(t),e)});function re(e){return function(t){ne.define(t,e)}}class oe{constructor(e,t=!1){this.evaluate=e,this.isVolatile=t}}const le=Object.freeze({none:0,attribute:1,booleanAttribute:2,property:3,content:4,tokenList:5,event:6,assign(e,t){if(t)switch(e.sourceAspect=t,t[0]){case":":e.targetAspect=t.substring(1),e.aspectType="classList"===e.targetAspect?le.tokenList:le.property;break;case"?":e.targetAspect=t.substring(1),e.aspectType=le.booleanAttribute;break;case"@":e.targetAspect=t.substring(1),e.aspectType=le.event;break;default:e.targetAspect=t,e.aspectType=le.attribute}else e.aspectType=le.content}});class ae{constructor(e){this.options=e,this.id=Z()}createHTML(e){return ee.attribute(e(this))}createBehavior(){return this}}const he=globalThis.TrustedHTML?e=>(t,s)=>{const i=e(t,s);if(i instanceof TrustedHTML)return i;throw l.error(1202)}:e=>e;class ce extends oe{createObserver(e,t){return v.binding(this.evaluate,t,this.isVolatile)}}class de extends oe{createObserver(){return this}bind(e){return this.evaluate(e.source,e.context)}}function ue(e,t,s,i){if(null==s&&(s=""),s.create){e.textContent="";let t=e.$fastView;void 0===t?t=s.create():e.$fastTemplate!==s&&(t.isComposed&&(t.remove(),t.unbind()),t=s.create()),t.isComposed?t.needsBindOnly&&(t.needsBindOnly=!1,t.bind(i.source,i.context)):(t.isComposed=!0,t.bind(i.source,i.context),t.insertBefore(e),e.$fastView=t,e.$fastTemplate=s)}else{const t=e.$fastView;void 0!==t&&t.isComposed&&(t.isComposed=!1,t.remove(),t.needsBindOnly?t.needsBindOnly=!1:t.unbind()),e.textContent=s}}function fe(e,t,s){var i;const n=`${this.id}-t`,r=null!==(i=e[n])&&void 0!==i?i:e[n]={c:0,v:Object.create(null)},o=r.v;let l=r.c;const a=e[t];if(null!=s&&s.length){const e=s.split(/\s+/);for(let t=0,s=e.length;t<s;++t){const s=e[t];""!==s&&(o[s]=l,a.add(s))}}if(r.v=l+1,0!==l){l-=1;for(const e in o)o[e]===l&&a.remove(e)}}const pe=(e,t,s)=>e[t]=s,ge=()=>{};class be{constructor(e){this.dataBinding=e,this.updateTarget=null,this.id=Z(),this.aspectType=le.content,this.bind=this.bindDefault,this.data=`${this.id}-d`}createHTML(e){return ee.interpolation(e(this))}createBehavior(){if(null===this.updateTarget)switch("innerHTML"===this.targetAspect&&(this.dataBinding.evaluate=he(this.dataBinding.evaluate)),this.aspectType){case 1:this.updateTarget=W.setAttribute;break;case 2:this.updateTarget=W.setBooleanAttribute;break;case 3:this.updateTarget=pe;break;case 4:this.bind=this.bindContent,this.updateTarget=ue;break;case 5:this.updateTarget=fe;break;case 6:this.bind=this.bindEvent,this.updateTarget=ge;break;default:throw l.error(1205)}return this}bindDefault(e){var t;const s=e.targets[this.nodeId],i=null!==(t=s[this.data])&&void 0!==t?t:s[this.data]=this.dataBinding.createObserver(this,this);i.target=s,i.controller=e,this.updateTarget(s,this.targetAspect,i.bind(e),e),this.updateTarget===ue&&e.onUnbind(this)}bindContent(e){this.bindDefault(e),e.onUnbind(this)}bindEvent(e){const t=e.targets[this.nodeId];t[this.data]=e,t.addEventListener(this.targetAspect,this,this.dataBinding.options)}unbind(e){const t=e.targets[this.nodeId].$fastView;void 0!==t&&t.isComposed&&(t.unbind(),t.needsBindOnly=!0)}handleEvent(e){const t=e.currentTarget;C.setEvent(e);const s=t[this.data],i=this.dataBinding.evaluate(s.source,s.context);C.setEvent(null),!0!==i&&e.preventDefault()}handleChange(e,t){const s=t.target,i=t.controller;this.updateTarget(s,this.targetAspect,t.bind(i),i)}}function ve(e,t=v.isVolatileBinding(e)){return new ce(e,t)}function ye(e){return new de(e)}function me(e,t){const s=new ce(e,!1);return s.options=t,s}function we(e){return d(e)?ve(e):e instanceof oe?e:ye((()=>e))}function Ce(e,t){const s=e.parentNode;let i,n=e;for(;n!==t;)i=n.nextSibling,s.removeChild(n),n=i;s.removeChild(t)}ne.define(be,{aspected:!0});class xe{constructor(e,t,s){this.fragment=e,this.factories=t,this.targets=s,this.behaviors=null,this.unbindables=[],this.source=null,this.isBound=!1,this.sourceLifetime=b.unknown,this.context=this,this.index=0,this.length=0,this.firstChild=e.firstChild,this.lastChild=e.lastChild}get event(){return C.getEvent()}get isEven(){return this.index%2==0}get isOdd(){return this.index%2!=0}get isFirst(){return 0===this.index}get isInMiddle(){return!this.isFirst&&!this.isLast}get isLast(){return this.index===this.length-1}eventDetail(){return this.event.detail}eventTarget(){return this.event.target}appendTo(e){e.appendChild(this.fragment)}insertBefore(e){if(this.fragment.hasChildNodes())e.parentNode.insertBefore(this.fragment,e);else{const t=this.lastChild;if(e.previousSibling===t)return;const s=e.parentNode;let i,n=this.firstChild;for(;n!==t;)i=n.nextSibling,s.insertBefore(n,e),n=i;s.insertBefore(t,e)}}remove(){const e=this.fragment,t=this.lastChild;let s,i=this.firstChild;for(;i!==t;)s=i.nextSibling,e.appendChild(i),i=s;e.appendChild(t)}dispose(){Ce(this.firstChild,this.lastChild),this.unbind()}onUnbind(e){this.unbindables.push(e)}bind(e,t=this){if(this.source===e)return;let s=this.behaviors;if(null===s){this.source=e,this.context=t,this.behaviors=s=new Array(this.factories.length);const i=this.factories;for(let e=0,t=i.length;e<t;++e){const t=i[e].createBehavior();t.bind(this),s[e]=t}}else{null!==this.source&&this.evaluateUnbindables(),this.isBound=!1,this.source=e,this.context=t;for(let e=0,t=s.length;e<t;++e)s[e].bind(this)}this.isBound=!0}unbind(){this.isBound&&null!==this.source&&(this.evaluateUnbindables(),this.source=null,this.context=this,this.isBound=!1)}evaluateUnbindables(){const e=this.unbindables;for(let t=0,s=e.length;t<s;++t)e[t].unbind(this);e.length=0}static disposeContiguousBatch(e){if(0!==e.length){Ce(e[0].firstChild,e[e.length-1].lastChild);for(let t=0,s=e.length;t<s;++t)e[t].unbind()}}}v.defineProperty(xe.prototype,"index"),v.defineProperty(xe.prototype,"length");const Se=(e,t)=>`${e}.${t}`,Te={},Oe={index:0,node:null};function Be(e){e.startsWith("fast-")||l.warn(1204,{name:e})}const Ae=new Proxy(document.createElement("div"),{get(e,t){Be(t);const s=Reflect.get(e,t);return d(s)?s.bind(e):s},set:(e,t,s)=>(Be(t),Reflect.set(e,t,s))});class ke{constructor(e,t){this.fragment=e,this.directives=t,this.proto=null,this.nodeIds=new Set,this.descriptors={},this.factories=[]}addFactory(e,t,s,i){this.nodeIds.has(s)||(this.nodeIds.add(s),this.addTargetDescriptor(t,s,i)),e.nodeId=s,this.factories.push(e)}freeze(){return this.proto=Object.create(null,this.descriptors),this}addTargetDescriptor(e,t,s){const i=this.descriptors;if("r"===t||"h"===t||i[t])return;if(!i[e]){const t=e.lastIndexOf("."),s=e.substring(0,t),i=parseInt(e.substring(t+1));this.addTargetDescriptor(s,e,i)}let n=Te[t];if(!n){const i=`_${t}`;Te[t]=n={get(){var t;return null!==(t=this[i])&&void 0!==t?t:this[i]=this[e].childNodes[s]}}}i[t]=n}createView(e){const t=this.fragment.cloneNode(!0),s=Object.create(this.proto);s.r=t,s.h=null!=e?e:Ae;for(const e of this.nodeIds)s[e];return new xe(t,this.factories,s)}}function je(e,t,s,i,n,r=!1){const o=s.attributes,l=e.directives;for(let a=0,h=o.length;a<h;++a){const c=o[a],d=c.value,u=te.parse(d,l);let f=null;null===u?r&&(f=new be(ye((()=>d))),le.assign(f,c.name)):f=_e.aggregate(u),null!==f&&(s.removeAttributeNode(c),a--,h--,e.addFactory(f,t,i,n))}}function Ie(e,t,s){let i=0,n=t.firstChild;for(;n;){const t=$e(e,s,n,i);n=t.node,i=t.index}}function $e(e,t,s,i){const n=Se(t,i);switch(s.nodeType){case 1:je(e,t,s,n,i),Ie(e,s,n);break;case 3:return function(e,t,s,i,n){const r=te.parse(t.textContent,e.directives);if(null===r)return Oe.node=t.nextSibling,Oe.index=n+1,Oe;let o,l=o=t;for(let t=0,a=r.length;t<a;++t){const a=r[t];0!==t&&(n++,i=Se(s,n),o=l.parentNode.insertBefore(document.createTextNode(""),l.nextSibling)),u(a)?o.textContent=a:(o.textContent=" ",le.assign(a),e.addFactory(a,s,i,n)),l=o}return Oe.index=n+1,Oe.node=l.nextSibling,Oe}(e,s,t,n,i);case 8:const r=te.parse(s.data,e.directives);null!==r&&e.addFactory(_e.aggregate(r),t,n,i)}return Oe.index=i+1,Oe.node=s.nextSibling,Oe}const Ve={createHTML:e=>e};let Ee=globalThis.trustedTypes?globalThis.trustedTypes.createPolicy("fast-html",Ve):Ve;const Ne=Ee,_e={setHTMLPolicy(e){if(Ee!==Ne)throw l.error(1201);Ee=e},compile(e,t){let s;if(u(e)){s=document.createElement("TEMPLATE"),s.innerHTML=Ee.createHTML(e);const t=s.content.firstElementChild;null!==t&&"TEMPLATE"===t.tagName&&(s=t)}else s=e;const i=document.adoptNode(s.content),n=new ke(i,t);return je(n,"",s,"h",0,!0),(function(e,t){return e&&8==e.nodeType&&null!==te.parse(e.data,t)}(i.firstChild,t)||1===i.childNodes.length&&Object.keys(t).length>0)&&i.insertBefore(document.createComment(""),i.firstChild),Ie(n,i,"r"),Oe.node=null,n.freeze()},setDefaultStrategy(e){this.compile=e},aggregate(e){if(1===e.length)return e[0];let t,s,i=!1;const n=e.length,r=e.map((e=>u(e)?()=>e:(t=e.sourceAspect||t,s=e.dataBinding||s,i=i||e.dataBinding.isVolatile,e.dataBinding.evaluate)));s.evaluate=(e,t)=>{let s="";for(let i=0;i<n;++i)s+=r[i](e,t);return s},s.isVolatile=i;const o=new be(s);return le.assign(o,t),o}};class ze{constructor(e,t){this.result=null,this.html=e,this.factories=t}create(e){return null===this.result&&(this.result=_e.compile(this.html,this.factories)),this.result.createView(e)}render(e,t,s){const i=this.create(s);return i.bind(e),i.appendTo(t),i}}const Fe=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function Le(e,t,s){const i=Fe.exec(t);return null!==i&&le.assign(e,i[2]),e.createHTML(s)}function Me(e,...t){let s="";const i=Object.create(null),n=e=>{var t;const s=null!==(t=e.id)&&void 0!==t?t:e.id=Z();return i[s]=e,s};for(let i=0,r=e.length-1;i<r;++i){const r=e[i],o=t[i];let l;if(s+=r,d(o))s+=Le(new be(ve(o)),r,n);else if(u(o)){const e=Fe.exec(r);if(null!==e){const t=new be(ye((()=>o)));le.assign(t,e[2]),s+=t.createHTML(n)}else s+=o}else o instanceof oe?s+=Le(new be(o),r,n):void 0===(l=ne.getForInstance(o))?s+=Le(new be(ye((()=>o))),r,n):l.aspected?s+=Le(o,r,n):s+=o.createHTML(n)}return new ze(s+e[e.length-1],i)}class Pe extends ae{bind(e){e.source[this.options]=e.targets[this.nodeId]}}ne.define(Pe);const Re=e=>new Pe(e);function De(e,t){const s=d(e)?e:()=>e,i=d(t)?t:()=>t;return(e,t)=>s(e,t)?i(e,t):null}const He=Object.freeze({positioning:!1,recycle:!0});function Ue(e,t,s,i){e.context.parent=i.source,e.context.parentContext=i.context,e.bind(t[s])}function qe(e,t,s,i){e.context.parent=i.source,e.context.parentContext=i.context,e.context.length=t.length,e.context.index=s,e.bind(t[s])}class Qe{constructor(e){this.directive=e,this.views=[],this.items=null,this.itemsObserver=null,this.bindView=Ue,this.itemsBindingObserver=e.dataBinding.createObserver(e,this),this.templateBindingObserver=e.templateBinding.createObserver(e,this),e.options.positioning&&(this.bindView=qe)}bind(e){this.location=e.targets[this.directive.nodeId],this.controller=e,this.items=this.itemsBindingObserver.bind(e),this.template=this.templateBindingObserver.bind(e),this.observeItems(!0),this.refreshAllViews(),e.onUnbind(this)}unbind(){null!==this.itemsObserver&&this.itemsObserver.unsubscribe(this),this.unbindAllViews()}handleChange(e,t){if(t===this.itemsBindingObserver)this.items=this.itemsBindingObserver.bind(this.controller),this.observeItems(),this.refreshAllViews();else if(t===this.templateBindingObserver)this.template=this.templateBindingObserver.bind(this.controller),this.refreshAllViews(!0);else{if(!t[0])return;t[0].reset?this.refreshAllViews():this.updateViews(t)}}observeItems(e=!1){if(!this.items)return void(this.items=a);const t=this.itemsObserver,s=this.itemsObserver=v.getNotifier(this.items),i=t!==s;i&&null!==t&&t.unsubscribe(this),(i||e)&&s.subscribe(this)}updateViews(e){const t=this.views,s=this.bindView,i=this.items,n=this.template,r=this.controller,o=this.directive.options.recycle,l=[];let a=0,h=0;for(let c=0,d=e.length;c<d;++c){const d=e[c],u=d.removed;let f=0,p=d.index;const g=p+d.addedCount,b=t.splice(d.index,u.length),v=h=l.length+b.length;for(;p<g;++p){const e=t[p],c=e?e.firstChild:this.location;let d;o&&h>0?(f<=v&&b.length>0?(d=b[f],f++):(d=l[a],a++),h--):d=n.create(),t.splice(p,0,d),s(d,i,p,r),d.insertBefore(c)}b[f]&&l.push(...b.slice(f))}for(let e=a,t=l.length;e<t;++e)l[e].dispose();if(this.directive.options.positioning)for(let e=0,s=t.length;e<s;++e){const i=t[e].context;i.length=e,i.index=s}}refreshAllViews(e=!1){const t=this.items,s=this.template,i=this.location,n=this.bindView,r=this.controller;let o=t.length,l=this.views,a=l.length;if(0!==o&&!e&&this.directive.options.recycle||(xe.disposeContiguousBatch(l),a=0),0===a){this.views=l=new Array(o);for(let e=0;e<o;++e){const o=s.create();n(o,t,e,r),l[e]=o,o.insertBefore(i)}}else{let e=0;for(;e<o;++e)if(e<a){n(l[e],t,e,r)}else{const o=s.create();n(o,t,e,r),l.push(o),o.insertBefore(i)}const h=l.splice(e,a-e);for(e=0,o=h.length;e<o;++e)h[e].dispose()}}unbindAllViews(){const e=this.views;for(let t=0,s=e.length;t<s;++t)e[t].unbind()}}class We{constructor(e,t,s){this.dataBinding=e,this.templateBinding=t,this.options=s,this.id=Z(),E.enable()}createHTML(e){return ee.comment(e(this))}createBehavior(){return new Qe(this)}}function Ge(e,t,s=He){const i=we(e),n=we(t);return new We(i,n,Object.assign(Object.assign({},He),s))}ne.define(We);const Je=e=>1===e.nodeType,Ke=e=>e?t=>1===t.nodeType&&t.matches(e):Je;class Xe extends ae{constructor(){super(...arguments),this.sourceProperty=`${this.id}-s`}bind(e){const t=e.targets[this.nodeId];t[this.sourceProperty]=e.source,this.updateTarget(e.source,this.computeNodes(t)),this.observe(t),e.onUnbind(this)}unbind(e){const t=e.targets[this.nodeId];this.updateTarget(e.source,a),this.disconnect(t),t[this.sourceProperty]=null}getSource(e){return e[this.sourceProperty]}updateTarget(e,t){e[this.options.property]=t}computeNodes(e){let t=this.getNodes(e);return"filter"in this.options&&(t=t.filter(this.options.filter)),t}}class Ye extends Xe{observe(e){e.addEventListener("slotchange",this)}disconnect(e){e.removeEventListener("slotchange",this)}getNodes(e){return e.assignedNodes(this.options)}handleEvent(e){const t=e.currentTarget;this.updateTarget(this.getSource(t),this.computeNodes(t))}}function Ze(e){return u(e)&&(e={property:e}),new Ye(e)}ne.define(Ye);class et extends Xe{constructor(e){super(e),this.observerProperty=`${this.id}-o`,this.handleEvent=(e,t)=>{const s=t.target;this.updateTarget(this.getSource(s),this.computeNodes(s))},e.childList=!0}observe(e){var t;const s=null!==(t=e[this.observerProperty])&&void 0!==t?t:e[this.observerProperty]=new MutationObserver(this.handleEvent);s.target=e,s.observe(e,this.options)}disconnect(e){const t=e[this.observerProperty];t.target=null,t.disconnect()}getNodes(e){return"selector"in this.options?Array.from(e.querySelectorAll(this.options.selector)):Array.from(e.childNodes)}}function tt(e){return u(e)&&(e={property:e}),new et(e)}ne.define(et);const st=Object.freeze({locate:c()}),it={toView:e=>e?"true":"false",fromView:e=>null!=e&&"false"!==e&&!1!==e&&0!==e};function nt(e){if(null==e)return null;const t=1*e;return isNaN(t)?null:t}const rt={toView(e){const t=nt(e);return t?t.toString():t},fromView:nt};class ot{constructor(e,t,s=t.toLowerCase(),i="reflect",n){this.guards=new Set,this.Owner=e,this.name=t,this.attribute=s,this.mode=i,this.converter=n,this.fieldName=`_${t}`,this.callbackName=`${t}Changed`,this.hasCallback=this.callbackName in e.prototype,"boolean"===i&&void 0===n&&(this.converter=it)}setValue(e,t){const s=e[this.fieldName],i=this.converter;void 0!==i&&(t=i.fromView(t)),s!==t&&(e[this.fieldName]=t,this.tryReflectToAttribute(e),this.hasCallback&&e[this.callbackName](s,t),e.$fastController.notify(this.name))}getValue(e){return v.track(e,this.name),e[this.fieldName]}onAttributeChangedCallback(e,t){this.guards.has(e)||(this.guards.add(e),this.setValue(e,t),this.guards.delete(e))}tryReflectToAttribute(e){const t=this.mode,s=this.guards;s.has(e)||"fromView"===t||f.enqueue((()=>{s.add(e);const i=e[this.fieldName];switch(t){case"reflect":const t=this.converter;W.setAttribute(e,this.attribute,void 0!==t?t.toView(i):i);break;case"boolean":W.setBooleanAttribute(e,this.attribute,i)}s.delete(e)}))}static collect(e,...t){const s=[];t.push(st.locate(e));for(let i=0,n=t.length;i<n;++i){const n=t[i];if(void 0!==n)for(let t=0,i=n.length;t<i;++t){const i=n[t];u(i)?s.push(new ot(e,i)):s.push(new ot(e,i.property,i.attribute,i.mode,i.converter))}}return s}}function lt(e,t){let s;function i(e,t){arguments.length>1&&(s.property=t),st.locate(e.constructor).push(s)}return arguments.length>1?(s={},void i(e,t)):(s=void 0===e?{}:e,i)}const at={mode:"open"},ht={},ct=new Set,dt=l.getById(4,(()=>h()));class ut{constructor(e,t=e.definition){var s;this.platformDefined=!1,u(t)&&(t={name:t}),this.type=e,this.name=t.name,this.template=t.template,this.registry=null!==(s=t.registry)&&void 0!==s?s:customElements;const i=e.prototype,n=ot.collect(e,t.attributes),r=new Array(n.length),o={},l={};for(let e=0,t=n.length;e<t;++e){const t=n[e];r[e]=t.attribute,o[t.name]=t,l[t.attribute]=t,v.defineProperty(i,t)}Reflect.defineProperty(e,"observedAttributes",{value:r,enumerable:!0}),this.attributes=n,this.propertyLookup=o,this.attributeLookup=l,this.shadowOptions=void 0===t.shadowOptions?at:null===t.shadowOptions?void 0:Object.assign(Object.assign({},at),t.shadowOptions),this.elementOptions=void 0===t.elementOptions?ht:Object.assign(Object.assign({},ht),t.elementOptions),this.styles=L.normalize(t.styles),dt.register(this)}get isDefined(){return this.platformDefined}define(e=this.registry){const t=this.type;return e.get(this.name)||(this.platformDefined=!0,e.define(this.name,t,this.elementOptions)),this}static compose(e,t){return ct.has(e)||dt.getByType(e)?new ut(class extends e{},t):new ut(e,t)}static registerBaseType(e){ct.add(e)}}ut.getByType=dt.getByType,ut.getForInstance=dt.getForInstance;const ft={bubbles:!0,composed:!0,cancelable:!0},pt=new WeakMap;function gt(e){var t,s;return null!==(s=null!==(t=e.shadowRoot)&&void 0!==t?t:pt.get(e))&&void 0!==s?s:null}class bt extends g{constructor(e,t){super(e),this.boundObservables=null,this.needsInitialization=!0,this.hasExistingShadowRoot=!1,this._template=null,this._isConnected=!1,this.behaviors=null,this._mainStyles=null,this.$fastController=this,this.view=null,this.source=e,this.definition=t;const s=t.shadowOptions;if(void 0!==s){let t=e.shadowRoot;t?this.hasExistingShadowRoot=!0:(t=e.attachShadow(s),"closed"===s.mode&&pt.set(e,t))}const i=v.getAccessors(e);if(i.length>0){const t=this.boundObservables=Object.create(null);for(let s=0,n=i.length;s<n;++s){const n=i[s].name,r=e[n];void 0!==r&&(delete e[n],t[n]=r)}}}get isConnected(){return v.track(this,"isConnected"),this._isConnected}setIsConnected(e){this._isConnected=e,v.notify(this,"isConnected")}get template(){var e;if(null===this._template){const t=this.definition;this.source.resolveTemplate?this._template=this.source.resolveTemplate():t.template&&(this._template=null!==(e=t.template)&&void 0!==e?e:null)}return this._template}set template(e){this._template!==e&&(this._template=e,this.needsInitialization||this.renderTemplate(e))}get mainStyles(){var e;if(null===this._mainStyles){const t=this.definition;this.source.resolveStyles?this._mainStyles=this.source.resolveStyles():t.styles&&(this._mainStyles=null!==(e=t.styles)&&void 0!==e?e:null)}return this._mainStyles}set mainStyles(e){this._mainStyles!==e&&(null!==this._mainStyles&&this.removeStyles(this._mainStyles),this._mainStyles=e,this.needsInitialization||this.addStyles(e))}addBehavior(e){var t,s;const i=null!==(t=this.behaviors)&&void 0!==t?t:this.behaviors=new Map,n=null!==(s=i.get(e))&&void 0!==s?s:0;0===n?(i.set(e,1),e.addedCallback&&e.addedCallback(this),e.connectedCallback&&this.isConnected&&e.connectedCallback(this)):i.set(e,n+1)}removeBehavior(e,t=!1){const s=this.behaviors;if(null===s)return;const i=s.get(e);void 0!==i&&(1===i||t?(s.delete(e),e.disconnectedCallback&&this.isConnected&&e.disconnectedCallback(this),e.removedCallback&&e.removedCallback(this)):s.set(e,i-1))}addStyles(e){var t;if(!e)return;const s=this.source,i=null!==(t=gt(s))&&void 0!==t?t:s.getRootNode();if(e instanceof HTMLElement)i.append(e);else if(!e.isAttachedTo(i)){const t=e.behaviors;if(e.addStylesTo(i),null!==t)for(let e=0,s=t.length;e<s;++e)this.addBehavior(t[e])}}removeStyles(e){var t;if(!e)return;const s=this.source,i=null!==(t=gt(s))&&void 0!==t?t:s.getRootNode();if(e instanceof HTMLElement)i.removeChild(e);else if(e.isAttachedTo(i)){const t=e.behaviors;if(e.removeStylesFrom(i),null!==t)for(let e=0,s=t.length;e<s;++e)this.addBehavior(t[e])}}connect(){if(this._isConnected)return;this.needsInitialization?this.finishInitialization():null!==this.view&&this.view.bind(this.source);const e=this.behaviors;if(null!==e)for(const t of e.keys())t.connectedCallback&&t.connectedCallback(this);this.setIsConnected(!0)}disconnect(){if(!this._isConnected)return;this.setIsConnected(!1),null!==this.view&&this.view.unbind();const e=this.behaviors;if(null!==e)for(const t of e.keys())t.disconnectedCallback&&t.disconnectedCallback(this)}onAttributeChangedCallback(e,t,s){const i=this.definition.attributeLookup[e];void 0!==i&&i.onAttributeChangedCallback(this.source,s)}emit(e,t,s){return!!this._isConnected&&this.source.dispatchEvent(new CustomEvent(e,Object.assign(Object.assign({detail:t},ft),s)))}finishInitialization(){const e=this.source,t=this.boundObservables;if(null!==t){const s=Object.keys(t);for(let i=0,n=s.length;i<n;++i){const n=s[i];e[n]=t[n]}this.boundObservables=null}this.renderTemplate(this.template),this.addStyles(this.mainStyles),this.needsInitialization=!1}renderTemplate(e){var t;const s=this.source,i=null!==(t=gt(s))&&void 0!==t?t:s;if(null!==this.view)this.view.dispose(),this.view=null;else if(!this.needsInitialization||this.hasExistingShadowRoot){this.hasExistingShadowRoot=!1;for(let e=i.firstChild;null!==e;e=i.firstChild)i.removeChild(e)}e&&(this.view=e.render(s,i,s),this.view.sourceLifetime=b.coupled)}static forCustomElement(e){const t=e.$fastController;if(void 0!==t)return t;const s=ut.getForInstance(e);if(void 0===s)throw l.error(1401);return e.$fastController=new bt(e,s)}}function vt(e){const t=class extends e{constructor(){super(),bt.forCustomElement(this)}$emit(e,t,s){return this.$fastController.emit(e,t,s)}connectedCallback(){this.$fastController.connect()}disconnectedCallback(){this.$fastController.disconnect()}attributeChangedCallback(e,t,s){this.$fastController.onAttributeChangedCallback(e,t,s)}};return ut.registerBaseType(t),t}function yt(e,t){return d(e)?ut.compose(e,t).define().type:ut.compose(this,e).define().type}const mt=Object.assign(vt(HTMLElement),{from:function(e){return vt(e)},define:yt,compose:function(e,t){return d(e)?ut.compose(e,t):ut.compose(this,e)}});function wt(e){return function(t){yt(t,e)}}export{M as AdoptedStyleSheetsStrategy,E as ArrayObserver,le as Aspect,st as AttributeConfiguration,ot as AttributeDefinition,oe as Binding,R as CSSDirective,et as ChildrenDirective,_e as Compiler,W as DOM,bt as ElementController,L as ElementStyles,C as ExecutionContext,l as FAST,mt as FASTElement,ut as FASTElementDefinition,be as HTMLBindingDirective,ne as HTMLDirective,xe as HTMLView,ee as Markup,Xe as NodeObservationDirective,v as Observable,te as Parser,g as PropertyChangeNotifier,Pe as RefDirective,Qe as RepeatBehavior,We as RepeatDirective,Ye as SlottedDirective,b as SourceLifetime,x as Splice,j as SpliceStrategy,S as SpliceStrategySupport,ae as StatelessAttachedAttributeDirective,p as SubscriberSet,f as Updates,se as ViewBehaviorOrchestrator,ze as ViewTemplate,lt as attr,ve as bind,it as booleanConverter,tt as children,c as createMetadataLocator,h as createTypeRegistry,U as css,D as cssDirective,Q as cssPartial,wt as customElement,Ke as elements,a as emptyArray,Me as html,re as htmlDirective,N as lengthOf,me as listener,we as normalizeBinding,rt as nullableNumberConverter,y as observable,ye as oneTime,Re as ref,Ge as repeat,Ze as slotted,m as volatile,De as when};
1
+ !function(){if("undefined"==typeof globalThis)if("undefined"!=typeof global)global.globalThis=global;else if("undefined"!=typeof self)self.globalThis=self;else if("undefined"!=typeof window)window.globalThis=window;else{const e=new Function("return this")();e.globalThis=e}}(),globalThis.trustedTypes||(globalThis.trustedTypes={createPolicy:(e,t)=>t});const e={configurable:!1,enumerable:!1,writable:!1};void 0===globalThis.FAST&&Reflect.defineProperty(globalThis,"FAST",Object.assign({value:Object.create(null)},e));const t=globalThis.FAST;if(void 0===t.getById){const s=Object.create(null);Reflect.defineProperty(t,"getById",Object.assign({value(e,t){let i=s[e];return void 0===i&&(i=t?s[e]=t():null),i}},e))}void 0===t.error&&Object.assign(t,{warn(){},error:e=>new Error(`Error ${e}`),addMessages(){}});const s=Object.freeze([]);function i(){const e=new Map;return Object.freeze({register:t=>!e.has(t.type)&&(e.set(t.type,t),!0),getByType:t=>e.get(t),getForInstance(t){if(null!=t)return e.get(t.constructor)}})}function n(){const e=new WeakMap;return function(t){let s=e.get(t);if(void 0===s){let i=Reflect.getPrototypeOf(t);for(;void 0===s&&null!==i;)s=e.get(i),i=Reflect.getPrototypeOf(i);s=void 0===s?[]:s.slice(0),e.set(t,s)}return s}}const r=e=>"function"==typeof e,o=e=>"string"==typeof e,l=t.getById(1,(()=>{const e=[],t=[],s=globalThis.requestAnimationFrame;let i=!0;function n(){if(t.length)throw t.shift()}function r(s){try{s.call()}catch(s){if(!i)throw e.length=0,s;t.push(s),setTimeout(n,0)}}function o(){let t=0;for(;t<e.length;)if(r(e[t]),t++,t>1024){for(let s=0,i=e.length-t;s<i;s++)e[s]=e[s+t];e.length-=t,t=0}e.length=0}function l(t){e.push(t),e.length<2&&(i?s(o):o())}return Object.freeze({enqueue:l,next:()=>new Promise(l),process:o,setMode:e=>i=e})}));class h{constructor(e,t){this.sub1=void 0,this.sub2=void 0,this.spillover=void 0,this.subject=e,this.sub1=t}has(e){return void 0===this.spillover?this.sub1===e||this.sub2===e:-1!==this.spillover.indexOf(e)}subscribe(e){const t=this.spillover;if(void 0===t){if(this.has(e))return;if(void 0===this.sub1)return void(this.sub1=e);if(void 0===this.sub2)return void(this.sub2=e);this.spillover=[this.sub1,this.sub2,e],this.sub1=void 0,this.sub2=void 0}else{-1===t.indexOf(e)&&t.push(e)}}unsubscribe(e){const t=this.spillover;if(void 0===t)this.sub1===e?this.sub1=void 0:this.sub2===e&&(this.sub2=void 0);else{const s=t.indexOf(e);-1!==s&&t.splice(s,1)}}notify(e){const t=this.spillover,s=this.subject;if(void 0===t){const t=this.sub1,i=this.sub2;void 0!==t&&t.handleChange(s,e),void 0!==i&&i.handleChange(s,e)}else for(let i=0,n=t.length;i<n;++i)t[i].handleChange(s,e)}}class a{constructor(e){this.subscribers={},this.subjectSubscribers=null,this.subject=e}notify(e){var t,s;null===(t=this.subscribers[e])||void 0===t||t.notify(e),null===(s=this.subjectSubscribers)||void 0===s||s.notify(e)}subscribe(e,t){var s,i;let n;n=t?null!==(s=this.subscribers[t])&&void 0!==s?s:this.subscribers[t]=new h(this.subject):null!==(i=this.subjectSubscribers)&&void 0!==i?i:this.subjectSubscribers=new h(this.subject),n.subscribe(e)}unsubscribe(e,t){var s,i;t?null===(s=this.subscribers[t])||void 0===s||s.unsubscribe(e):null===(i=this.subjectSubscribers)||void 0===i||i.unsubscribe(e)}}const c=Object.freeze({unknown:void 0,coupled:1}),d=t.getById(2,(()=>{const e=l.enqueue,s=/(:|&&|\|\||if)/,i=new WeakMap;let d,u=e=>{throw t.error(1101)};function f(e){var t;let s=null!==(t=e.$fastController)&&void 0!==t?t:i.get(e);return void 0===s&&(Array.isArray(e)?s=u(e):i.set(e,s=new a(e))),s}const p=n();class b{constructor(e){this.name=e,this.field=`_${e}`,this.callback=`${e}Changed`}getValue(e){return void 0!==d&&d.watch(e,this.name),e[this.field]}setValue(e,t){const s=this.field,i=e[s];if(i!==t){e[s]=t;const n=e[this.callback];r(n)&&n.call(e,i,t),f(e).notify(this.name)}}}class g extends h{constructor(e,t,s=!1){super(e,t),this.expression=e,this.isVolatileBinding=s,this.needsRefresh=!0,this.needsQueue=!0,this.isAsync=!0,this.first=this,this.last=null,this.propertySource=void 0,this.propertyName=void 0,this.notifier=void 0,this.next=void 0}setMode(e){this.isAsync=this.needsQueue=e}bind(e){this.controller=e;const t=this.observe(e.source,e.context);return!e.isBound&&this.requiresUnbind(e)&&e.onUnbind(this),t}requiresUnbind(e){return e.sourceLifetime!==c.coupled||this.first!==this.last||this.first.propertySource!==e.source}unbind(e){this.dispose()}observe(e,t){this.needsRefresh&&null!==this.last&&this.dispose();const s=d;let i;d=this.needsRefresh?this:void 0,this.needsRefresh=this.isVolatileBinding;try{i=this.expression(e,t)}finally{d=s}return i}disconnect(){this.dispose()}dispose(){if(null!==this.last){let e=this.first;for(;void 0!==e;)e.notifier.unsubscribe(this,e.propertyName),e=e.next;this.last=null,this.needsRefresh=this.needsQueue=this.isAsync}}watch(e,t){const s=this.last,i=f(e),n=null===s?this.first:{};if(n.propertySource=e,n.propertyName=t,n.notifier=i,i.subscribe(this,t),null!==s){if(!this.needsRefresh){let t;d=void 0,t=s.propertySource[s.propertyName],d=this,e===t&&(this.needsRefresh=!0)}s.next=n}this.last=n}handleChange(){this.needsQueue?(this.needsQueue=!1,e(this)):this.isAsync||this.call()}call(){null!==this.last&&(this.needsQueue=this.isAsync,this.notify(this))}*records(){let e=this.first;for(;void 0!==e;)yield e,e=e.next}}return Object.freeze({setArrayObserverFactory(e){u=e},getNotifier:f,track(e,t){d&&d.watch(e,t)},trackVolatile(){d&&(d.needsRefresh=!0)},notify(e,t){f(e).notify(t)},defineProperty(e,t){o(t)&&(t=new b(t)),p(e).push(t),Reflect.defineProperty(e,t.name,{enumerable:!0,get(){return t.getValue(this)},set(e){t.setValue(this,e)}})},getAccessors:p,binding(e,t,s=this.isVolatileBinding(e)){return new g(e,t,s)},isVolatileBinding:e=>s.test(e.toString())})}));function u(e,t){d.defineProperty(e,t)}function f(e,t,s){return Object.assign({},s,{get(){return d.trackVolatile(),s.get.apply(this)}})}const p=t.getById(3,(()=>{let e=null;return{get:()=>e,set(t){e=t}}})),b=Object.freeze({default:{index:0,length:0,get event(){return b.getEvent()},eventDetail(){return this.event.detail},eventTarget(){return this.event.target}},getEvent:()=>p.get(),setEvent(e){p.set(e)}});class g{constructor(e,t,s){this.index=e,this.removed=t,this.addedCount=s}adjustTo(e){let t=this.index;const s=e.length;return t>s?t=s-this.addedCount:t<0&&(t=s+this.removed.length+t-this.addedCount),this.index=t<0?0:t,this}}const v=Object.freeze({reset:1,splice:2,optimized:3}),y=new g(0,s,0);y.reset=!0;const m=[y];function w(e,t,i,n,r,o){let l=0,h=0;const a=Math.min(i-t,o-r);if(0===t&&0===r&&(l=function(e,t,s){for(let i=0;i<s;++i)if(e[i]!==t[i])return i;return s}(e,n,a)),i===e.length&&o===n.length&&(h=function(e,t,s){let i=e.length,n=t.length,r=0;for(;r<s&&e[--i]===t[--n];)r++;return r}(e,n,a-l)),r+=l,o-=h,(i-=h)-(t+=l)==0&&o-r==0)return s;if(t===i){const e=new g(t,[],0);for(;r<o;)e.removed.push(n[r++]);return[e]}if(r===o)return[new g(t,[],i-t)];const c=function(e){let t=e.length-1,s=e[0].length-1,i=e[t][s];const n=[];for(;t>0||s>0;){if(0===t){n.push(2),s--;continue}if(0===s){n.push(3),t--;continue}const r=e[t-1][s-1],o=e[t-1][s],l=e[t][s-1];let h;h=o<l?o<r?o:r:l<r?l:r,h===r?(r===i?n.push(0):(n.push(1),i=r),t--,s--):h===o?(n.push(3),t--,i=o):(n.push(2),s--,i=l)}return n.reverse()}(function(e,t,s,i,n,r){const o=r-n+1,l=s-t+1,h=new Array(o);let a,c;for(let e=0;e<o;++e)h[e]=new Array(l),h[e][0]=e;for(let e=0;e<l;++e)h[0][e]=e;for(let s=1;s<o;++s)for(let r=1;r<l;++r)e[t+r-1]===i[n+s-1]?h[s][r]=h[s-1][r-1]:(a=h[s-1][r]+1,c=h[s][r-1]+1,h[s][r]=a<c?a:c);return h}(e,t,i,n,r,o)),d=[];let u,f=t,p=r;for(let e=0;e<c.length;++e)switch(c[e]){case 0:void 0!==u&&(d.push(u),u=void 0),f++,p++;break;case 1:void 0===u&&(u=new g(f,[],0)),u.addedCount++,f++,u.removed.push(n[p]),p++;break;case 2:void 0===u&&(u=new g(f,[],0)),u.addedCount++,f++;break;case 3:void 0===u&&(u=new g(f,[],0)),u.removed.push(n[p]),p++}return void 0!==u&&d.push(u),d}function C(e,t){let s=!1,i=0;for(let h=0;h<t.length;h++){const a=t[h];if(a.index+=i,s)continue;const c=(n=e.index,r=e.index+e.removed.length,o=a.index,l=a.index+a.addedCount,r<o||l<n?-1:r===o||l===n?0:n<o?r<l?r-o:l-o:l<r?l-n:r-n);if(c>=0){t.splice(h,1),h--,i-=a.addedCount-a.removed.length,e.addedCount+=a.addedCount-c;const n=e.removed.length+a.removed.length-c;if(e.addedCount||n){let t=a.removed;if(e.index<a.index){const s=e.removed.slice(0,a.index-e.index);s.push(...t),t=s}if(e.index+e.removed.length>a.index+a.addedCount){const s=e.removed.slice(a.index+a.addedCount-e.index);t.push(...s)}e.removed=t,a.index<e.index&&(e.index=a.index)}else s=!0}else if(e.index<a.index){s=!0,t.splice(h,0,e),h++;const n=e.addedCount-e.removed.length;a.index+=n,i+=n}}var n,r,o,l;s||t.push(e)}let x=Object.freeze({support:v.optimized,normalize:(e,t,i)=>void 0===e?void 0===i?s:i.length>1?function(e,t){let s=[];const i=[];for(let e=0,s=t.length;e<s;e++)C(t[e],i);for(let t=0,n=i.length;t<n;++t){const n=i[t];1!==n.addedCount||1!==n.removed.length?s=s.concat(w(e,n.index,n.index+n.addedCount,n.removed,0,n.removed.length)):n.removed[0]!==e[n.index]&&s.push(n)}return s}(t,i):i:m,pop(e,t,s,i){const n=e.length>0,r=s.apply(e,i);return n&&t.addSplice(new g(e.length,[r],0)),r},push(e,t,s,i){const n=s.apply(e,i);return t.addSplice(new g(e.length-i.length,[],i.length).adjustTo(e)),n},reverse(e,t,s,i){const n=s.apply(e,i);return t.reset(e),n},shift(e,t,s,i){const n=e.length>0,r=s.apply(e,i);return n&&t.addSplice(new g(0,[r],0)),r},sort(e,t,s,i){const n=s.apply(e,i);return t.reset(e),n},splice(e,t,s,i){const n=s.apply(e,i);return t.addSplice(new g(+i[0],n,i.length>2?i.length-2:0).adjustTo(e)),n},unshift(e,t,s,i){const n=s.apply(e,i);return t.addSplice(new g(0,[],i.length).adjustTo(e)),n}});const S=Object.freeze({reset:m,setDefaultStrategy(e){x=e}});function T(e,t,s){Reflect.defineProperty(e,t,{value:s,enumerable:!1})}class O extends h{constructor(e){super(e),this.oldCollection=void 0,this.splices=void 0,this.needsQueue=!0,this._strategy=null,this._lengthObserver=void 0,this.call=this.flush,T(e,"$fastController",this)}get strategy(){return this._strategy}set strategy(e){this._strategy=e}get lengthObserver(){let e=this._lengthObserver;if(void 0===e){const t=this.subject;this._lengthObserver=e={length:t.length,handleChange(){this.length!==t.length&&(this.length=t.length,d.notify(e,"length"))}},this.subscribe(e)}return e}subscribe(e){this.flush(),super.subscribe(e)}addSplice(e){void 0===this.splices?this.splices=[e]:this.splices.push(e),this.enqueue()}reset(e){this.oldCollection=e,this.enqueue()}flush(){var e;const t=this.splices,s=this.oldCollection;void 0===t&&void 0===s||(this.needsQueue=!0,this.splices=void 0,this.oldCollection=void 0,this.notify((null!==(e=this._strategy)&&void 0!==e?e:x).normalize(s,this.subject,t)))}enqueue(){this.needsQueue&&(this.needsQueue=!1,l.enqueue(this))}}let B=!1;const A=Object.freeze({enable(){if(B)return;B=!0,d.setArrayObserverFactory((e=>new O(e)));const e=Array.prototype;e.$fastPatch||(T(e,"$fastPatch",1),[e.pop,e.push,e.reverse,e.shift,e.sort,e.splice,e.unshift].forEach((t=>{e[t.name]=function(...e){var s;const i=this.$fastController;return void 0===i?t.apply(this,e):(null!==(s=i.strategy)&&void 0!==s?s:x)[t.name](this,i,t,e)}})))}});function k(e){if(!e)return 0;let t=e.$fastController;return void 0===t&&(A.enable(),t=d.getNotifier(e)),d.track(t.lengthObserver,"length"),e.length}let j;function $(e){return e.map((e=>e instanceof I?$(e.styles):[e])).reduce(((e,t)=>e.concat(t)),[])}class I{constructor(e){this.styles=e,this.targets=new WeakSet,this._strategy=null,this.behaviors=e.map((e=>e instanceof I?e.behaviors:null)).reduce(((e,t)=>null===t?e:null===e?t:e.concat(t)),null)}get strategy(){return null===this._strategy&&this.withStrategy(j),this._strategy}addStylesTo(e){this.strategy.addStylesTo(e),this.targets.add(e)}removeStylesFrom(e){this.strategy.removeStylesFrom(e),this.targets.delete(e)}isAttachedTo(e){return this.targets.has(e)}withBehaviors(...e){return this.behaviors=null===this.behaviors?e:this.behaviors.concat(e),this}withStrategy(e){return this._strategy=new e($(this.styles)),this}static setDefaultStrategy(e){j=e}static normalize(e){return void 0===e?void 0:Array.isArray(e)?new I(e):e instanceof I?e:new I([e])}}I.supportsAdoptedStyleSheets=Array.isArray(document.adoptedStyleSheets)&&"replace"in CSSStyleSheet.prototype;const V=i(),E=Object.freeze({getForInstance:V.getForInstance,getByType:V.getByType,define:e=>(V.register({type:e}),e)});function N(){return function(e){E.define(e)}}function _(e,t){const s=[];let i="";const n=[],r=e=>{n.push(e)};for(let n=0,o=e.length-1;n<o;++n){i+=e[n];let o=t[n];void 0!==E.getForInstance(o)&&(o=o.createCSS(r)),o instanceof I||o instanceof CSSStyleSheet?(""!==i.trim()&&(s.push(i),i=""),s.push(o)):i+=o}return i+=e[e.length-1],""!==i.trim()&&s.push(i),{styles:s,behaviors:n}}const z=(e,...t)=>{const{styles:s,behaviors:i}=_(e,t),n=new I(s);return i.length?n.withBehaviors(...i):n};class L{constructor(e,t){this.behaviors=t,this.css="";const s=e.reduce(((e,t)=>(o(t)?this.css+=t:e.push(t),e)),[]);s.length&&(this.styles=new I(s))}createCSS(e){return this.behaviors.forEach(e),this.styles&&e(this),this.css}addedCallback(e){e.addStyles(this.styles)}removedCallback(e){e.removeStyles(this.styles)}}E.define(L);const F=z.partial=(e,...t)=>{const{styles:s,behaviors:i}=_(e,t);return new L(s,i)},M=Object.freeze({queueUpdate:l.enqueue,nextUpdate:l.next,processUpdates:l.process,setAttribute(e,t,s){null==s?e.removeAttribute(t):e.setAttribute(t,s)},setBooleanAttribute(e,t,s){s?e.setAttribute(t,""):e.removeAttribute(t)}}),P=`fast-${Math.random().toString(36).substring(2,8)}`,R=`${P}{`,D=`}${P}`,H=D.length;let U=0;const q=()=>`${P}-${++U}`,Q=Object.freeze({interpolation:e=>`${R}${e}${D}`,attribute:e=>`${q()}="${R}${e}${D}"`,comment:e=>`\x3c!--${R}${e}${D}--\x3e`}),W=Object.freeze({parse(e,t){const s=e.split(R);if(1===s.length)return null;const i=[];for(let e=0,n=s.length;e<n;++e){const n=s[e],r=n.indexOf(D);let o;if(-1===r)o=n;else{const e=n.substring(0,r);i.push(t[e]),o=n.substring(r+H)}""!==o&&i.push(o)}return i}}),G=Object.freeze({create(e){const t=[],s={};let i=null,n=!1;return{source:e,context:b.default,targets:s,get isBound(){return n},addBehaviorFactory(e,t){const s=e.nodeId||(e.nodeId=q());e.id||(e.id=q()),this.addTarget(s,t),this.addBehavior(e.createBehavior())},addTarget(e,t){s[e]=t},addBehavior(e){t.push(e),n&&e.bind(this)},onUnbind(e){null===i&&(i=[]),i.push(e)},connectedCallback(e){n||(n=!0,t.forEach((e=>e.bind(this))))},disconnectedCallback(e){n&&(n=!1,null!==i&&i.forEach((e=>e.unbind(this))))}}}}),J=i(),K=Object.freeze({getForInstance:J.getForInstance,getByType:J.getByType,define:(e,t)=>((t=t||{}).type=e,J.register(t),e)});function X(e){return function(t){K.define(t,e)}}class Y{constructor(e,t=!1){this.evaluate=e,this.isVolatile=t}}const Z=Object.freeze({none:0,attribute:1,booleanAttribute:2,property:3,content:4,tokenList:5,event:6,assign(e,t){if(t)switch(e.sourceAspect=t,t[0]){case":":e.targetAspect=t.substring(1),e.aspectType="classList"===e.targetAspect?Z.tokenList:Z.property;break;case"?":e.targetAspect=t.substring(1),e.aspectType=Z.booleanAttribute;break;case"@":e.targetAspect=t.substring(1),e.aspectType=Z.event;break;default:e.targetAspect=t,e.aspectType=Z.attribute}else e.aspectType=Z.content}});class ee{constructor(e){this.options=e,this.id=q()}createHTML(e){return Q.attribute(e(this))}createBehavior(){return this}}const te=globalThis.TrustedHTML?e=>(s,i)=>{const n=e(s,i);if(n instanceof TrustedHTML)return n;throw t.error(1202)}:e=>e;class se extends Y{createObserver(e,t){return d.binding(this.evaluate,t,this.isVolatile)}}class ie extends Y{createObserver(){return this}bind(e){return this.evaluate(e.source,e.context)}}function ne(e,t,s,i){if(null==s&&(s=""),s.create){e.textContent="";let t=e.$fastView;void 0===t?t=s.create():e.$fastTemplate!==s&&(t.isComposed&&(t.remove(),t.unbind()),t=s.create()),t.isComposed?t.needsBindOnly&&(t.needsBindOnly=!1,t.bind(i.source,i.context)):(t.isComposed=!0,t.bind(i.source,i.context),t.insertBefore(e),e.$fastView=t,e.$fastTemplate=s)}else{const t=e.$fastView;void 0!==t&&t.isComposed&&(t.isComposed=!1,t.remove(),t.needsBindOnly?t.needsBindOnly=!1:t.unbind()),e.textContent=s}}function re(e,t,s){var i;const n=`${this.id}-t`,r=null!==(i=e[n])&&void 0!==i?i:e[n]={c:0,v:Object.create(null)},o=r.v;let l=r.c;const h=e[t];if(null!=s&&s.length){const e=s.split(/\s+/);for(let t=0,s=e.length;t<s;++t){const s=e[t];""!==s&&(o[s]=l,h.add(s))}}if(r.v=l+1,0!==l){l-=1;for(const e in o)o[e]===l&&h.remove(e)}}const oe=(e,t,s)=>e[t]=s,le=()=>{};class he{constructor(e){this.dataBinding=e,this.updateTarget=null,this.id=q(),this.aspectType=Z.content,this.bind=this.bindDefault,this.data=`${this.id}-d`}createHTML(e){return Q.interpolation(e(this))}createBehavior(){if(null===this.updateTarget)switch("innerHTML"===this.targetAspect&&(this.dataBinding.evaluate=te(this.dataBinding.evaluate)),this.aspectType){case 1:this.updateTarget=M.setAttribute;break;case 2:this.updateTarget=M.setBooleanAttribute;break;case 3:this.updateTarget=oe;break;case 4:this.bind=this.bindContent,this.updateTarget=ne;break;case 5:this.updateTarget=re;break;case 6:this.bind=this.bindEvent,this.updateTarget=le;break;default:throw t.error(1205)}return this}bindDefault(e){var t;const s=e.targets[this.nodeId],i=null!==(t=s[this.data])&&void 0!==t?t:s[this.data]=this.dataBinding.createObserver(this,this);i.target=s,i.controller=e,this.updateTarget(s,this.targetAspect,i.bind(e),e),this.updateTarget===ne&&e.onUnbind(this)}bindContent(e){this.bindDefault(e),e.onUnbind(this)}bindEvent(e){const t=e.targets[this.nodeId];t[this.data]=e,t.addEventListener(this.targetAspect,this,this.dataBinding.options)}unbind(e){const t=e.targets[this.nodeId].$fastView;void 0!==t&&t.isComposed&&(t.unbind(),t.needsBindOnly=!0)}handleEvent(e){const t=e.currentTarget;b.setEvent(e);const s=t[this.data],i=this.dataBinding.evaluate(s.source,s.context);b.setEvent(null),!0!==i&&e.preventDefault()}handleChange(e,t){const s=t.target,i=t.controller;this.updateTarget(s,this.targetAspect,t.bind(i),i)}}function ae(e,t=d.isVolatileBinding(e)){return new se(e,t)}function ce(e){return new ie(e)}function de(e,t){const s=new se(e,!1);return s.options=t,s}function ue(e){return r(e)?ae(e):e instanceof Y?e:ce((()=>e))}function fe(e,t){const s=e.parentNode;let i,n=e;for(;n!==t;)i=n.nextSibling,s.removeChild(n),n=i;s.removeChild(t)}K.define(he,{aspected:!0});class pe{constructor(e,t,s){this.fragment=e,this.factories=t,this.targets=s,this.behaviors=null,this.unbindables=[],this.source=null,this.isBound=!1,this.sourceLifetime=c.unknown,this.context=this,this.index=0,this.length=0,this.firstChild=e.firstChild,this.lastChild=e.lastChild}get event(){return b.getEvent()}get isEven(){return this.index%2==0}get isOdd(){return this.index%2!=0}get isFirst(){return 0===this.index}get isInMiddle(){return!this.isFirst&&!this.isLast}get isLast(){return this.index===this.length-1}eventDetail(){return this.event.detail}eventTarget(){return this.event.target}appendTo(e){e.appendChild(this.fragment)}insertBefore(e){if(this.fragment.hasChildNodes())e.parentNode.insertBefore(this.fragment,e);else{const t=this.lastChild;if(e.previousSibling===t)return;const s=e.parentNode;let i,n=this.firstChild;for(;n!==t;)i=n.nextSibling,s.insertBefore(n,e),n=i;s.insertBefore(t,e)}}remove(){const e=this.fragment,t=this.lastChild;let s,i=this.firstChild;for(;i!==t;)s=i.nextSibling,e.appendChild(i),i=s;e.appendChild(t)}dispose(){fe(this.firstChild,this.lastChild),this.unbind()}onUnbind(e){this.unbindables.push(e)}bind(e,t=this){if(this.source===e)return;let s=this.behaviors;if(null===s){this.source=e,this.context=t,this.behaviors=s=new Array(this.factories.length);const i=this.factories;for(let e=0,t=i.length;e<t;++e){const t=i[e].createBehavior();t.bind(this),s[e]=t}}else{null!==this.source&&this.evaluateUnbindables(),this.isBound=!1,this.source=e,this.context=t;for(let e=0,t=s.length;e<t;++e)s[e].bind(this)}this.isBound=!0}unbind(){this.isBound&&null!==this.source&&(this.evaluateUnbindables(),this.source=null,this.context=this,this.isBound=!1)}evaluateUnbindables(){const e=this.unbindables;for(let t=0,s=e.length;t<s;++t)e[t].unbind(this);e.length=0}static disposeContiguousBatch(e){if(0!==e.length){fe(e[0].firstChild,e[e.length-1].lastChild);for(let t=0,s=e.length;t<s;++t)e[t].unbind()}}}d.defineProperty(pe.prototype,"index"),d.defineProperty(pe.prototype,"length");const be=(e,t)=>`${e}.${t}`,ge={},ve={index:0,node:null};function ye(e){e.startsWith("fast-")||t.warn(1204,{name:e})}const me=new Proxy(document.createElement("div"),{get(e,t){ye(t);const s=Reflect.get(e,t);return r(s)?s.bind(e):s},set:(e,t,s)=>(ye(t),Reflect.set(e,t,s))});class we{constructor(e,t){this.fragment=e,this.directives=t,this.proto=null,this.nodeIds=new Set,this.descriptors={},this.factories=[]}addFactory(e,t,s,i){this.nodeIds.has(s)||(this.nodeIds.add(s),this.addTargetDescriptor(t,s,i)),e.nodeId=s,this.factories.push(e)}freeze(){return this.proto=Object.create(null,this.descriptors),this}addTargetDescriptor(e,t,s){const i=this.descriptors;if("r"===t||"h"===t||i[t])return;if(!i[e]){const t=e.lastIndexOf("."),s=e.substring(0,t),i=parseInt(e.substring(t+1));this.addTargetDescriptor(s,e,i)}let n=ge[t];if(!n){const i=`_${t}`;ge[t]=n={get(){var t;return null!==(t=this[i])&&void 0!==t?t:this[i]=this[e].childNodes[s]}}}i[t]=n}createView(e){const t=this.fragment.cloneNode(!0),s=Object.create(this.proto);s.r=t,s.h=null!=e?e:me;for(const e of this.nodeIds)s[e];return new pe(t,this.factories,s)}}function Ce(e,t,s,i,n,r=!1){const o=s.attributes,l=e.directives;for(let h=0,a=o.length;h<a;++h){const c=o[h],d=c.value,u=W.parse(d,l);let f=null;null===u?r&&(f=new he(ce((()=>d))),Z.assign(f,c.name)):f=Ae.aggregate(u),null!==f&&(s.removeAttributeNode(c),h--,a--,e.addFactory(f,t,i,n))}}function xe(e,t,s){let i=0,n=t.firstChild;for(;n;){const t=Se(e,s,n,i);n=t.node,i=t.index}}function Se(e,t,s,i){const n=be(t,i);switch(s.nodeType){case 1:Ce(e,t,s,n,i),xe(e,s,n);break;case 3:return function(e,t,s,i,n){const r=W.parse(t.textContent,e.directives);if(null===r)return ve.node=t.nextSibling,ve.index=n+1,ve;let l,h=l=t;for(let t=0,a=r.length;t<a;++t){const a=r[t];0!==t&&(n++,i=be(s,n),l=h.parentNode.insertBefore(document.createTextNode(""),h.nextSibling)),o(a)?l.textContent=a:(l.textContent=" ",Z.assign(a),e.addFactory(a,s,i,n)),h=l}return ve.index=n+1,ve.node=h.nextSibling,ve}(e,s,t,n,i);case 8:const r=W.parse(s.data,e.directives);null!==r&&e.addFactory(Ae.aggregate(r),t,n,i)}return ve.index=i+1,ve.node=s.nextSibling,ve}const Te={createHTML:e=>e};let Oe=globalThis.trustedTypes?globalThis.trustedTypes.createPolicy("fast-html",Te):Te;const Be=Oe,Ae={setHTMLPolicy(e){if(Oe!==Be)throw t.error(1201);Oe=e},compile(e,t){let s;if(o(e)){s=document.createElement("TEMPLATE"),s.innerHTML=Oe.createHTML(e);const t=s.content.firstElementChild;null!==t&&"TEMPLATE"===t.tagName&&(s=t)}else s=e;const i=document.adoptNode(s.content),n=new we(i,t);return Ce(n,"",s,"h",0,!0),(function(e,t){return e&&8==e.nodeType&&null!==W.parse(e.data,t)}(i.firstChild,t)||1===i.childNodes.length&&Object.keys(t).length>0)&&i.insertBefore(document.createComment(""),i.firstChild),xe(n,i,"r"),ve.node=null,n.freeze()},setDefaultStrategy(e){this.compile=e},aggregate(e){if(1===e.length)return e[0];let t,s,i=!1;const n=e.length,r=e.map((e=>o(e)?()=>e:(t=e.sourceAspect||t,s=e.dataBinding||s,i=i||e.dataBinding.isVolatile,e.dataBinding.evaluate)));s.evaluate=(e,t)=>{let s="";for(let i=0;i<n;++i)s+=r[i](e,t);return s},s.isVolatile=i;const l=new he(s);return Z.assign(l,t),l}};class ke{constructor(e,t){this.result=null,this.html=e,this.factories=t}create(e){return null===this.result&&(this.result=Ae.compile(this.html,this.factories)),this.result.createView(e)}render(e,t,s){const i=this.create(s);return i.bind(e),i.appendTo(t),i}}const je=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function $e(e,t,s){const i=je.exec(t);return null!==i&&Z.assign(e,i[2]),e.createHTML(s)}function Ie(e,...t){let s="";const i=Object.create(null),n=e=>{var t;const s=null!==(t=e.id)&&void 0!==t?t:e.id=q();return i[s]=e,s};for(let i=0,l=e.length-1;i<l;++i){const l=e[i],h=t[i];let a;if(s+=l,r(h))s+=$e(new he(ae(h)),l,n);else if(o(h)){const e=je.exec(l);if(null!==e){const t=new he(ce((()=>h)));Z.assign(t,e[2]),s+=t.createHTML(n)}else s+=h}else h instanceof Y?s+=$e(new he(h),l,n):void 0===(a=K.getForInstance(h))?s+=$e(new he(ce((()=>h))),l,n):a.aspected?s+=$e(h,l,n):s+=h.createHTML(n)}return new ke(s+e[e.length-1],i)}class Ve extends ee{bind(e){e.source[this.options]=e.targets[this.nodeId]}}K.define(Ve);const Ee=e=>new Ve(e);function Ne(e,t){const s=r(e)?e:()=>e,i=r(t)?t:()=>t;return(e,t)=>s(e,t)?i(e,t):null}const _e=Object.freeze({positioning:!1,recycle:!0});function ze(e,t,s,i){e.context.parent=i.source,e.context.parentContext=i.context,e.bind(t[s])}function Le(e,t,s,i){e.context.parent=i.source,e.context.parentContext=i.context,e.context.length=t.length,e.context.index=s,e.bind(t[s])}class Fe{constructor(e){this.directive=e,this.items=null,this.itemsObserver=null,this.bindView=ze,this.views=[],this.itemsBindingObserver=e.dataBinding.createObserver(e,this),this.templateBindingObserver=e.templateBinding.createObserver(e,this),e.options.positioning&&(this.bindView=Le)}bind(e){this.location=e.targets[this.directive.nodeId],this.controller=e,this.items=this.itemsBindingObserver.bind(e),this.template=this.templateBindingObserver.bind(e),this.observeItems(!0),this.refreshAllViews(),e.onUnbind(this)}unbind(){null!==this.itemsObserver&&this.itemsObserver.unsubscribe(this),this.unbindAllViews()}handleChange(e,t){if(t===this.itemsBindingObserver)this.items=this.itemsBindingObserver.bind(this.controller),this.observeItems(),this.refreshAllViews();else if(t===this.templateBindingObserver)this.template=this.templateBindingObserver.bind(this.controller),this.refreshAllViews(!0);else{if(!t[0])return;t[0].reset?this.refreshAllViews():this.updateViews(t)}}observeItems(e=!1){if(!this.items)return void(this.items=s);const t=this.itemsObserver,i=this.itemsObserver=d.getNotifier(this.items),n=t!==i;n&&null!==t&&t.unsubscribe(this),(n||e)&&i.subscribe(this)}updateViews(e){const t=this.views,s=this.bindView,i=this.items,n=this.template,r=this.controller,o=this.directive.options.recycle,l=[];let h=0,a=0;for(let c=0,d=e.length;c<d;++c){const d=e[c],u=d.removed;let f=0,p=d.index;const b=p+d.addedCount,g=t.splice(d.index,u.length),v=a=l.length+g.length;for(;p<b;++p){const e=t[p],c=e?e.firstChild:this.location;let d;o&&a>0?(f<=v&&g.length>0?(d=g[f],f++):(d=l[h],h++),a--):d=n.create(),t.splice(p,0,d),s(d,i,p,r),d.insertBefore(c)}g[f]&&l.push(...g.slice(f))}for(let e=h,t=l.length;e<t;++e)l[e].dispose();if(this.directive.options.positioning)for(let e=0,s=t.length;e<s;++e){const i=t[e].context;i.length=s,i.index=e}}refreshAllViews(e=!1){const t=this.items,s=this.template,i=this.location,n=this.bindView,r=this.controller;let o=t.length,l=this.views,h=l.length;if(0!==o&&!e&&this.directive.options.recycle||(pe.disposeContiguousBatch(l),h=0),0===h){this.views=l=new Array(o);for(let e=0;e<o;++e){const o=s.create();n(o,t,e,r),l[e]=o,o.insertBefore(i)}}else{let e=0;for(;e<o;++e)if(e<h){n(l[e],t,e,r)}else{const o=s.create();n(o,t,e,r),l.push(o),o.insertBefore(i)}const a=l.splice(e,h-e);for(e=0,o=a.length;e<o;++e)a[e].dispose()}}unbindAllViews(){const e=this.views;for(let t=0,s=e.length;t<s;++t)e[t].unbind()}}class Me{constructor(e,t,s){this.dataBinding=e,this.templateBinding=t,this.options=s,this.id=q(),A.enable()}createHTML(e){return Q.comment(e(this))}createBehavior(){return new Fe(this)}}function Pe(e,t,s=_e){const i=ue(e),n=ue(t);return new Me(i,n,Object.assign(Object.assign({},_e),s))}K.define(Me);const Re=e=>1===e.nodeType,De=e=>e?t=>1===t.nodeType&&t.matches(e):Re;class He extends ee{constructor(){super(...arguments),this.sourceProperty=`${this.id}-s`}bind(e){const t=e.targets[this.nodeId];t[this.sourceProperty]=e.source,this.updateTarget(e.source,this.computeNodes(t)),this.observe(t),e.onUnbind(this)}unbind(e){const t=e.targets[this.nodeId];this.updateTarget(e.source,s),this.disconnect(t),t[this.sourceProperty]=null}getSource(e){return e[this.sourceProperty]}updateTarget(e,t){e[this.options.property]=t}computeNodes(e){let t=this.getNodes(e);return"filter"in this.options&&(t=t.filter(this.options.filter)),t}}class Ue extends He{observe(e){e.addEventListener("slotchange",this)}disconnect(e){e.removeEventListener("slotchange",this)}getNodes(e){return e.assignedNodes(this.options)}handleEvent(e){const t=e.currentTarget;this.updateTarget(this.getSource(t),this.computeNodes(t))}}function qe(e){return o(e)&&(e={property:e}),new Ue(e)}K.define(Ue);class Qe extends He{constructor(e){super(e),this.observerProperty=`${this.id}-o`,this.handleEvent=(e,t)=>{const s=t.target;this.updateTarget(this.getSource(s),this.computeNodes(s))},e.childList=!0}observe(e){var t;const s=null!==(t=e[this.observerProperty])&&void 0!==t?t:e[this.observerProperty]=new MutationObserver(this.handleEvent);s.target=e,s.observe(e,this.options)}disconnect(e){const t=e[this.observerProperty];t.target=null,t.disconnect()}getNodes(e){return"selector"in this.options?Array.from(e.querySelectorAll(this.options.selector)):Array.from(e.childNodes)}}function We(e){return o(e)&&(e={property:e}),new Qe(e)}K.define(Qe);const Ge=Object.freeze({locate:n()}),Je={toView:e=>e?"true":"false",fromView:e=>null!=e&&"false"!==e&&!1!==e&&0!==e};function Ke(e){if(null==e)return null;const t=1*e;return isNaN(t)?null:t}const Xe={toView(e){const t=Ke(e);return t?t.toString():t},fromView:Ke};class Ye{constructor(e,t,s=t.toLowerCase(),i="reflect",n){this.guards=new Set,this.Owner=e,this.name=t,this.attribute=s,this.mode=i,this.converter=n,this.fieldName=`_${t}`,this.callbackName=`${t}Changed`,this.hasCallback=this.callbackName in e.prototype,"boolean"===i&&void 0===n&&(this.converter=Je)}setValue(e,t){const s=e[this.fieldName],i=this.converter;void 0!==i&&(t=i.fromView(t)),s!==t&&(e[this.fieldName]=t,this.tryReflectToAttribute(e),this.hasCallback&&e[this.callbackName](s,t),e.$fastController.notify(this.name))}getValue(e){return d.track(e,this.name),e[this.fieldName]}onAttributeChangedCallback(e,t){this.guards.has(e)||(this.guards.add(e),this.setValue(e,t),this.guards.delete(e))}tryReflectToAttribute(e){const t=this.mode,s=this.guards;s.has(e)||"fromView"===t||l.enqueue((()=>{s.add(e);const i=e[this.fieldName];switch(t){case"reflect":const t=this.converter;M.setAttribute(e,this.attribute,void 0!==t?t.toView(i):i);break;case"boolean":M.setBooleanAttribute(e,this.attribute,i)}s.delete(e)}))}static collect(e,...t){const s=[];t.push(Ge.locate(e));for(let i=0,n=t.length;i<n;++i){const n=t[i];if(void 0!==n)for(let t=0,i=n.length;t<i;++t){const i=n[t];o(i)?s.push(new Ye(e,i)):s.push(new Ye(e,i.property,i.attribute,i.mode,i.converter))}}return s}}function Ze(e,t){let s;function i(e,t){arguments.length>1&&(s.property=t),Ge.locate(e.constructor).push(s)}return arguments.length>1?(s={},void i(e,t)):(s=void 0===e?{}:e,i)}const et={mode:"open"},tt={},st=new Set,it=t.getById(4,(()=>i()));class nt{constructor(e,t=e.definition){var s;this.platformDefined=!1,o(t)&&(t={name:t}),this.type=e,this.name=t.name,this.template=t.template,this.registry=null!==(s=t.registry)&&void 0!==s?s:customElements;const i=e.prototype,n=Ye.collect(e,t.attributes),r=new Array(n.length),l={},h={};for(let e=0,t=n.length;e<t;++e){const t=n[e];r[e]=t.attribute,l[t.name]=t,h[t.attribute]=t,d.defineProperty(i,t)}Reflect.defineProperty(e,"observedAttributes",{value:r,enumerable:!0}),this.attributes=n,this.propertyLookup=l,this.attributeLookup=h,this.shadowOptions=void 0===t.shadowOptions?et:null===t.shadowOptions?void 0:Object.assign(Object.assign({},et),t.shadowOptions),this.elementOptions=void 0===t.elementOptions?tt:Object.assign(Object.assign({},tt),t.elementOptions),this.styles=I.normalize(t.styles),it.register(this)}get isDefined(){return this.platformDefined}define(e=this.registry){const t=this.type;return e.get(this.name)||(this.platformDefined=!0,e.define(this.name,t,this.elementOptions)),this}static compose(e,t){return st.has(e)||it.getByType(e)?new nt(class extends e{},t):new nt(e,t)}static registerBaseType(e){st.add(e)}}nt.getByType=it.getByType,nt.getForInstance=it.getForInstance;const rt={bubbles:!0,composed:!0,cancelable:!0},ot=new WeakMap;function lt(e){var t,s;return null!==(s=null!==(t=e.shadowRoot)&&void 0!==t?t:ot.get(e))&&void 0!==s?s:null}class ht extends a{constructor(e,t){super(e),this.boundObservables=null,this.needsInitialization=!0,this.hasExistingShadowRoot=!1,this._template=null,this._isConnected=!1,this.behaviors=null,this._mainStyles=null,this.$fastController=this,this.view=null,this.source=e,this.definition=t;const s=t.shadowOptions;if(void 0!==s){let t=e.shadowRoot;t?this.hasExistingShadowRoot=!0:(t=e.attachShadow(s),"closed"===s.mode&&ot.set(e,t))}const i=d.getAccessors(e);if(i.length>0){const t=this.boundObservables=Object.create(null);for(let s=0,n=i.length;s<n;++s){const n=i[s].name,r=e[n];void 0!==r&&(delete e[n],t[n]=r)}}}get isConnected(){return d.track(this,"isConnected"),this._isConnected}setIsConnected(e){this._isConnected=e,d.notify(this,"isConnected")}get template(){var e;if(null===this._template){const t=this.definition;this.source.resolveTemplate?this._template=this.source.resolveTemplate():t.template&&(this._template=null!==(e=t.template)&&void 0!==e?e:null)}return this._template}set template(e){this._template!==e&&(this._template=e,this.needsInitialization||this.renderTemplate(e))}get mainStyles(){var e;if(null===this._mainStyles){const t=this.definition;this.source.resolveStyles?this._mainStyles=this.source.resolveStyles():t.styles&&(this._mainStyles=null!==(e=t.styles)&&void 0!==e?e:null)}return this._mainStyles}set mainStyles(e){this._mainStyles!==e&&(null!==this._mainStyles&&this.removeStyles(this._mainStyles),this._mainStyles=e,this.needsInitialization||this.addStyles(e))}addBehavior(e){var t,s;const i=null!==(t=this.behaviors)&&void 0!==t?t:this.behaviors=new Map,n=null!==(s=i.get(e))&&void 0!==s?s:0;0===n?(i.set(e,1),e.addedCallback&&e.addedCallback(this),e.connectedCallback&&this.isConnected&&e.connectedCallback(this)):i.set(e,n+1)}removeBehavior(e,t=!1){const s=this.behaviors;if(null===s)return;const i=s.get(e);void 0!==i&&(1===i||t?(s.delete(e),e.disconnectedCallback&&this.isConnected&&e.disconnectedCallback(this),e.removedCallback&&e.removedCallback(this)):s.set(e,i-1))}addStyles(e){var t;if(!e)return;const s=this.source;if(e instanceof HTMLElement){(null!==(t=lt(s))&&void 0!==t?t:this.source).append(e)}else if(!e.isAttachedTo(s)){const t=e.behaviors;if(e.addStylesTo(s),null!==t)for(let e=0,s=t.length;e<s;++e)this.addBehavior(t[e])}}removeStyles(e){var t;if(!e)return;const s=this.source;if(e instanceof HTMLElement){(null!==(t=lt(s))&&void 0!==t?t:s).removeChild(e)}else if(e.isAttachedTo(s)){const t=e.behaviors;if(e.removeStylesFrom(s),null!==t)for(let e=0,s=t.length;e<s;++e)this.addBehavior(t[e])}}connect(){if(this._isConnected)return;this.needsInitialization?this.finishInitialization():null!==this.view&&this.view.bind(this.source);const e=this.behaviors;if(null!==e)for(const t of e.keys())t.connectedCallback&&t.connectedCallback(this);this.setIsConnected(!0)}disconnect(){if(!this._isConnected)return;this.setIsConnected(!1),null!==this.view&&this.view.unbind();const e=this.behaviors;if(null!==e)for(const t of e.keys())t.disconnectedCallback&&t.disconnectedCallback(this)}onAttributeChangedCallback(e,t,s){const i=this.definition.attributeLookup[e];void 0!==i&&i.onAttributeChangedCallback(this.source,s)}emit(e,t,s){return!!this._isConnected&&this.source.dispatchEvent(new CustomEvent(e,Object.assign(Object.assign({detail:t},rt),s)))}finishInitialization(){const e=this.source,t=this.boundObservables;if(null!==t){const s=Object.keys(t);for(let i=0,n=s.length;i<n;++i){const n=s[i];e[n]=t[n]}this.boundObservables=null}this.renderTemplate(this.template),this.addStyles(this.mainStyles),this.needsInitialization=!1}renderTemplate(e){var t;const s=this.source,i=null!==(t=lt(s))&&void 0!==t?t:s;if(null!==this.view)this.view.dispose(),this.view=null;else if(!this.needsInitialization||this.hasExistingShadowRoot){this.hasExistingShadowRoot=!1;for(let e=i.firstChild;null!==e;e=i.firstChild)i.removeChild(e)}e&&(this.view=e.render(s,i,s),this.view.sourceLifetime=c.coupled)}static forCustomElement(e){const s=e.$fastController;if(void 0!==s)return s;const i=nt.getForInstance(e);if(void 0===i)throw t.error(1401);return e.$fastController=new ht(e,i)}}function at(e){var t;return"adoptedStyleSheets"in e?e:null!==(t=lt(e))&&void 0!==t?t:e.getRootNode()}class ct{constructor(e){const t=ct.styleSheetCache;this.sheets=e.map((e=>{if(e instanceof CSSStyleSheet)return e;let s=t.get(e);return void 0===s&&(s=new CSSStyleSheet,s.replaceSync(e),t.set(e,s)),s}))}addStylesTo(e){const t=at(e);t.adoptedStyleSheets=[...t.adoptedStyleSheets,...this.sheets]}removeStylesFrom(e){const t=at(e),s=this.sheets;t.adoptedStyleSheets=t.adoptedStyleSheets.filter((e=>-1===s.indexOf(e)))}}ct.styleSheetCache=new Map;let dt=0;function ut(e){return e===document?document.body:e}function ft(e){const t=class extends e{constructor(){super(),ht.forCustomElement(this)}$emit(e,t,s){return this.$fastController.emit(e,t,s)}connectedCallback(){this.$fastController.connect()}disconnectedCallback(){this.$fastController.disconnect()}attributeChangedCallback(e,t,s){this.$fastController.onAttributeChangedCallback(e,t,s)}};return nt.registerBaseType(t),t}function pt(e,t){return r(e)?nt.compose(e,t).define().type:nt.compose(this,e).define().type}I.setDefaultStrategy(I.supportsAdoptedStyleSheets?ct:class{constructor(e){this.styles=e,this.styleClass="fast-"+ ++dt}addStylesTo(e){e=ut(at(e));const t=this.styles,s=this.styleClass;for(let i=0;i<t.length;i++){const n=document.createElement("style");n.innerHTML=t[i],n.className=s,e.append(n)}}removeStylesFrom(e){const t=(e=ut(at(e))).querySelectorAll(`.${this.styleClass}`);t[0].parentNode;for(let s=0,i=t.length;s<i;++s)e.removeChild(t[s])}});const bt=Object.assign(ft(HTMLElement),{from:function(e){return ft(e)},define:pt,compose:function(e,t){return r(e)?nt.compose(e,t):nt.compose(this,e)}});function gt(e){return function(t){pt(t,e)}}export{A as ArrayObserver,Z as Aspect,Ge as AttributeConfiguration,Ye as AttributeDefinition,Y as Binding,E as CSSDirective,Qe as ChildrenDirective,Ae as Compiler,M as DOM,ht as ElementController,I as ElementStyles,b as ExecutionContext,t as FAST,bt as FASTElement,nt as FASTElementDefinition,he as HTMLBindingDirective,K as HTMLDirective,pe as HTMLView,Q as Markup,He as NodeObservationDirective,d as Observable,W as Parser,a as PropertyChangeNotifier,Ve as RefDirective,Fe as RepeatBehavior,Me as RepeatDirective,Ue as SlottedDirective,c as SourceLifetime,g as Splice,S as SpliceStrategy,v as SpliceStrategySupport,ee as StatelessAttachedAttributeDirective,h as SubscriberSet,l as Updates,G as ViewBehaviorOrchestrator,ke as ViewTemplate,Ze as attr,ae as bind,Je as booleanConverter,We as children,n as createMetadataLocator,i as createTypeRegistry,z as css,N as cssDirective,F as cssPartial,gt as customElement,De as elements,s as emptyArray,Ie as html,X as htmlDirective,k as lengthOf,de as listener,ue as normalizeBinding,Xe as nullableNumberConverter,u as observable,ce as oneTime,Ee as ref,Pe as repeat,qe as slotted,f as volatile,Ne as when};
@@ -32,20 +32,6 @@ export declare type AddBehavior = (behavior: HostBehavior<HTMLElement>) => void;
32
32
  */
33
33
  export declare type AddViewBehaviorFactory = (factory: ViewBehaviorFactory) => string;
34
34
 
35
- /**
36
- * https://wicg.github.io/construct-stylesheets/
37
- * https://developers.google.com/web/updates/2019/02/constructable-stylesheets
38
- *
39
- * @internal
40
- */
41
- export declare class AdoptedStyleSheetsStrategy implements StyleStrategy {
42
- /** @internal */
43
- readonly sheets: CSSStyleSheet[];
44
- constructor(styles: (string | CSSStyleSheet)[]);
45
- addStylesTo(target: StyleTarget): void;
46
- removeStylesFrom(target: StyleTarget): void;
47
- }
48
-
49
35
  /**
50
36
  * An observer for arrays.
51
37
  * @public
@@ -2027,13 +2013,14 @@ export declare class RepeatBehavior<TSource = any> implements ViewBehavior, Subs
2027
2013
  private directive;
2028
2014
  private location;
2029
2015
  private controller;
2030
- private views;
2031
2016
  private template;
2032
2017
  private templateBindingObserver;
2033
2018
  private items;
2034
2019
  private itemsObserver;
2035
2020
  private itemsBindingObserver;
2036
2021
  private bindView;
2022
+ /** @internal */
2023
+ views: SyntheticView[];
2037
2024
  /**
2038
2025
  * Creates an instance of RepeatBehavior.
2039
2026
  * @param location - The location in the DOM to render the repeat.
@@ -2401,7 +2388,7 @@ export declare interface StyleStrategy {
2401
2388
  * A node that can be targeted by styles.
2402
2389
  * @public
2403
2390
  */
2404
- export declare interface StyleTarget {
2391
+ export declare interface StyleTarget extends Pick<Node, "getRootNode"> {
2405
2392
  /**
2406
2393
  * Stylesheets to be adopted by the node.
2407
2394
  */
@@ -17,19 +17,6 @@ export type AddBehavior = (behavior: HostBehavior<HTMLElement>) => void;
17
17
  // @public
18
18
  export type AddViewBehaviorFactory = (factory: ViewBehaviorFactory) => string;
19
19
 
20
- // Warning: (ae-internal-missing-underscore) The name "AdoptedStyleSheetsStrategy" should be prefixed with an underscore because the declaration is marked as @internal
21
- //
22
- // @internal
23
- export class AdoptedStyleSheetsStrategy implements StyleStrategy {
24
- constructor(styles: (string | CSSStyleSheet)[]);
25
- // (undocumented)
26
- addStylesTo(target: StyleTarget): void;
27
- // (undocumented)
28
- removeStylesFrom(target: StyleTarget): void;
29
- // (undocumented)
30
- readonly sheets: CSSStyleSheet[];
31
- }
32
-
33
20
  // @public
34
21
  export interface ArrayObserver extends SubscriberSet {
35
22
  addSplice(splice: Splice): void;
@@ -662,6 +649,8 @@ export class RepeatBehavior<TSource = any> implements ViewBehavior, Subscriber {
662
649
  bind(controller: ViewController): void;
663
650
  handleChange(source: any, args: Splice[] | ExpressionObserver): void;
664
651
  unbind(): void;
652
+ // @internal (undocumented)
653
+ views: SyntheticView[];
665
654
  }
666
655
 
667
656
  // @public
@@ -777,7 +766,7 @@ export interface StyleStrategy {
777
766
  }
778
767
 
779
768
  // @public
780
- export interface StyleTarget {
769
+ export interface StyleTarget extends Pick<Node, "getRootNode"> {
781
770
  adoptedStyleSheets?: CSSStyleSheet[];
782
771
  append(styles: HTMLStyleElement): void;
783
772
  querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@microsoft/fast-element",
3
3
  "description": "A library for constructing Web Components",
4
- "version": "2.0.0-beta.10",
4
+ "version": "2.0.0-beta.12",
5
5
  "author": {
6
6
  "name": "Microsoft",
7
7
  "url": "https://discord.gg/FcSNfg4"
@@ -26,10 +26,6 @@
26
26
  "development": "./dist/esm/index.debug.js",
27
27
  "default": "./dist/esm/index.js"
28
28
  },
29
- "./polyfills": {
30
- "types": "./dist/dts/polyfills.d.ts",
31
- "default": "./dist/esm/polyfills.js"
32
- },
33
29
  "./debug": {
34
30
  "types": "./dist/dts/debug.d.ts",
35
31
  "default": "./dist/esm/debug.js"
@@ -111,7 +107,7 @@
111
107
  "@microsoft/api-extractor": "7.24.2",
112
108
  "@types/chai": "^4.2.11",
113
109
  "@types/chai-spies": "^1.0.3",
114
- "@types/karma": "^5.0.0",
110
+ "@types/karma": "^6.3.3",
115
111
  "@types/mocha": "^7.0.2",
116
112
  "@types/webpack-env": "^1.15.2",
117
113
  "chai": "^4.2.0",
@@ -122,7 +118,7 @@
122
118
  "istanbul-instrumenter-loader": "^3.0.1",
123
119
  "jsdom": "^16.2.2",
124
120
  "jsdom-global": "3.0.2",
125
- "karma": "^5.0.4",
121
+ "karma": "^6.4.1",
126
122
  "karma-chrome-launcher": "^3.1.0",
127
123
  "karma-coverage": "^2.0.2",
128
124
  "karma-coverage-istanbul-reporter": "^3.0.0",