1import { V as Video } from './Video-227d44f6.js'; 2import './file-url-9a71ec36.js'; 3import './Index-34f70ab5.js'; 4import './index-6d9f7a14.js'; 5import './svelte/svelte.js'; 6 7const Example_svelte_svelte_type_style_lang = ''; 8 9/* home/runner/work/gradio/gradio/js/video/Example.svelte generated by Svelte v4.2.2 */ 10const { 11 SvelteComponent, 12 add_flush_callback, 13 append, 14 attr, 15 bind, 16 binding_callbacks, 17 create_component, 18 destroy_component, 19 detach, 20 element, 21 empty, 22 init: init_1, 23 insert, 24 is_function, 25 mount_component, 26 noop, 27 safe_not_equal, 28 set_data, 29 text, 30 toggle_class, 31 transition_in, 32 transition_out 33} = window.__gradio__svelte__internal; 34function create_else_block(ctx) { 35 let div; 36 let t; 37 38 return { 39 c() { 40 div = element("div"); 41 t = text(/*value*/ ctx[2]); 42 }, 43 m(target, anchor) { 44 insert(target, div, anchor); 45 append(div, t); 46 }, 47 p(ctx, dirty) { 48 if (dirty & /*value*/ 4) set_data(t, /*value*/ ctx[2]); 49 }, 50 i: noop, 51 o: noop, 52 d(detaching) { 53 if (detaching) { 54 detach(div); 55 } 56 } 57 }; 58} 59 60// (18:0) {#if playable()} 61function create_if_block(ctx) { 62 let div; 63 let video_1; 64 let updating_node; 65 let current; 66 67 function video_1_node_binding(value) { 68 /*video_1_node_binding*/ ctx[6](value); 69 } 70 71 let video_1_props = { 72 muted: true, 73 playsinline: true, 74 src: /*samples_dir*/ ctx[3] + /*value*/ ctx[2] 75 }; 76 77 if (/*video*/ ctx[4] !== void 0) { 78 video_1_props.node = /*video*/ ctx[4]; 79 } 80 81 video_1 = new Video({ props: video_1_props }); 82 binding_callbacks.push(() => bind(video_1, 'node', video_1_node_binding)); 83 video_1.$on("loadeddata", /*init*/ ctx[5]); 84 85 video_1.$on("mouseover", function () { 86 if (is_function(/*video*/ ctx[4].play.bind(/*video*/ ctx[4]))) /*video*/ ctx[4].play.bind(/*video*/ ctx[4]).apply(this, arguments); 87 }); 88 89 video_1.$on("mouseout", function () { 90 if (is_function(/*video*/ ctx[4].pause.bind(/*video*/ ctx[4]))) /*video*/ ctx[4].pause.bind(/*video*/ ctx[4]).apply(this, arguments); 91 }); 92 93 return { 94 c() { 95 div = element("div"); 96 create_component(video_1.$$.fragment); 97 attr(div, "class", "container svelte-1de9zxs"); 98 toggle_class(div, "table", /*type*/ ctx[0] === "table"); 99 toggle_class(div, "gallery", /*type*/ ctx[0] === "gallery"); 100 toggle_class(div, "selected", /*selected*/ ctx[1]); 101 }, 102 m(target, anchor) { 103 insert(target, div, anchor); 104 mount_component(video_1, div, null); 105 current = true; 106 }, 107 p(new_ctx, dirty) { 108 ctx = new_ctx; 109 const video_1_changes = {}; 110 if (dirty & /*samples_dir, value*/ 12) video_1_changes.src = /*samples_dir*/ ctx[3] + /*value*/ ctx[2]; 111 112 if (!updating_node && dirty & /*video*/ 16) { 113 updating_node = true; 114 video_1_changes.node = /*video*/ ctx[4]; 115 add_flush_callback(() => updating_node = false); 116 } 117 118 video_1.$set(video_1_changes); 119 120 if (!current || dirty & /*type*/ 1) { 121 toggle_class(div, "table", /*type*/ ctx[0] === "table"); 122 } 123 124 if (!current || dirty & /*type*/ 1) { 125 toggle_class(div, "gallery", /*type*/ ctx[0] === "gallery"); 126 } 127 128 if (!current || dirty & /*selected*/ 2) { 129 toggle_class(div, "selected", /*selected*/ ctx[1]); 130 } 131 }, 132 i(local) { 133 if (current) return; 134 transition_in(video_1.$$.fragment, local); 135 current = true; 136 }, 137 o(local) { 138 transition_out(video_1.$$.fragment, local); 139 current = false; 140 }, 141 d(detaching) { 142 if (detaching) { 143 detach(div); 144 } 145 146 destroy_component(video_1); 147 } 148 }; 149} 150 151function create_fragment(ctx) { 152 let current_block_type_index; 153 let if_block; 154 let if_block_anchor; 155 let current; 156 const if_block_creators = [create_if_block, create_else_block]; 157 const if_blocks = []; 158 159 function select_block_type(ctx, dirty) { 160 return 0; 161 } 162 163 current_block_type_index = select_block_type(); 164 if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 165 166 return { 167 c() { 168 if_block.c(); 169 if_block_anchor = empty(); 170 }, 171 m(target, anchor) { 172 if_blocks[current_block_type_index].m(target, anchor); 173 insert(target, if_block_anchor, anchor); 174 current = true; 175 }, 176 p(ctx, [dirty]) { 177 if_block.p(ctx, dirty); 178 }, 179 i(local) { 180 if (current) return; 181 transition_in(if_block); 182 current = true; 183 }, 184 o(local) { 185 transition_out(if_block); 186 current = false;
187 }, 188 d(detaching) { 189 if (detaching) { 190 detach(if_block_anchor); 191 } 192 193 if_blocks[current_block_type_index].d(detaching); 194 } 195 }; 196} 197 198function instance($$self, $$props, $$invalidate) { 199 let { type } = $$props; 200 let { selected = false } = $$props; 201 let { value } = $$props; 202 let { samples_dir } = $$props; 203 let video; 204 205 async function init() { 206 $$invalidate(4, video.muted = true, video); 207 $$invalidate(4, video.playsInline = true, video); 208 $$invalidate(4, video.controls = false, video); 209 video.setAttribute("muted", ""); 210 await video.play(); 211 video.pause(); 212 } 213 214 function video_1_node_binding(value) { 215 video = value; 216 $$invalidate(4, video); 217 } 218 219 $$self.$$set = $$props => { 220 if ('type' in $$props) $$invalidate(0, type = $$props.type); 221 if ('selected' in $$props) $$invalidate(1, selected = $$props.selected); 222 if ('value' in $$props) $$invalidate(2, value = $$props.value); 223 if ('samples_dir' in $$props) $$invalidate(3, samples_dir = $$props.samples_dir); 224 }; 225 226 return [type, selected, value, samples_dir, video, init, video_1_node_binding]; 227} 228 229class Example extends SvelteComponent { 230 constructor(options) { 231 super(); 232 233 init_1(this, options, instance, create_fragment, safe_not_equal, { 234 type: 0, 235 selected: 1, 236 value: 2, 237 samples_dir: 3 238 }); 239 } 240} 241 242export { Example as default }; 243//# sourceMappingURL=Example-4295692b.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.