(()=>{"use strict";var e={n:t=>{var l=t&&t.__esModule?()=>t.default:()=>t;return e.d(l,{a:l}),l},d:(t,l)=>{for(var a in l)e.o(l,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:l[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,l=window.wp.blocks,a=window.wp.blockEditor,o=window.wp.components,i=window.wp.serverSideRender;var r=e.n(i);const n=window.wp.i18n,s=JSON.parse('{"UU":"vitalisite-fse/video"}');(0,l.registerBlockType)(s.UU,{edit:function({attributes:e,setAttributes:l}){const{videoType:i,youtubeUrl:d,videoId:c,videoUrl:u,posterUrl:p,posterId:v,aspectRatio:m}=e,b=(0,a.useBlockProps)({className:"vitalisite-video-block"});return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(a.InspectorControls,null,(0,t.createElement)(o.PanelBody,{title:(0,n.__)("Source vidéo","vitalisite-fse")},(0,t.createElement)(o.SelectControl,{label:(0,n.__)("Type de vidéo","vitalisite-fse"),value:i,options:[{label:"YouTube",value:"youtube"},{label:(0,n.__)("Upload","vitalisite-fse"),value:"upload"}],onChange:e=>l({videoType:e})}),"youtube"===i&&(0,t.createElement)(o.TextControl,{label:(0,n.__)("URL YouTube","vitalisite-fse"),value:d,onChange:e=>l({youtubeUrl:e}),placeholder:"https://www.youtube.com/watch?v=..."}),"upload"===i&&(0,t.createElement)(a.MediaUploadCheck,null,(0,t.createElement)(a.MediaUpload,{onSelect:e=>l({videoId:e.id,videoUrl:e.url}),allowedTypes:["video"],value:c,render:({open:e})=>(0,t.createElement)(t.Fragment,null,(0,t.createElement)(o.Button,{onClick:e,variant:"secondary",className:"editor-media-placeholder__button"},u?(0,n.__)("Changer la vidéo","vitalisite-fse"):(0,n.__)("Choisir une vidéo","vitalisite-fse")),u&&(0,t.createElement)("p",{style:{marginTop:"8px",fontSize:"12px",wordBreak:"break-all"}},u))}))),(0,t.createElement)(o.PanelBody,{title:(0,n.__)("Réglages","vitalisite-fse"),initialOpen:!1},(0,t.createElement)(o.SelectControl,{label:(0,n.__)("Ratio","vitalisite-fse"),value:m,options:[{label:"16:9",value:"16/9"},{label:"4:3",value:"4/3"},{label:"1:1",value:"1/1"},{label:"9:16",value:"9/16"}],onChange:e=>l({aspectRatio:e})}),(0,t.createElement)(a.MediaUploadCheck,null,(0,t.createElement)(a.MediaUpload,{onSelect:e=>l({posterId:e.id,posterUrl:e.url}),allowedTypes:["image"],value:v,render:({open:e})=>(0,t.createElement)(t.Fragment,null,(0,t.createElement)(o.Button,{onClick:e,variant:"secondary"},p?(0,n.__)("Changer le poster","vitalisite-fse"):(0,n.__)("Ajouter un poster","vitalisite-fse")),p&&(0,t.createElement)(t.Fragment,null,(0,t.createElement)("img",{src:p,alt:"poster",style:{marginTop:"8px",maxWidth:"100%",borderRadius:"4px"}}),(0,t.createElement)(o.Button,{onClick:()=>l({posterId:0,posterUrl:""}),variant:"link",isDestructive:!0,style:{marginTop:"4px"}},(0,n.__)("Supprimer le poster","vitalisite-fse"))))})))),(0,t.createElement)("div",{...b},(0,t.createElement)(r(),{block:s.UU,attributes:e,key:JSON.stringify(e)})))},save:()=>null})})();