CREATE TABLE IF NOT EXISTS `{PR}tilbuci_assets` (
  `at_uid` int(11) NOT NULL AUTO_INCREMENT,
  `at_id` varchar(32) NOT NULL,
  `at_collection` varchar(64) NOT NULL,
  `at_order` int(11) NOT NULL DEFAULT 0,
  `at_name` varchar(256) NOT NULL,
  `at_type` varchar(16) NOT NULL,
  `at_time` decimal(8,4) NOT NULL DEFAULT 5.0000,
  `at_action` text DEFAULT NULL,
  `at_frames` int(11) NOT NULL DEFAULT 1,
  `at_frtime` int(11) NOT NULL DEFAULT 100,
  `at_file1` text DEFAULT NULL,
  `at_file2` text DEFAULT NULL,
  `at_file3` text DEFAULT NULL,
  `at_file4` text DEFAULT NULL,
  `at_file5` text DEFAULT NULL,
  PRIMARY KEY (`at_uid`),
  KEY `at_id` (`at_id`),
  KEY `at_collection` (`at_collection`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_collections` (
  `cl_uid` varchar(64) NOT NULL,
  `cl_id` varchar(32) NOT NULL,
  `cl_movie` varchar(32) NOT NULL,
  `cl_title` varchar(256) NOT NULL,
  `cl_transition` varchar(8) NOT NULL DEFAULT 'alpha',
  `cl_time` decimal(8,4) NOT NULL DEFAULT 1.0000,
  PRIMARY KEY (`cl_uid`),
  KEY `cl_id` (`cl_id`),
  KEY `cl_movie` (`cl_movie`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_config` (
  `cf_key` varchar(16) NOT NULL,
  `cf_value` text DEFAULT NULL,
  PRIMARY KEY (`cf_key`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_cors` (
  `cr_domain` varchar(256) NOT NULL,
  PRIMARY KEY (`cr_domain`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_dialogues` (
  `dg_id` int(11) NOT NULL AUTO_INCREMENT,
  `dg_movie` varchar(32) NOT NULL,
  `dg_name` varchar(64) NOT NULL,
  `dg_content` longtext DEFAULT NULL,
  PRIMARY KEY (`dg_id`),
  KEY `dg_movie` (`dg_movie`),
  KEY `dg_name` (`dg_name`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_events` (
  `ev_id` int(11) NOT NULL AUTO_INCREMENT,
  `ev_date` datetime NOT NULL DEFAULT current_timestamp(),
  `ev_when` datetime NOT NULL,
  `ev_name` varchar(128) NOT NULL,
  `ev_movie` varchar(32) NOT NULL,
  `ev_moviename` varchar(256) NOT NULL,
  `ev_scene` varchar(32) NOT NULL,
  `ev_scenename` varchar(256) NOT NULL,
  `ev_visitor` varchar(256) NOT NULL,
  `ev_extra` text NOT NULL,
  `ev_session` varchar(32) NOT NULL DEFAULT '',
  PRIMARY KEY (`ev_id`),
  KEY `ev_date` (`ev_date`),
  KEY `ev_movie` (`ev_movie`),
  KEY `ev_when` (`ev_when`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_fonts` (
  `fn_name` varchar(128) NOT NULL,
  `fn_file` varchar(512) NOT NULL,
  PRIMARY KEY (`fn_name`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_instancedesc` (
  `id_id` int(11) NOT NULL AUTO_INCREMENT,
  `id_instance` int(11) NOT NULL,
  `id_position` varchar(1) NOT NULL,
  `id_order` tinyint(4) NOT NULL DEFAULT 0,
  `id_x` int(11) NOT NULL DEFAULT 0,
  `id_y` int(11) NOT NULL DEFAULT 0,
  `id_alpha` decimal(4,3) NOT NULL DEFAULT 1.000,
  `id_width` int(11) NOT NULL DEFAULT 64,
  `id_height` int(11) NOT NULL DEFAULT 64,
  `id_rotation` int(11) NOT NULL DEFAULT 0,
  `id_visible` tinyint(4) NOT NULL DEFAULT 1,
  `id_color` varchar(8) NOT NULL DEFAULT '0x000000',
  `id_coloralpha` decimal(4,3) NOT NULL DEFAULT 0.000,
  `id_volume` decimal(5,0) NOT NULL DEFAULT 1,
  `id_pan` decimal(5,3) NOT NULL DEFAULT 0.000,
  `id_blur` varchar(128) NOT NULL DEFAULT '',
  `id_dropshadow` varchar(128) NOT NULL DEFAULT '',
  `id_textfont` varchar(128) NOT NULL DEFAULT '',
  `id_textsize` smallint(6) NOT NULL DEFAULT 12,
  `id_textcolor` varchar(8) NOT NULL DEFAULT '0xFFFFFF',
  `id_textbold` tinyint(4) NOT NULL DEFAULT 0,
  `id_textitalic` tinyint(4) NOT NULL DEFAULT 0,
  `id_textleading` smallint(6) NOT NULL DEFAULT 0,
  `id_textspacing` tinyint(4) NOT NULL DEFAULT 0,
  `id_textbackground` varchar(8) NOT NULL DEFAULT '',
  `id_textalign` varchar(8) NOT NULL DEFAULT 'left',
  `id_glow` varchar(128) NOT NULL DEFAULT '',
  `id_blend` varchar(16) NOT NULL DEFAULT 'normal',
  PRIMARY KEY (`id_id`),
  KEY `id_instance` (`id_instance`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_instances` (
  `in_id` int(11) NOT NULL AUTO_INCREMENT,
  `in_keyframe` int(11) NOT NULL,
  `in_name` varchar(32) NOT NULL,
  `in_collection` varchar(32) NOT NULL,
  `in_asset` varchar(32) NOT NULL,
  `in_action` text DEFAULT NULL,
  `in_play` tinyint(4) NOT NULL DEFAULT 1,
  `in_actionover` text DEFAULT NULL,
  `in_timedac` mediumtext DEFAULT NULL,
  PRIMARY KEY (`in_id`),
  KEY `in_keyframe` (`in_keyframe`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_keyframes` (
  `kf_id` int(11) NOT NULL AUTO_INCREMENT,
  `kf_scene` int(11) NOT NULL,
  `kf_order` tinyint(4) NOT NULL,
  PRIMARY KEY (`kf_id`),
  KEY `kf_scene` (`kf_scene`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_menus` (
  `mn_id` int(11) NOT NULL AUTO_INCREMENT,
  `mn_movie` varchar(64) NOT NULL,
  `mn_name` varchar(64) NOT NULL,
  `mn_button` varchar(1024) NOT NULL,
  `mn_over` varchar(1024) NOT NULL,
  `mn_background` varchar(1024) NOT NULL,
  `mn_courtain` varchar(16) NOT NULL,
  `mn_x` int(11) NOT NULL DEFAULT -1,
  `mn_y` int(11) NOT NULL DEFAULT -1,
  PRIMARY KEY (`mn_id`),
  KEY `mn_movie` (`mn_movie`),
  KEY `mn_name` (`mn_name`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_movies` (
  `mv_id` varchar(32) NOT NULL,
  `mv_user` varchar(256) NOT NULL,
  `mv_collaborators` varchar(2048) NOT NULL DEFAULT '',
  `mv_author` varchar(256) NOT NULL,
  `mv_title` varchar(512) NOT NULL,
  `mv_about` varchar(2048) NOT NULL DEFAULT '',
  `mv_copyright` varchar(128) NOT NULL DEFAULT '',
  `mv_copyleft` varchar(128) NOT NULL DEFAULT '',
  `mv_tags` varchar(1024) NOT NULL DEFAULT '',
  `mv_favicon` varchar(1024) NOT NULL DEFAULT '',
  `mv_image` varchar(1024) NOT NULL DEFAULT '',
  `mv_key` varchar(32) NOT NULL DEFAULT '',
  `mv_identify` tinyint(1) NOT NULL DEFAULT 0,
  `mv_vsgroups` varchar(256) NOT NULL DEFAULT '',
  `mv_fallback` varchar(256) NOT NULL DEFAULT '',
  `mv_start` varchar(32) NOT NULL DEFAULT '',
  `mv_acstart` text DEFAULT NULL,
  `mv_screenbig` int(11) NOT NULL DEFAULT 1920,
  `mv_screensmall` int(11) NOT NULL DEFAULT 1080,
  `mv_screentype` varchar(16) NOT NULL DEFAULT 'both',
  `mv_screenbg` varchar(8) NOT NULL DEFAULT '0x000000',
  `mv_interval` decimal(3,2) NOT NULL DEFAULT 1.00,
  `mv_origin` varchar(16) NOT NULL DEFAULT 'center',
  `mv_animation` varchar(16) NOT NULL DEFAULT 'linear',
  `mv_fonts` text DEFAULT NULL,
  `mv_style` longtext DEFAULT NULL,
  `mv_highlight` varchar(16) NOT NULL DEFAULT '',
  `mv_actions` longtext DEFAULT NULL,
  `mv_theme` text DEFAULT NULL,
  `mv_inputs` text DEFAULT NULL,
  `mv_texts` longtext DEFAULT NULL,
  `mv_numbers` longtext DEFAULT NULL,
  `mv_flags` longtext DEFAULT NULL,
  `mv_plugins` varchar(1024) NOT NULL DEFAULT '',
  `mv_created` datetime NOT NULL DEFAULT current_timestamp(),
  `mv_updated` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `mv_contraptions` longtext DEFAULT NULL,
  `mv_loading` varchar(2048) NOT NULL DEFAULT '',
  `mv_strings` longtext DEFAULT NULL,
  `mv_encrypted` tinyint(4) NOT NULL DEFAULT 0,
  `mv_narrative` longtext DEFAULT NULL,
  PRIMARY KEY (`mv_id`),
  KEY `mv_title` (`mv_title`),
  KEY `mv_updated` (`mv_updated`),
  KEY `mv_user` (`mv_user`),
  KEY `mv_collaborators` (`mv_collaborators`(768)),
  KEY `mv_collaborators_2` (`mv_collaborators`(768))
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_notes` (
  `nt_id` int(11) NOT NULL AUTO_INCREMENT,
  `nt_movie` varchar(32) NOT NULL,
  `nt_scene` varchar(32) NOT NULL,
  `nt_type` varchar(8) NOT NULL,
  `nt_text` longtext NOT NULL,
  `nt_author` varchar(256) NOT NULL,
  `nt_time` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`nt_id`),
  KEY `nt_movie` (`nt_movie`),
  KEY `nt_scene` (`nt_scene`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_overlay_plugin` (
  `op_key` varchar(32) NOT NULL,
  `op_url` varchar(2048) NOT NULL,
  `op_request` longtext DEFAULT NULL,
  `op_return` longtext DEFAULT NULL,
  `op_closed` tinyint(4) NOT NULL DEFAULT 0,
  `op_created` datetime NOT NULL DEFAULT current_timestamp(),
  `op_updated` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`op_key`),
  KEY `op_created` (`op_created`),
  KEY `op_updated` (`op_updated`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_pluginconfig` (
  `pc_id` varchar(64) NOT NULL,
  `pc_active` tinyint(4) NOT NULL DEFAULT 1,
  `pc_setup` longtext DEFAULT NULL,
  `pc_file` varchar(64) NOT NULL,
  `pc_index` tinyint(4) NOT NULL DEFAULT 0,
  `pc_ws` tinyint(4) NOT NULL DEFAULT 0,
  PRIMARY KEY (`pc_id`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_plugins` (
  `pl_id` varchar(128) NOT NULL,
  `pl_name` varchar(64) NOT NULL,
  `pl_movie` varchar(64) NOT NULL,
  `pl_scene` varchar(64) NOT NULL,
  `pl_config` longtext DEFAULT NULL,
  PRIMARY KEY (`pl_id`),
  KEY `pl_name` (`pl_name`),
  KEY `pl_movie` (`pl_movie`,`pl_scene`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_scenelock` (
  `sl_id` varchar(128) NOT NULL,
  `sl_movie` varchar(32) NOT NULL,
  `sl_scene` varchar(32) NOT NULL,
  `sl_user` varchar(512) NOT NULL DEFAULT '',
  `sl_when` datetime NOT NULL,
  PRIMARY KEY (`sl_id`),
  KEY `sl_movie` (`sl_movie`),
  KEY `sl_scene` (`sl_scene`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_scenes` (
  `sc_uid` int(11) NOT NULL AUTO_INCREMENT,
  `sc_id` varchar(32) NOT NULL,
  `sc_movie` varchar(32) NOT NULL,
  `sc_published` tinyint(4) NOT NULL DEFAULT 0,
  `sc_title` varchar(256) NOT NULL,
  `sc_about` varchar(2048) NOT NULL DEFAULT '',
  `sc_image` varchar(1024) NOT NULL DEFAULT '',
  `sc_up` varchar(32) NOT NULL DEFAULT '',
  `sc_down` varchar(32) NOT NULL DEFAULT '',
  `sc_left` varchar(32) NOT NULL DEFAULT '',
  `sc_right` varchar(32) NOT NULL DEFAULT '',
  `sc_nin` varchar(32) NOT NULL DEFAULT '',
  `sc_nout` varchar(32) NOT NULL DEFAULT '',
  `sc_collections` varchar(2048) NOT NULL DEFAULT '',
  `sc_loop` tinyint(4) NOT NULL DEFAULT 0,
  `sc_acstart` text DEFAULT NULL,
  `sc_ackeyframes` mediumtext DEFAULT NULL,
  `sc_user` varchar(512) NOT NULL,
  `sc_date` datetime NOT NULL DEFAULT current_timestamp(),
  `sc_static` tinyint(4) NOT NULL DEFAULT 0,
  `sc_dflow1` varchar(256) NOT NULL DEFAULT '',
  `sc_dflow2` varchar(256) NOT NULL DEFAULT '',
  `sc_dflow3` varchar(256) NOT NULL DEFAULT '',
  `sc_dflow4` varchar(256) NOT NULL DEFAULT '',
  PRIMARY KEY (`sc_uid`),
  KEY `sc_id` (`sc_id`),
  KEY `sc_movie` (`sc_movie`),
  KEY `sc_published` (`sc_published`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_snippets` (
  `sn_id` int(11) NOT NULL AUTO_INCREMENT,
  `sn_movie` varchar(32) NOT NULL,
  `sn_file` varchar(128) NOT NULL,
  `sn_content` longtext NOT NULL,
  PRIMARY KEY (`sn_id`),
  KEY `sn_movie` (`sn_movie`),
  KEY `sn_file` (`sn_file`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_strings` (
  `st_id` int(11) NOT NULL AUTO_INCREMENT,
  `st_movie` varchar(32) NOT NULL,
  `st_file` varchar(128) NOT NULL,
  `st_content` longtext DEFAULT NULL,
  PRIMARY KEY (`st_id`),
  KEY `st_movie` (`st_movie`),
  KEY `st_file` (`st_file`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_users` (
  `us_email` varchar(256) NOT NULL,
  `us_pass` varchar(32) NOT NULL,
  `us_passtemp` varchar(32) NOT NULL,
  `us_key` varchar(32) NOT NULL,
  `us_level` tinyint(4) NOT NULL,
  `us_created` datetime NOT NULL DEFAULT current_timestamp(),
  `us_updated` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`us_email`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_visitorassoc` (
  `va_id` int(11) NOT NULL AUTO_INCREMENT,
  `va_visitor` varchar(512) NOT NULL,
  `va_group` int(11) NOT NULL,
  PRIMARY KEY (`va_id`),
  KEY `va_visitor` (`va_visitor`),
  KEY `va_group` (`va_group`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_visitordata` (
  `vd_id` varchar(128) NOT NULL,
  `vd_movie` varchar(64) NOT NULL,
  `vd_user` varchar(128) NOT NULL,
  `vd_name` varchar(64) NOT NULL,
  `vd_value` mediumtext DEFAULT NULL,
  `vd_created` datetime NOT NULL DEFAULT current_timestamp(),
  `vd_updated` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`vd_id`),
  KEY `vd_movie` (`vd_movie`),
  KEY `vd_user` (`vd_user`),
  KEY `vd_name` (`vd_name`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_visitorgroups` (
  `vg_id` int(11) NOT NULL AUTO_INCREMENT,
  `vg_name` varchar(512) NOT NULL,
  `vg_created` datetime NOT NULL DEFAULT current_timestamp(),
  `vg_updated` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`vg_id`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_visitors` (
  `vs_email` varchar(256) NOT NULL,
  `vs_key` varchar(32) NOT NULL,
  `vs_created` datetime NOT NULL DEFAULT current_timestamp(),
  `vs_last` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `vs_code` varchar(8) NOT NULL,
  `vs_level` tinyint(4) NOT NULL DEFAULT 100,
  PRIMARY KEY (`vs_email`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_visitorsblocked` (
  `vb_email` varchar(512) NOT NULL,
  `vb_admin` varchar(512) NOT NULL,
  `vb_when` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`vb_email`)
);
CREATE TABLE IF NOT EXISTS `{PR}tilbuci_visitorstate` (
  `vs_id` varchar(128) NOT NULL,
  `vs_movie` varchar(64) NOT NULL,
  `vs_user` varchar(128) NOT NULL,
  `vs_quick` tinyint(4) NOT NULL DEFAULT 0,
  `vs_scene` varchar(64) NOT NULL,
  `vs_about` varchar(512) NOT NULL DEFAULT '',
  `vs_value` mediumtext DEFAULT NULL,
  `vs_created` datetime NOT NULL DEFAULT current_timestamp(),
  `vs_updated` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`vs_id`),
  KEY `vs_movie` (`vs_movie`),
  KEY `vs_user` (`vs_user`),
  KEY `vs_quick` (`vs_quick`)
);
