init {
	screenTemplates := {
		"000": {
			"widgets": {
				"001": {"type": "textInput", "text": "", "visible": true}, 
				"002": {"type": "button", "text": "Next", "visible": true},
				"005": {"type": "label", "text": "_", "visible": true},
				"006": {"type": "button", "text": "hello", "visible": true}
			}, 
			"layout": true
		},
		"001": {
			"widgets": {
				"003": {"type": "label", "text": "label", "visible": true}, 
				"004": {"type": "button", "text": "Back", "visible": true}
			}, 
			"layout": true
		}
	}
	sender5 := "005"
}

native channel ScreenUpdate {
	in screen(curSc: Json, update(curSc, nextSc)) = nextSc
}

native channel SetLayout {
	in screen.layout(curLayout: Bool, setLayout(nextLayout)) = nextLayout
}

native channel SetVisible(wid: Str) {
	in screen.widgets.{wid}.visible(curVisible: Bool, setVisible(nextVisible)) = nextVisible
}

native channel SetText(wid: Str) {
	in screen.widgets.{wid}.text(curText: Str, setText(nextText)) = nextText
}

native channel SetX(wid: Str) {
	in screen.widgets.{wid}.x(curX: Int, setX(nextX)) = nextX
}

native channel SetY(wid: Str) {
	in screen.widgets.{wid}.y(curY: Int, setY(nextY)) = nextY
}

native channel SetWidth(wid: Str) {
	in screen.widgets.{wid}.width(curWidth: Int, setWidth(nextWidth)) = nextWidth
}

native channel SetHeight(wid: Str) {
	in screen.widgets.{wid}.height(curHeight: Int, setHeight(nextHeight)) = nextHeight
}

native channel MouseEvent(wid: Str) {
	out screen.widgets.{wid}.state(curState: Int, mouseEvent(nextState)) = nextState
}

native channel TextEvent(wid: Str) {
	out screen.widgets.{wid}.text(curText: Str, textEvent(nextText)) = nextText
}

channel ChangeCurScreen {
	out curScreen(curScId: Str, changeCurScreen(nextScId)) = nextScId
}

channel ScreenTransition {
	in curScreen(curScId: Str, transScreen(nextScId, screen)) = nextScId
	ref screenTemplates.{nextScId}(screen, transScreen(nextScId, screen))
	out screen(curS, transScreen(nextScId, screen)) = screen
}

channel EventHandler1(wid: Str) {
	in screen.widgets.{wid="002"}.state(curState: Int, handleEvent1(nextState)) = nextState
	out curScreen(curScId: Str, handleEvent1(nextState)) = if((curScId == "000") && (nextState == 0), "001", curScId)
}

channel EventHandler2(wid: Str) {
	in screen.widgets.{wid="004"}.state(curState: Int, handleEvent2(nextState)) = nextState
	out curScreen(curScId: Str, handleEvent2(nextState)) = if((curScId == "001") && (nextState == 0), "000", curScId)
}

channel EventHandler3(wid: Str) {
	in screen.widgets.{wid="001"}.text(curText: Str, handler3(nextText: Str, target:Str)) = nextText
	ref sender5(target, handler3(nextText, target))
	out screen.widgets.{target}.text(curText, handler3(nextText, target)) = nextText
}

