-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlayout-manager.js
1 lines (1 loc) · 30.8 KB
/
layout-manager.js
1
"use strict";this._root=document;let ImageResource=(()=>{let t=Symbol(),e=Symbol(),s=Symbol(),i=Symbol(),o=Symbol();return class{constructor(){this.source=null,this.sizes=null,this.type=null,this.purpose=null,this.platform=null}set source(e){e=null!=e?e[WebAddress.to]():WebAddress.empty,this[t]=e}get source(){return this[t]}set sizes(t){t=null!=t?t[String.to]():String.empty,this[e]=t}get sizes(){return this[e]}set type(t){t=null!=t?t[String.to]():String.empty,this[s]=t}get type(){return this[s]}set purpose(t){t=null!=t?t[String.to]():String.empty,this[i]=t}get purpose(){return this[i]}set platform(t){t=null!=t?t[String.to]():String.empty,this[o]=t}get platform(){return this[o]}get src(){return this.source}toJSON(){let t={};return t.source=this.source,t.sizes=this.sizes,t.type=this.type,t.purpose=this.purpose,t.platform=this.platform,t}}})(),ApplicationManifest=(()=>{let t=Symbol(),e=Symbol(),s=Symbol(),i=Symbol(),o=Symbol(),r=Symbol();return class{constructor(){this.name=null,this.description=null,this.icons=null,this.display="standalone",this.orientation="natural",this.start_url=null}set name(e){e=null!=e?e[String.to]():String.empty,this[t]=e}get name(){return this[t]}set description(t){t=null!=t?t[String.to]():String.empty,this[e]=t}get description(){return this[e]}set icons(t){t=null!=t?t[List.to]():List.empty,this[s]=t}get icons(){return this[s]}set display(t){this[i]=t}get display(){return this[i]}set orientation(t){this[o]=t}get orientation(){return this[o]}set start_url(t){t=null!=t?t[String.to]():String.empty,this[r]=t}get start_url(){return this[r]}addTo(t){this.name||(this.name=document.title),this.icons.size||(this.icons=List.of({src:document.icons[0].source})),this.start_url||(this.start_url=document.location.pathname),HTMLElement.create("link").fillWith({rel:"manifest",source:new Blob(Array.of(JSON.stringify(this)),{type:"application/manifest+json"}),parentNode:t.head}),HTMLElement.create("meta").fillWith({name:"viewport",content:"width=device-width,initial-scale=1,maximum-scale=1",parentNode:t.head})}toJSON(){let t={};return t.name=this.name,t.description=this.description,t.icons=this.icons,t.display=this.display,t.orientation=this.orientation,t.start_url=this.start_url,t}}})(),UnitValue=(()=>{let t=Symbol(),e=Symbol(),s=RegExp.from`^([+-]?\d+(?:\.\d+)?)(.*)$`;class i{constructor(){this.value=null,this.unit="px"}set value(e){e=null!=e?e[RealNumber.to]():RealNumber.empty,this[t]=e}get value(){return this[t]}set unit(t){this[e]=t}get unit(){return this[e]}[String.to](){return`${this.value}${this.unit}`}toJSON(){let t={};return t.value=this.value,t.unit=this.unit,t}}return RealNumber.implements(class{[i.to](){return(new i).fillWith({value:this})}}),String.implements(class{[i.to](){s.lastIndex=0;let t=s.exec(this);return(new i).fillWith({value:t[1],unit:t[2]})}}),i})(),PositionValue=(()=>{let t=Symbol(),e=Symbol();return class{constructor(){this.x="50%",this.y="50%"}set x(e){e=null!=e?e[UnitValue.to]():UnitValue.empty,this[t]=e}get x(){return this[t]}set y(t){t=null!=t?t[UnitValue.to]():UnitValue.empty,this[e]=t}get y(){return this[e]}set all(t){this.x=t,this.y=t}[String.to](){return`${this.x} ${this.y}`}toJSON(){let t={};return t.x=this.x,t.y=this.y,t}}})(),LookBase=class t{addTo(t){}removeFrom(t){}static mapFromLogicalName(t){return t.replace("start","right").replace("end","left")}static set(t,e,s){t.style.setProperty(e,s)}static append(e,s,i,o){null==o&&(o=",");let r=e.style.getPropertyValue(s);r&&(i=`${r}${o}${i}`),t.set(e,s,i)}},InnerSpacing=(()=>{let t=Symbol(),e=Symbol(),s=Symbol(),i=Symbol();return class extends LookBase{constructor(){super(...arguments),this.top="unset",this.start="unset",this.bottom="unset",this.end="unset"}set top(e){this[t]=e}get top(){return this[t]}set start(t){this[e]=t}get start(){return this[e]}set bottom(t){this[s]=t}get bottom(){return this[s]}set end(t){this[i]=t}get end(){return this[i]}set all(t){this.top=t,this.start=t,this.bottom=t,this.end=t}set topBottom(t){this.top=t,this.bottom=t}set startEnd(t){this.start=t,this.end=t}addTo(t){let e=function(e,s){"unset"!=s&&LookBase.set(t,`padding-${e}`,String.isObjectModelOf(s)?s:`${s}px`)}.bind(this);e("top",this.top),e("bottom",this.bottom),e(LookBase.mapFromLogicalName("start"),this.start),e(LookBase.mapFromLogicalName("end"),this.end)}toJSON(){let t=super.toJSON?super.toJSON():{};return t.top=this.top,t.start=this.start,t.bottom=this.bottom,t.end=this.end,t}}})(),Border=(()=>{let t=Symbol(),e=Symbol(),s=Symbol(),i=Symbol();return class extends LookBase{constructor(){super(...arguments),this.edge="all",this.width=1,this.style="solid",this.color=null}set edge(e){this[t]=e}get edge(){return this[t]}set width(t){t=null!=t?t[UnitValue.to]():UnitValue.empty,this[e]=t}get width(){return this[e]}set style(t){this[s]=t}get style(){return this[s]}set color(t){t=null!=t?t[Color.to]():Color.empty,this[i]=t}get color(){return this[i]}addTo(t){let e=function(e){LookBase.set(t,`border${e}`,`${this.width} ${this.style} ${this.color}`)}.bind(this);if("all"==this.edge)e("");else for(let t of LookBase.mapFromLogicalName(this.edge).split("-"))e(`-${t}`)}toJSON(){let t=super.toJSON?super.toJSON():{};return t.edge=this.edge,t.width=this.width,t.style=this.style,t.color=this.color,t}}})(),BorderRadius=(()=>{let t=Symbol(),e=Symbol(),s=Symbol();return class extends LookBase{constructor(){super(...arguments),this.corner="all",this.width=null,this.height=null}set corner(e){this[t]=e}get corner(){return this[t]}set width(t){t=null!=t?t[UnitValue.to]():UnitValue.empty,this[e]=t}get width(){return this[e]}set height(t){t=null!=t?t[UnitValue.to]():UnitValue.empty,this[s]=t}get height(){return this[s]}set all(t){this.width=t,this.height=t}addTo(t){let e=LookBase.mapFromLogicalName(this.corner),s=function(e,s){null==s&&(s=" "),LookBase.set(t,`border${e}-radius`,`${this.width}${s}${this.height}`)}.bind(this);"all"==e?s("","/"):e.includes("-")?s(`-${e}`):"top"==this.corner||"bottom"==this.corner?(s(`-${e}-left`),s(`-${e}-right`)):(s(`-top-${e}`),s(`-bottom-${e}`))}toJSON(){let t=super.toJSON?super.toJSON():{};return t.corner=this.corner,t.width=this.width,t.height=this.height,t}}})(),ColorStop=(()=>{let t=Symbol(),e=Symbol();return class{constructor(){this.color=null,this.position=null}set color(e){e=null!=e?e[Color.to]():Color.empty,this[t]=e}get color(){return this[t]}set position(t){t=null!=t?t[UnitValue.to]():UnitValue.empty,this[e]=t}get position(){return this[e]}[String.to](){return`${this.color} ${this.position}`}toJSON(){let t={};return t.color=this.color,t.position=this.position,t}}})(),LinearGradient=(()=>{let t=Symbol(),e=Symbol(),s=Symbol();return class extends LookBase{constructor(){super(...arguments),this.direction=180,this.colors=null,this.repeatable=null}set direction(e){e=null!=e?e[RealNumber.to]():RealNumber.empty,this[t]=e}get direction(){return this[t]}set colors(t){t=null!=t?t[List.to]():List.empty,this[e]=t}get colors(){return this[e]}set repeatable(t){t=null!=t?t[Boolean.to]():Boolean.empty,this[s]=t}get repeatable(){return this[s]}[Symbol.add](t,e){Color.isObjectModelOf(t)&&(t=(new ColorStop).fillWith({color:t,position:(new UnitValue).fillWith({value:e?100:0,unit:"%"})})),this.colors.add(t)}addTo(t){1==this.colors.size&&this.colors.add(this.colors[0]),LookBase.append(t,"background",`${this.repeatable?"repeating-":""}linear-gradient(${this.direction}deg,${this.colors.join()})`)}toJSON(){let t=super.toJSON?super.toJSON():{};return t.direction=this.direction,t.colors=this.colors,t.repeatable=this.repeatable,t}}})(),RadialGradient=(()=>{let t=Symbol(),e=Symbol(),s=Symbol(),i=Symbol(),o=Symbol();return class extends LookBase{constructor(){super(...arguments),this.shape="ellipse",this.position=null,this.extent="farthest-corner",this.colors=null,this.repeatable=null}set shape(e){this[t]=e}get shape(){return this[t]}set position(t){t=null!=t?t[PositionValue.to]():PositionValue.empty,this[e]=t}get position(){return this[e]}set extent(t){this[s]=t}get extent(){return this[s]}set colors(t){t=null!=t?t[List.to]():List.empty,this[i]=t}get colors(){return this[i]}set repeatable(t){t=null!=t?t[Boolean.to]():Boolean.empty,this[o]=t}get repeatable(){return this[o]}[Symbol.add](t,e){Color.isObjectModelOf(t)&&(t=(new ColorStop).fillWith({color:t,position:(new UnitValue).fillWith({value:e?100:0,unit:"%"})})),this.colors.add(t)}addTo(t){1==this.colors.size&&this.colors.add(this.colors[0]),LookBase.append(t,"background",`${this.repeatable?"repeating-":""}radial-gradient(${this.shape} ${this.extent} at ${this.position},${this.colors.join()})`)}toJSON(){let t=super.toJSON?super.toJSON():{};return t.shape=this.shape,t.position=this.position,t.extent=this.extent,t.colors=this.colors,t.repeatable=this.repeatable,t}}})(),FontLook=(()=>{let t=Symbol(),e=Symbol(),s=Symbol(),i=Symbol(),o=Symbol();return class extends LookBase{constructor(){super(...arguments),this.name="unset",this.size="unset",this.style="unset",this.weight="unset",this.lineHeight="unset"}set name(e){this[t]=e}get name(){return this[t]}set size(t){this[e]=t}get size(){return this[e]}set style(t){this[s]=t}get style(){return this[s]}set weight(t){this[i]=t}get weight(){return this[i]}set lineHeight(t){this[o]=t}get lineHeight(){return this[o]}addTo(t){let e=function(t,e){"unset"!=e&&LookBase.set(t,e)}.bind(this);e("font-family",this.name),e("font-size",this.size),e("font-style",this.style),e("font-weight",this.weight),e("line-height",this.lineHeight)}toJSON(){let t=super.toJSON?super.toJSON():{};return t.name=this.name,t.size=this.size,t.style=this.style,t.weight=this.weight,t.lineHeight=this.lineHeight,t}}})(),TextLook=(()=>{let t=Symbol(),e=Symbol(),s=Symbol(),i=Symbol(),o=Symbol(),r=Symbol(),l=Symbol();return class extends LookBase{constructor(){super(...arguments),this.align="unset",this.verticalAlign="unset",this.color="unset",this.indent="unset",this.decoration="unset",this.transform="unset",this.overflow="unset"}set align(e){this[t]=e}get align(){return this[t]}set verticalAlign(t){this[e]=t}get verticalAlign(){return this[e]}set color(t){this[s]=t}get color(){return this[s]}set indent(t){this[i]=t}get indent(){return this[i]}set decoration(t){this[o]=t}get decoration(){return this[o]}set transform(t){this[r]=t}get transform(){return this[r]}set overflow(t){this[l]=t}get overflow(){return this[l]}addTo(t){let e=function(e,s){"unset"!=s&&LookBase.set(t,e,s)}.bind(this);e("text-align",this.align),e("vertical-align",this.verticalAlign),e("color",this.color),e("text-indent",this.indent),e("text-decoration",this.decoration),e("text-transform",this.transform),e("text-overflow",this.overflow)}toJSON(){let t=super.toJSON?super.toJSON():{};return t.align=this.align,t.verticalAlign=this.verticalAlign,t.color=this.color,t.indent=this.indent,t.decoration=this.decoration,t.transform=this.transform,t.overflow=this.overflow,t}}})(),BoxShadow=(()=>{let t=Symbol(),e=Symbol(),s=Symbol(),i=Symbol(),o=Symbol(),r=Symbol();return class extends LookBase{constructor(){super(...arguments),this.horizontal=null,this.vertical=null,this.blur=null,this.color=null,this.spread=null,this.inset=null}set horizontal(e){e=null!=e?e[UnitValue.to]():UnitValue.empty,this[t]=e}get horizontal(){return this[t]}set vertical(t){t=null!=t?t[UnitValue.to]():UnitValue.empty,this[e]=t}get vertical(){return this[e]}set blur(t){t=null!=t?t[UnitValue.to]():UnitValue.empty,this[s]=t}get blur(){return this[s]}set color(t){t=null!=t?t[Color.to]():Color.empty,this[i]=t}get color(){return this[i]}set spread(t){t=null!=t?t[UnitValue.to]():UnitValue.empty,this[o]=t}get spread(){return this[o]}set inset(t){t=null!=t?t[Boolean.to]():Boolean.empty,this[r]=t}get inset(){return this[r]}addTo(t){LookBase.append(t,"box-shadow",`${this.horizontal} ${this.vertical} ${this.blur} ${this.spread} ${this.color}${this.inset?" inset":""}`)}static clear(){return(new LookDefinition).fillWith({boxShadow:"unset"})}toJSON(){let t=super.toJSON?super.toJSON():{};return t.horizontal=this.horizontal,t.vertical=this.vertical,t.blur=this.blur,t.color=this.color,t.spread=this.spread,t.inset=this.inset,t}}})(),TextShadow=(()=>{let t=Symbol(),e=Symbol(),s=Symbol(),i=Symbol();return class extends LookBase{constructor(){super(...arguments),this.horizontal=null,this.vertical=null,this.blur=null,this.color=null}set horizontal(e){e=null!=e?e[UnitValue.to]():UnitValue.empty,this[t]=e}get horizontal(){return this[t]}set vertical(t){t=null!=t?t[UnitValue.to]():UnitValue.empty,this[e]=t}get vertical(){return this[e]}set blur(t){t=null!=t?t[UnitValue.to]():UnitValue.empty,this[s]=t}get blur(){return this[s]}set color(t){t=null!=t?t[Color.to]():Color.empty,this[i]=t}get color(){return this[i]}addTo(t){LookBase.append(t,"text-shadow",`${this.horizontal} ${this.vertical} ${this.blur} ${this.color}`)}toJSON(){let t=super.toJSON?super.toJSON():{};return t.horizontal=this.horizontal,t.vertical=this.vertical,t.blur=this.blur,t.color=this.color,t}}})(),LookShadow=(()=>{let t=Symbol(),e=Symbol(),s=Symbol(),i=Symbol();return class extends LookBase{constructor(){super(...arguments),this.horizontal=null,this.vertical=null,this.blur=null,this.color=null}set horizontal(e){e=null!=e?e[UnitValue.to]():UnitValue.empty,this[t]=e}get horizontal(){return this[t]}set vertical(t){t=null!=t?t[UnitValue.to]():UnitValue.empty,this[e]=t}get vertical(){return this[e]}set blur(t){t=null!=t?t[UnitValue.to]():UnitValue.empty,this[s]=t}get blur(){return this[s]}set color(t){t=null!=t?t[Color.to]():Color.empty,this[i]=t}get color(){return this[i]}addTo(t){LookBase.append(t,"filter",`drop-shadow(${this.horizontal} ${this.vertical} ${this.blur} ${this.color})`," ")}toJSON(){let t=super.toJSON?super.toJSON():{};return t.horizontal=this.horizontal,t.vertical=this.vertical,t.blur=this.blur,t.color=this.color,t}}})(),LookOpacity=(()=>{let t=Symbol();return class extends LookBase{constructor(){super(...arguments),this.amount=null}set amount(e){e=null!=e?e[RealNumber.to]():RealNumber.empty,this[t]=e}get amount(){return this[t]}addTo(t){LookBase.set(t,"opacity",this.amount/100)}toJSON(){let t=super.toJSON?super.toJSON():{};return t.amount=this.amount,t}}})(),LookGrayscale=(()=>{let t=Symbol();return class extends LookBase{constructor(){super(...arguments),this.amount=null}set amount(e){e=null!=e?e[RealNumber.to]():RealNumber.empty,this[t]=e}get amount(){return this[t]}addTo(t){LookBase.append(t,"filter",`grayscale(${this.amount}%)`," ")}toJSON(){let t=super.toJSON?super.toJSON():{};return t.amount=this.amount,t}}})(),LookBlur=(()=>{let t=Symbol();return class extends LookBase{constructor(){super(...arguments),this.amount=null}set amount(e){e=null!=e?e[UnitValue.to]():UnitValue.empty,this[t]=e}get amount(){return this[t]}addTo(t){LookBase.append(t,"filter",`blur(${this.amount})`," ")}toJSON(){let t=super.toJSON?super.toJSON():{};return t.amount=this.amount,t}}})(),LookVector=(()=>{let t,e,s,i=Symbol(),o=Symbol(),r=Symbol();class l{constructor(){this.x=null,this.y=null,this.z=null}set x(t){t=null!=t?t[RealNumber.to]():RealNumber.empty,this[i]=t}get x(){return this[i]}set y(t){t=null!=t?t[RealNumber.to]():RealNumber.empty,this[o]=t}get y(){return this[o]}set z(t){t=null!=t?t[RealNumber.to]():RealNumber.empty,this[r]=t}get z(){return this[r]}set all(t){this.x=t,this.y=t,this.z=t}static set X(e){t=e}static get X(){return t}static set Y(t){e=t}static get Y(){return e}static set Z(t){s=t}static get Z(){return s}toJSON(){let t={};return t.x=this.x,t.y=this.y,t.z=this.z,t}}return l.Z=(new l).fillWith({z:1}),l.Y=(new l).fillWith({y:1}),l.X=(new l).fillWith({x:1}),l})(),LookTransform=(()=>{let t=Symbol();return class extends LookBase{constructor(){super(...arguments),this.origin=null}set origin(e){e=null!=e?e[PositionValue.to]():PositionValue.empty,this[t]=e}get origin(){return this[t]}addTo(t){LookBase.set(t,"transform-origin",this.origin)}toJSON(){let t=super.toJSON?super.toJSON():{};return t.origin=this.origin,t}}})(),LookTranslate=(()=>{let t=Symbol(),e=Symbol(),s=Symbol();return class extends LookBase{constructor(){super(...arguments),this.x=null,this.y=null,this.z=null}set x(e){e=null!=e?e[UnitValue.to]():UnitValue.empty,this[t]=e}get x(){return this[t]}set y(t){t=null!=t?t[UnitValue.to]():UnitValue.empty,this[e]=t}get y(){return this[e]}set z(t){t=null!=t?t[UnitValue.to]():UnitValue.empty,this[s]=t}get z(){return this[s]}set all(t){this.x=t,this.y=t,this.z=t}addTo(t){LookBase.append(t,"transform",`translate3d(${this.x},${this.y},${this.z})`," ")}toJSON(){let t=super.toJSON?super.toJSON():{};return t.x=this.x,t.y=this.y,t.z=this.z,t}}})(),LookSkew=(()=>{let t=Symbol(),e=Symbol();return class extends LookBase{constructor(){super(...arguments),this.x=null,this.y=null}set x(e){e=null!=e?e[RealNumber.to]():RealNumber.empty,this[t]=e}get x(){return this[t]}set y(t){t=null!=t?t[RealNumber.to]():RealNumber.empty,this[e]=t}get y(){return this[e]}set all(t){this.x=t,this.y=t}addTo(t){LookBase.append(t,"transform",`skew(${this.x}deg,${this.y}deg)`," ")}toJSON(){let t=super.toJSON?super.toJSON():{};return t.x=this.x,t.y=this.y,t}}})(),LookScale=(()=>{let t=Symbol(),e=Symbol(),s=Symbol();return class extends LookBase{constructor(){super(...arguments),this.x=null,this.y=null,this.z=null}set x(e){e=null!=e?e[RealNumber.to]():RealNumber.empty,this[t]=e}get x(){return this[t]}set y(t){t=null!=t?t[RealNumber.to]():RealNumber.empty,this[e]=t}get y(){return this[e]}set z(t){t=null!=t?t[RealNumber.to]():RealNumber.empty,this[s]=t}get z(){return this[s]}set all(t){this.x=t,this.y=t,this.z=t}addTo(t){LookBase.append(t,"transform",`scale3d(${this.x},${this.y},${this.z})`," ")}toJSON(){let t=super.toJSON?super.toJSON():{};return t.x=this.x,t.y=this.y,t.z=this.z,t}}})(),LookRotate=(()=>{let t=Symbol(),e=Symbol();return class extends LookBase{constructor(){super(...arguments),this.angle=null,this.vector=LookVector.Z}set angle(e){e=null!=e?e[RealNumber.to]():RealNumber.empty,this[t]=e}get angle(){return this[t]}set vector(t){t=null!=t?t[LookVector.to]():LookVector.empty,this[e]=t}get vector(){return this[e]}addTo(t){LookBase.append(t,"transform",`rotate3d(${this.vector.x},${this.vector.y},${this.vector.z},${this.angle}deg)`," ")}toJSON(){let t=super.toJSON?super.toJSON():{};return t.angle=this.angle,t.vector=this.vector,t}}})(),LookPerspective=(()=>{let t=Symbol(),e=Symbol();return class extends LookBase{constructor(){super(...arguments),this.length=null,this.origin=null}set length(e){e=null!=e?e[UnitValue.to]():UnitValue.empty,this[t]=e}get length(){return this[t]}set origin(t){t=null!=t?t[PositionValue.to]():PositionValue.empty,this[e]=t}get origin(){return this[e]}addTo(t){LookBase.append(t,"transform",`perspective(${this.length})`," "),LookBase.set(t,"perspective-origin",this.origin)}toJSON(){let t=super.toJSON?super.toJSON():{};return t.length=this.length,t.origin=this.origin,t}}})(),Layout=class extends LookBase{constructor(){super(...arguments)}},LookDefinition=class{[Symbol.add](t){this[t[0]]=t[1]}addTo(t){for(let e of this)t.style.setProperty(e[0],e[1])}removeFrom(t){}},LookMixin=class extends Set{constructor(){super(...arguments)}addTo(t){for(let e of this)e.addTo(t)}removeFrom(t){for(let e of this)e.removeFrom(t)}},LookState=(()=>{let t=Symbol(),e=Symbol(),s=Symbol();class i extends LookBase{constructor(){super(...arguments),this.name="base",this.when=null,this.changes=null}set name(e){e=null!=e?e[String.to]():String.empty,this[t]=e}get name(){return this[t]}set when(t){t=null!=t?t[Boolean.to]():Boolean.empty,this[e]=t}get when(){return this[e]}set changes(t){t=null!=t?t[Set.to]():Set.empty,this[s]=t}get changes(){return this[s]}[Symbol.add](t){this.changes.add(t)}addTo(t){t.states?t.lastState.size&&t.classes.toggle("dummy-state"):t.fillWith({states:new Map,lastState:new Set},function*(){t.style.cssText&&(yield(new i).fillWith({name:"inlineStyle",when:!0},[(new LookDefinition).fillWith({},function*(){for(let e of t.style)yield[e,t.style.getPropertyValue(e)]},this)]))},this),t.states.set(this.name,this)}toJSON(){let t=super.toJSON?super.toJSON():{};return t.name=this.name,t.when=this.when,t.changes=this.changes,t}}let o=function(t,e){for(let s of t.source.path)s.states&&s.classes.remove(e)}.bind(this),r=function(t,e){for(let s of t.source.path)s.states&&s.classes.add(e)}.bind(this);return document.fillWith({},[(new When).fillWith({name:"focusin",resolver(t){r(t,"in-focus")}}),(new When).fillWith({name:"focusout",resolver(t){o(t,"in-focus")}}),(new When).fillWith({name:"mouseover",resolver(t){r(t,"in-over")}}),(new When).fillWith({name:"mouseout",resolver(t){o(t,"in-over")}}),(new When).fillWith({name:"mousedown",resolver(t){r(t,"is-pressed")}}),(new When).fillWith({name:"mouseup",resolver(t){o(t,"is-pressed")}})]),new MutationObserver(function(t){let e=new Set,s=function(t){let s=function(e){for(let s of e.changes)t.lastState.add(s),s.addTo(t)}.bind(this);if(t.states&&!e.includes(t)){for(let e of t.lastState)e.removeFrom(t);t.lastState.clear(),t.style.fillWith({cssText:"",overflow:"hidden",position:"relative"}),t.states.includes("base")&&s(t.states.get("base"));for(let e of t.states){Sequence.isObjectModelOf(e)&&(e=e[List.to]());let i=e[Symbol.get](1);(t.classes.includes(i.name)||i.when)&&s(i)}e.add(t)}}.bind(this),i=new Event("in-view"),o=new Event("out-of-view"),r=function(t){for(let e of t)e.nodes&&(o.sendTo(e),r(e.nodes))}.bind(this),l=function(t){for(let e of t)e.nodes&&(s(e),i.sendTo(e),l(e.nodes))}.bind(this);for(let e of t)"childList"==e.type?(r(e.removedNodes),l(e.addedNodes)):s(e.target)}.bind(this)).observe(document,{subtree:!0,childList:!0,attributes:!0,attributeFilter:(new List).fillWith({},["class"])}),i})(),PropertyChanges=(()=>{let t=Symbol(),e=Symbol(),s=Symbol();return class{constructor(){this.target=null,this.properties=null,this.state=null}set target(e){this[t]=e}get target(){return this[t]}set properties(t){t=null!=t?t[Set.to]():Set.empty,this[e]=t}get properties(){return this[e]}set state(t){this[s]=t}get state(){return this[s]}[Symbol.add](t){this.properties.add(t)}addTo(t){let e=this.target?this.target():t;for(let t of Object.getOwnPropertyNames(this))e[t]=this[t];this.state&&e.classes.add(this.state);for(let t of this.properties)t.addTo(e)}removeFrom(t){let e=this.target?this.target():t;this.state&&e.classes.remove(this.state);for(let t of this.properties)t.removeFrom(e)}toJSON(){let t={};return t.target=this.target,t.properties=this.properties,t.state=this.state,t}}})(),Color=(()=>{let t=Symbol(),e=Symbol(),s=Symbol(),i=Symbol();class o{constructor(){this.red=null,this.green=null,this.blue=null,this.alpha=255}set red(e){e=null!=e?e[Integer.to]():Integer.empty,this[t]=e}get red(){return this[t]}set green(t){t=null!=t?t[Integer.to]():Integer.empty,this[e]=t}get green(){return this[e]}set blue(t){t=null!=t?t[Integer.to]():Integer.empty,this[s]=t}get blue(){return this[s]}set alpha(t){t=null!=t?t[Integer.to]():Integer.empty,this[i]=t}get alpha(){return this[i]}[String.to](){return`rgba(${this.red},${this.green},${this.blue},${this.alpha/255})`}static fromGray(t,e){return null==e&&(e=255),(new o).fillWith({red:t,green:t,blue:t,alpha:e})}toJSON(){let t={};return t.red=this.red,t.green=this.green,t.blue=this.blue,t.alpha=this.alpha,t}}return o})(),LookRule=(()=>{let t,e=Symbol(),s=Symbol();class i{constructor(){this.selector=null,this.properties=null}set selector(t){t=null!=t?t[String.to]():String.empty,this[e]=t}get selector(){return this[e]}set properties(t){t=null!=t?t[List.to]():List.empty,this[s]=t}get properties(){return this[s]}[Symbol.add](t){this.properties.add(t)}addTo(t){let e,s="";CSSRule.isObjectModelOf(t)?(e=t.parentStyleSheet,s=t.selectorText):e=(t=i.ruleSet).sheet;let o=e.insertRule(`${s}${this.selector}{}`,e.cssRules.length),r=e.cssRules[o];for(let t of this.properties)t.addTo(r)}static set ruleSet(e){t=e}static get ruleSet(){return t}toJSON(){let t={};return t.selector=this.selector,t.properties=this.properties,t}}return i.ruleSet=HTMLElement.create("style").fillWith({parentNode:document.head}),document.fillWith({},[(new i).fillWith({selector:"*"},[(new LookDefinition).fillWith({"box-sizing":"border-box",margin:0,padding:0,border:0,"font-family":"inherit","font-size":"100%","text-align":"start",transition:"background .5s ease, opacity .5s ease-out, transform .5s, width .5s, height .5s, box-shadow .5s, border .5s"})]),(new i).fillWith({selector:":focus"},[(new LookDefinition).fillWith({outline:0})]),(new i).fillWith({selector:"img"},[(new LookDefinition).fillWith({"max-width":"100%"})]),(new i).fillWith({selector:"button"},[(new LookDefinition).fillWith({background:"none","text-align":"center",cursor:"pointer"}),(new InnerSpacing).fillWith({all:8})])]),i})(),LookFontFace=(()=>{let t=Symbol(),e=Symbol(),s=Symbol(),i=Symbol();return class{constructor(){this.source=null,this.name=null,this.style="normal",this.weight="normal"}set source(e){e=null!=e?e[WebAddress.to]():WebAddress.empty,this[t]=e}get source(){return this[t]}set name(t){t=null!=t?t[String.to]():String.empty,this[e]=t}get name(){return this[e]}set style(t){this[s]=t}get style(){return this[s]}set weight(t){this[i]=t}get weight(){return this[i]}addTo(t){t=LookRule.ruleSet,Sequence.isObjectModelOf(t)&&(t=t[List.to]());let e=t[Symbol.get]("sheet"),s=e.insertRule("@font-face{}",e.cssRules.length);e.cssRules[s].fillWith({},[(new LookDefinition).fillWith({src:`url(${this.source})`,"font-family":this.name,"font-style":this.style,"font-weight":this.weight})])}toJSON(){let t={};return t.source=this.source,t.name=this.name,t.style=this.style,t.weight=this.weight,t}}})(),DistributingChildren=(()=>{let t=Symbol(),e=Symbol(),s=Symbol(),i=Symbol(),o=Symbol();return document.fillWith({},[(new LookRule).fillWith({selector:".MyGridView"},[(new LookDefinition).fillWith({display:"flex","flex-wrap":"wrap"})]),(new LookRule).fillWith({selector:".MyGridView.filledSpace::after"},[(new LookDefinition).fillWith({content:"''",width:"var(--filledSpace, 0)"})])]),class extends Layout{constructor(){super(...arguments),this.containerAlignment="space-between",this.spacing=16,this.itemWidth="fit-content",this.itemHeight="max-content",this.itemAlignment="start"}set containerAlignment(e){this[t]=e}get containerAlignment(){return this[t]}set spacing(t){t=null!=t?t[Integer.to]():Integer.empty,this[e]=t}get spacing(){return this[e]}set itemWidth(t){this[s]=t}get itemWidth(){return this[s]}set itemHeight(t){this[i]=t}get itemHeight(){return this[i]}set itemAlignment(t){this[o]=t}get itemAlignment(){return this[o]}addTo(t){let e,s=function(){this.execute(t)}.bind(this);t.fillWith({classes:"MyGridView"},[(new When).fillWith({name:"in-view",resolver(){s(),(e=new MutationObserver(s)).observe(t,{childList:!0}),visualViewport.addEventListener("resize",s,{passive:!0})}}),(new When).fillWith({name:"out-of-view",resolver(){e.disconnect(),visualViewport.removeEventListener("resize",s)}})])}execute(t){if(!t.firstChild)return;let e=function(t){return"start"==t||"end"==t?`${t}-value`:t}.bind(this),s=(new List).fillWith({},["start","end","center"]).includes(this.containerAlignment)||"stretch"==this.itemWidth,i=getComputedStyle(t),o=t.getBoundingClientRect().width-(i.paddingLeft[RealNumber.to]()+i.paddingRight[RealNumber.to]()),r=getComputedStyle(t).direction,l=t.firstChild.getBoundingClientRect().width,n=o%l,h=Math.floor(o/l),a=t.nodes.length%h,u=Math.ceil(t.nodes.length/h),c=h-a,m=c*l;m+=s?c*this.spacing:n/h*(c-1),t.classes.toggle("filledSpace",u>1&&m),t.fillWith({},[(new LookState).fillWith({name:"MyGridView",when:!0},[(new LookDefinition).fillWith({"justify-content":1==h?"space-around":e(this.containerAlignment),"align-items":"max-content"==this.itemHeight?"stretch":e(this.itemAlignment),"--filledSpace":`${m}px`})])]);let d="rtl"==r?"margin-right":"margin-left";{let e=0;for(let i of t.nodes)i.fillWith({},[(new LookState).fillWith({name:"MyGridViewItem",when:!0},[(new LookDefinition).fillWith({margin:0,"margin-top":h<=e?`${this.spacing}px`:0,"flex-grow":"stretch"==this.itemWidth?1:0},[Array.of(d,s&&e%h!=0?`${this.spacing}px`:0)])])]),e+=1}}toJSON(){let t=super.toJSON?super.toJSON():{};return t.containerAlignment=this.containerAlignment,t.spacing=this.spacing,t.itemWidth=this.itemWidth,t.itemHeight=this.itemHeight,t.itemAlignment=this.itemAlignment,t}}})(),PositionRelative=(()=>{let t=Symbol(),e=Symbol(),s=Symbol();return class extends Layout{constructor(){super(...arguments),this.origin=null,this.distance=(new PositionValue).fillWith({all:0}),this.container="parent"}set origin(e){e=null!=e?e[PositionValue.to]():PositionValue.empty,this[t]=e}get origin(){return this[t]}set distance(t){t=null!=t?t[PositionValue.to]():PositionValue.empty,this[e]=t}get distance(){return this[e]}set container(t){this[s]=t}get container(){return this[s]}addTo(t){t.fillWith({},[(new LookDefinition).fillWith({position:"parent"==this.container?"absolute":"fixed",left:`calc(${this.origin.x} + ${this.distance.x})`,top:`calc(${this.origin.y} + ${this.distance.y})`,transform:`translate(-${this.origin.x}, -${this.origin.y})`})])}toJSON(){let t=super.toJSON?super.toJSON():{};return t.origin=this.origin,t.distance=this.distance,t.container=this.container,t}}})(),Group=class{constructor(){return HTMLElement.create("div")}},EditableList=(()=>{let t=Symbol();return class{constructor(){this.selectRender=null}set selectRender(e){e=null!=e?e[Function.to]():Function.empty,this[t]=e}get selectRender(){return this[t]}toJSON(){let t={};return t.selectRender=this.selectRender,t}}})(),EditableText=(()=>{return document.fillWith({},[(new LookRule).fillWith({selector:"input"},[(new InnerSpacing).fillWith({all:8})])]),class{constructor(){return HTMLElement.create("input").fillWith({})}}})(),NavigationLink=(()=>{return document.fillWith({},[(new LookRule).fillWith({selector:"a"},[(new LookDefinition).fillWith({"text-decoration":"none",cursor:"pointer",color:"inherit"})])]),class{constructor(){return HTMLElement.create("a")}}})(),NavigationLinks=class{constructor(){return HTMLElement.create("nav")}},LineBreak=class{constructor(){return HTMLElement.create("br")}},Paragraph=class{constructor(){return HTMLElement.create("p")}},UserInterfaceElement=(()=>{let t=Symbol();class e extends EventTarget{constructor(){super(...arguments),this.renderedElement=null}set renderedElement(e){this[t]=e}get renderedElement(){return this[t]}whenObjectStateChanged(){this.renderedElement&&this.renderedElement.replaceWith(this.render())}[Node.to](){return this.render()}render(){return this.renderedElement=this.renderer(),e.isObjectModelOf(this.renderedElement)&&(this.renderedElement=this.renderedElement.render()),this.renderedElement}renderer(){}toJSON(){let t=super.toJSON?super.toJSON():{};return t.renderedElement=this.renderedElement,t}}return e})(),HistoryRecord=(()=>{let t=Symbol(),e=Symbol();return class{constructor(){this.pageAddress=null,this.scrollPosition=null}set pageAddress(e){this[t]=e}get pageAddress(){return this[t]}set scrollPosition(t){t=null!=t?t[PositionValue.to]():PositionValue.empty,this[e]=t}get scrollPosition(){return this[e]}toJSON(){let t={};return t.pageAddress=this.pageAddress,t.scrollPosition=this.scrollPosition,t}}})(),Router=(()=>{let t=Symbol(),e=Symbol();return window.fillWith({},[(new When).fillWith({name:"hashchange",resolver(){}})]),class{constructor(){this.rules=null,this.root="/"}set rules(e){e=null!=e?e[Set.to]():Set.empty,this[t]=e}get rules(){return this[t]}set root(t){t=null!=t?t[String.to]():String.empty,this[e]=t}get root(){return this[e]}transitionTo(){}resolve(){}toJSON(){let t={};return t.rules=this.rules,t.root=this.root,t}}})();