1"use strict";(self.webpackChunkcalendy=self.webpackChunkcalendy||[]).push([[9280],{2197:function(e,a,t){t.d(a,{A:function(){return n}});t(96540);var s=t(58761);class n extends s.A{}},8283:function(e,a,t){function s(e,a=null){if(!e)return null;let t;t=a?(Array.isArray(a)?a:[a]).flatMap(a=>e.displayEntries({field:a})):e.displayEntries();return[...new Set(t.map(e=>e.type))].filter(e=>e).map(e=>`has-${e.replaceAll("_","-")}`).join(" ")}t.d(a,{e:function(){return s}})},13524:function(e,a,t){var s=t(96540),n=t(69099),i=t(55643);a.A=(e,a,t)=>{const{uploads:o,callbacks:l}=a,c=o.filter(e=>"photo"==e.type).length+e.filter(e=>"Photo"==e.attachable_type).length,r=o.filter(e=>"video"==e.type).length+e.filter(e=>"Video"==e.attachable_type).length,d=o.filter(e=>"document"==e.type).length+e.filter(e=>"Document"==e.attachable_type).length,p=(0,s.useMemo)(()=>{const e={...t};return t.photos.limitRemaining=(t.photos.limit||1/0)-c,t.videos.limitRemaining=(t.videos.limit||1/0)-r,t.documents.limitRemaining=(t.documents.limit||1/0)-d,t.photos.disabled=t.photos.hide||t.photos.limitRemaining<=0,t.videos.disabled=t.videos.hide||t.videos.limitRemaining<=0,t.documents.disabled=t.documents.hide||t.documents.limitRemaining<=0,e},[JSON.stringify(t),c,r,d]),h=(0,n.A)("photo",l),u=(0,n.A)("video",l),m=(0,n.A)("document",l),g=(0,s.useMemo)(()=>({photos:h,videos:u,documents:m}),[h,u,m]);return{mediaConfig:p,uploading:a,onDrop:(0,i.A)(a.callbacks,g,p)}}},47344:function(e,a,t){t.d(a,{A:function(){return Ne}});var s=t(74848),n=t(96540),i=t(71468),o=t(22464),l=t(81614),c=t(80916),r=t(73928),d=t(23129);function p({onValidate:e,onAddContent:a,types:t,callbacks:o}){const[c,p]=(0,n.useState)(!1),h=(0,i.d4)(e=>e.context.calendar),u=(0,i.d4)(e=>e.context.user),m=(0,i.d4)(e=>e.context.paths),g=(0,i.d4)(e=>o.selectAllCalendarsPermissions(e)),v=(0,i.d4)(e=>e.context.aws),b=(0,i.d4)(e=>e.context.isMobileApp),x=(0,n.useCallback)(e=>{p(!1),a(e)},[a]);return(0,s.jsxs)(n.Fragment,{children:[g.show_library?(0,s.jsx)("button",{className:"btn btn-link browse-library",onClick:()=>p(!0),children:(0,s.jsx)(l.A,{className:"fa fa-book",content:"Browse Library",disabled:b})}):(0,s.jsx)("a",{href:"#",className:"btn btn-link browse-library load-modal","data-url":`/calendars/${h.id}/library/plan_limit_modal`,children:(0,s.jsx)(l.A,{className:"fa fa-book",content:"Browse Library",disabled:b})}),c&&(0,s.jsx)(r.A,{calendar:h,user:u,paths:m,permissions:g,types:t,aws:v,isMobileApp:b,callbacks:o,children:(0,s.jsx)(d.A,{onValidate:e,onFinish:x})})]})}var h=n.memo(p),u=t(82493),m=t(13215);function g({calendarId:e,isMobileApp:a,onValidate:t,onUploadPhoto:i}){const[c,r]=(0,n.useState)(!1);return(0,s.jsxs)(n.Fragment,{children:[(0,s.jsx)("a",{className:"browse-unsplash",href:"#",onClick:e=>{(0,o.N)(e),r(!0)},children:(0,s.jsx)(l.A,{content:"Browse Unsplash",disabled:a,children:(0,s.jsx)(u.A,{})})}),c&&(0,s.jsx)(m.A,{isMobileApp:a,onValidate:t,onClose:()=>r(!1),calendarId:e,onUploadPhoto:i})]})}var v=t(25282),b=t(67290);function x({calendarId:e,isMobileApp:a,onValidate:t,onUploadPhoto:i}){const[c,r]=(0,n.useState)(!1);return(0,s.jsxs)(n.Fragment,{children:[(0,s.jsx)("a",{className:"browse-giphy",href:"#",onClick:e=>{(0,o.N)(e),r(!0)},children:(0,s.jsx)(l.A,{content:"Browse Giphy",disabled:a,children:(0,s.jsx)(v.A,{})})}),c&&(0,s.jsx)(b.A,{isMobileApp:a,onValidate:t,onClose:()=>r(!1),calendarId:e,onUploadPhoto:i})]})}var f=t(10526),j=t(7498),_=t(68889);function k({isMobileApp:e,calendarId:a,identity:t,onUploadPhoto:i,onUploadVideo:c,onUploadDocument:r}){const[d,p]=(0,n.useState)(!1);return(0,s.jsxs)(n.Fragment,{children:[(0,s.jsx)("a",{className:"browse-canva",href:"#",onClick:e=>{(0,o.N)(e),p(!0)},children:(0,s.jsx)(l.A,{content:"Import from Canva",disabled:e,children:(0,s.jsx)(j.A,{})})}),d&&(0,s.jsx)(_.A,{calendarId:a,isMobileApp:e,identity:t,onOpen:()=>p(!0),onClose:()=>p(!1),onUploadPhoto:i,onUploadVideo:c,onUploadDocument:r})]})}var y=t(69482),N=t(15734),C=t.n(N);var A=t(26916),w=t(64351),M=t(14540),P=t(82726);t(74626)(C());var S=({onClose:e,onUploadPhoto:a,onUploadVideo:t,onUploadDocument:i,onValidate:o,calendarId:l})=>
1{const[c,r]=(0,n.useState)(!1),[d,p]=(0,n.useState)([]),[h,u]=(0,n.useState)(!1),m=(0,n.useCallback)(e=>{const a=e.currentTarget.value;a?.match(M._t)||a?.match(M.oV)?(p(["Invalid URL: IP addresses are not allowed."]),u(!0)):(p([]),u(!1))},[]),g=(0,n.useCallback)(e=>{e.preventDefault(),p([]),b(P(e.currentTarget).find("input.import-url")[0].value)}),v=(0,n.useCallback)((e,a)=>{const t=e=>{const t=o((0,w.dV)(e));let s=null;p(t.entries("error").map(e=>e.message)),s=t.hasEntries("error"),s?r(!1):a(e)};C().post("/media_header_extractions.json").send({url:e}).setCsrfToken().end((a,s)=>{if(a||!s.ok)s.body.errors&&p(s.body.errors),r(!1);else{let a=s.body;"video"==a.type&&"video/mp4"==a.content_type?function(e,a){let t=document.createElement("video");t.preload="metadata",t.onloadedmetadata=function(){const e=t.duration;a(e)},t.src=e}(e,e=>{a={...a,duration:e},t(a)}):t(a)}})},[]),b=(0,n.useCallback)(s=>{s&&(r(!0),v(s,n=>{C().post("/import_media_from_urls.json").send({url:s,calendar_id:l}).setCsrfToken().end((s,o)=>{s||!o.ok?(o.body.errors&&p(o.body.errors),r(!1)):("photo"==n.type?a(o.body.media):"video"==n.type?t(o.body.media):"document"==n.type&&i(o.body.media),r(!1),e())})}))},[]);return(0,s.jsx)(A.A,{modalClassName:"small import-media-from-url-modal",open:!0,onClose:e,children:(0,s.jsxs)("div",{className:"modal-content-custom",children:[(0,s.jsx)("div",{className:"modal-header-custom",children:(0,s.jsx)("div",{className:"modal-title-custom",children:"Import media from URL"})}),(0,s.jsxs)("form",{onSubmit:g,children:[(0,s.jsxs)("div",{className:"modal-body-custom",children:[(0,s.jsx)("div",{className:"alert-container",children:d.map((e,a)=>(0,s.jsx)("div",{className:"alert alert-danger",children:e},a))}),(0,s.jsx)("div",{className:"hint",children:"You can upload a photo, video or document directly from a URL. Make sure the URL you include in the field below is pointing directly to the file you want to import. YouTube currently does not allow video importing from URLs."}),(0,s.jsxs)("div",{className:"form-field",children:[(0,s.jsx)("label",{htmlFor:"import-url",children:"Page Media URL"}),(0,s.jsx)("input",{type:"url",name:"import-url",onChange:m,placeholder:"http://",className:"form-control import-url"})]})]}),(0,s.jsxs)("div",{className:"modal-footer-custom",children:[(0,s.jsx)("button",{className:"button small secondary",onClick:e,children:"Cancel"}),(0,s.jsx)("input",{type:"submit",className:"button small",disabled:h,value:c?"Importing...":"Import"})]})]})]})})},U=t(95222),I=t(54954);const F="Generate an image for this post",D="Suggest five ideas for a new social media post for my brand. Please keep a mix of posts that: a) Are relevant to my industry and products; b) are based on events or festivities happening in the coming weeks; c) take inspiration from trends that are currently relevant on social media";function T(){const e=(0,i.d4)(e=>e.context.features?.loomly_ai),a=(0,U.Kf)(),t=(0,n.useCallback)(()=>{const e=(0,I.Tx)(),a=U.Ay.get("postDraft"),t=a&&(a.copy||a.subject||a.attachments&&a.attachments.length>0),s=e&&"new"!==e||t?F:D;if(U.Ay.openChatWithPrompt(s),window.trackPicoUserAction){const e=window.getLoomlyAiUiState?window.getLoomlyAiUiState():{};window.trackPicoUserAction("ai_assistant_toggled",{...e,open:!0,source:"post_builder_generate"})}},[]),o="undefined"!==typeof document&&!!document.getElementById("loomly-ai-chat-area");return e&&o?(0,s.jsxs)("button",{type:"button",className:"ai-generate-btn",onClick:t,disabled:a,children:[(0,s.jsx)("i",{className:"fa fa-magic"}),(0,s.jsx)("span",{children:"Generate"})]}):null}const E="No more photos are supported. Remove one to replace it.",V="No more videos are supported. Remove one to replace it.",L="No more documents are supported. Remove one to replace it.";function R({scope:e,validator:a,config:t,onDrop:r,setImportErrors:d,callbacks:p,source:u,services:m}){const v=(0,i.wA)(),b=(0,n.useCallback)(a=>v(p.addMedia({scope:e,value:a})),[JSON.stringify(e)]),j=(0,n.useCallback)(()=>v(p.clearFailedMedia({scope:e})),[JSON.stringify(e)]),_=(0,i.d4)(e=>e.context.isMobileApp),N=(0,i.d4)(e=>e.context.calendar),C=(0,c.NP)("Media",_,navigator.userAgent),[A,w]=(0,n.use
1State)(!1),M=(0,n.useCallback)(a=>v(p.addMediaFromLibrary({scope:e,value:a})),[JSON.stringify(e)]),P=!C&&!t.photos.hide,U=!C&&!t.videos.hide,I=!C&&!t.documents.hide,F=(0,i.d4)(e=>e.context.googleDrivePickerEnv),D=(0,i.d4)(e=>e.context.features.google_drive_picker),R=P&&!t.photos.disabled||U&&!t.videos.disabled||I&&!t.documents.disabled,W=P&&!t.photos.hideUnsplash&&!t.photos.disabled,$=P&&!t.photos.hideGiphy&&!t.photos.disabled,O=!t.photos.hideGoogleDrive&&D,G=P&&!t.photos.disabled||U&&!t.videos.disabled,B=(0,i.d4)(e=>e.context.features.canva_import),Y=R&&B,z=(0,n.useMemo)(()=>a.validateSelectionFor.bind(a,"library"),[a]),H=(0,n.useMemo)(()=>a.validateSelectionFor.bind(a,"unsplash"),[a]),J=(0,n.useMemo)(()=>a.validateSelectionFor.bind(a,"giphy"),[a]),K=(0,n.useMemo)(()=>a.validateSelectionFor.bind(a,"url"),[a]),Q=(0,n.useMemo)(()=>a.validateSelectionFor.bind(a,"google_drive"),[a]),X=(0,n.useCallback)(()=>{const e=["Facebook","Twitter","Instagram","LinkedIn","TikTok"].filter(e=>m[e.toLowerCase()]);let a="Up to 10MB is supported for all channels"+(m.twitter?" except Twitter, where up to 5MB is supported.":".");return 1!=t.photos.limit&&e.length>0&&(a+=" Uploading more than one photo is supported for "+[e.slice(0,-1).join(", "),e.slice(-1)[0]].join(e.length<2?"":e.length<3?" and ":", and ")+"."),a},[m,t.photos.limit]),q=(0,n.useCallback)(()=>"We recommend videos less than 50MB and shorter than 2 minutes for best performance. Up to 1GB and 15 minutes is supported, but may take a while to process.",[]),Z=(0,n.useCallback)(()=>"We recommend documents less than 30MB and with less than 100 pages for best performance. Up to 100MB and 300 pages is supported, but may take a while to process.",[]),ee=(0,n.useMemo)(()=>{const e=[];return P&&e.push("photos"),U&&e.push("videos"),I&&e.push("documents"),e.push("notes"),e},[P,U,I]);return(0,s.jsxs)(s.Fragment,{children:[R&&(0,s.jsx)(h,{onValidate:z,onAddContent:M,types:ee,callbacks:p}),P&&(0,s.jsx)(y.A,{type:"photos",onDrop:r,config:t.photos,children:(0,s.jsx)("a",{href:"#",onClick:o.N,className:t.photos.disabled?"disabled":"",children:(0,s.jsx)(l.A,{className:"fa fa-picture-o",content:t.photos.disabled?E:t.photos.hint||X(),popoverSize:"large",disabled:_})})}),U&&(0,s.jsx)(y.A,{type:"videos",onDrop:r,config:t.videos,children:(0,s.jsx)("a",{href:"#",onClick:o.N,className:t.videos.disabled?"disabled":"",children:(0,s.jsx)(l.A,{className:"fa fa-video-camera",content:t.videos.disabled?V:t.videos.hint||q(),popoverSize:"large",disabled:_})})}),I&&(0,s.jsx)(y.A,{type:"documents",onDrop:r,config:t.documents,children:(0,s.jsx)("a",{href:"#",onClick:o.N,className:t.documents.disabled?"disabled":"",children:(0,s.jsx)(l.A,{className:"fa fa-file-text",content:t.documents.disabled?L:t.documents.hint||Z(),popoverSize:"large",disabled:_})})}),G&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("a",{className:"import-from-url",href:"#",onClick:e=>{(0,o.N)(e),w(!0)},children:(0,s.jsx)(l.A,{className:"fa fa-download",content:"Import Media from URL",disabled:_})}),A&&(0,s.jsx)(S,{calendarId:N.id,onClose:()=>w(!1),onUploadPhoto:b,onUploadVideo:b,onUploadDocument:b,onValidate:K})]}),W&&(0,s.jsx)(g,{calendarId:N.id,isMobileApp:_,onValidate:H,onUploadPhoto:b}),$&&(0,s.jsx)(x,{calendarId:N.id,isMobileApp:_,onValidate:J,onUploadPhoto:b}),O&&(0,s.jsx)(f.A,{source:u,calendarId:N.id,labelText:"",googleDrivePickerEnv:F,photosLimit:t.photos.limit,videosLimit:t.videos.limit,documentsLimit:t.documents.limit,showPhotosChooser:P,showVideosChooser:U,showDocumentsChooser:I,photosDisabled:t.photos.disabled,videosDisabled:t.videos.disabled,documentsDisabled:t.documents.disabled,onUploadPhoto:b,onUploadVideo:b,onUploadDocument:b,setErrors:d,onClearFailed:j,onValidate:Q}),Y&&(0,s.jsx)(k,{isMobileApp:_,calendarId:N.id,identity:N.identities.canva,onUploadPhoto:b,onUploadVideo:b,onUploadDocument:b}),(0,s.jsx)(T,{})]})}var W=t(43375),$=t(43627),O=t(84746),G=t(46892),B=t(8283),Y=t(74979),z=t(73261),H=t(63844),J=t(74161);function K({attachment:e,scope:a,callbacks:t}){const o=(0,i.wA)(),l=(0,i.d4)(e=>e.context.calendar.id),c=(0,i.d4)(e=>
1e.context.aws),r=(0,w.QN)(e),[d,p]=(0,n.useState)(!1),h=(0,n.useCallback)(()=>p(!0),[]),u=(0,n.useCallback)(()=>p(!1),[]),m=(0,n.useCallback)((s,n)=>o(t.replaceAttachmentMedia({scope:a,attachment:e,value:n})),[e]);return(0,w.Yp)(e)&&r.processed?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:"btn btn-link action-icon",onClick:h,children:"Photo"===r.type?(0,s.jsx)(H.A,{color:"currentColor"}):(0,s.jsx)(J.A,{color:"currentColor"})}),(0,s.jsx)(z.A,{calendarId:l,attachment:r,awsConfig:c,editorOpen:d,onReplace:m,onClose:u})]}):null}var Q=n.memo(K);function X({attachment:e,index:a,scope:t,config:o,callbacks:l}){const c=(0,i.wA)(),r=e.attachable_type,d=(0,w.QN)(e),p=o.metadata||{},h=(0,n.useCallback)(()=>c(l.setAttachmentMetadataModalIndex({scope:t,value:a})),[a]);return d?.processed&&(p.alt_text&&"Photo"==r||p.link_url&&"Photo"==r||(p.tagged_users||p.tagged_products)&&"Photo"==r&&!d?.animated_gif||(p.cover_photo||p.video_title)&&"Video"==r||p.document_title&&"Document"==r)?(0,s.jsx)("button",{type:"button",className:"btn btn-link action-icon",onClick:h,children:(0,s.jsx)("i",{className:"fa fa-cog","aria-hidden":"true"})}):null}var q=n.memo(X);function Z({attachment:e,index:a,scope:t,validator:o,config:l,callbacks:c,disabled:r}){const d=(0,i.wA)(),p=(0,i.d4)(e=>e.context.isMobileApp),h=(0,i.d4)(e=>!t.service||null!=t.fragmentIndex||!!e.post.media_overrides[t.service]),u=l.metadata||{},m=e.metadata||{},g=(0,w.QN)(e),v=(0,w.ep)(e),b=(0,n.useCallback)(()=>d(c.removeAttachment({scope:t,value:e})),[]),x=(0,n.useCallback)(()=>d(c.fetchMediaProcessed({scope:t,media:g,attachment:e})),[JSON.stringify(t),g?.id]);(0,O.A)({file:h?g:null,websocketOptions:h&&g?{channel:(0,w._j)(g),id:g.id}:{},onProcessingUpdate:x,onFinishedProcessing:x});const f=(0,n.useMemo)(()=>{if(o&&o.attachmentValidatorFor&&o.attachmentValidatorFor(e))return o.attachmentValidatorFor(e);return new(o&&o.constructor.AttachmentValidator?o.constructor.AttachmentValidator:c.getValidatorFallback())(e,{service:t.service,parent:o}).validate()},[e,t.service,o]);let j=[];u.alt_text&&"Photo"==e.attachable_type&&(m.alt||"").length>0&&j.push((0,s.jsx)("span",{className:"metadata-tag",children:"ALT"},"ALT")),(0,w.Ci)(e,u)&&j.push((0,s.jsx)("span",{className:"metadata-tag",children:"VC"},"VC"));const{attributes:_,listeners:k,setNodeRef:y,setActivatorNodeRef:N,transform:C,transition:A}=(0,$.gl)({id:(0,w.bM)(e)}),M={transform:Y.Ks.Transform.toString(C),transition:A};return(0,s.jsxs)("div",{ref:y,style:M,className:`attachment ${g.processing?"processing":""} ${(0,B.e)(f)}`,children:[(0,s.jsx)("div",{ref:N,className:"drag-container",..._,...k,children:!r&&(0,s.jsx)("span",{className:"move-attachment fa fa-bars"})}),(0,s.jsx)("div",{className:"photo-container",children:(0,s.jsx)(G.A,{type:g.type,processing:g.processing,failed:g.processing_failed,version:"simple",src:v,placeholderWidth:75,loaderWidth:75,loaderHeight:75})}),(0,s.jsxs)("div",{className:"details-container",children:[(0,s.jsx)("div",{className:"file-name",children:g&&g.file_name}),j.length>0&&(0,s.jsx)("div",{className:"metadata-tags",children:j}),u.video_title&&(m.video_title||"").length>0&&"Video"==e.attachable_type&&(0,s.jsxs)("div",{className:"video-title",children:["Title: ",m.video_title]}),u.document_title&&(m.document_title||"").length>0&&"Document"==e.attachable_type&&(0,s.jsxs)("div",{className:"document-title",children:["Title: ",m.document_title]}),c.getInputValidationMessages(f)]}),!r&&(0,s.jsxs)("div",{className:"action-container",children:[!p&&(0,s.jsx)(Q,{attachment:e,index:a,scope:t,validator:f,config:l,callbacks:c}),(0,s.jsx)(q,{attachment:e,index:a,scope:t,validator:f,config:l,callbacks:c}),(0,s.jsx)("button",{className:"btn btn-link action-icon destroy-attachment",onClick:b,children:(0,s.jsx)("span",{className:"fa fa-tras
1h"})})]})]})}function ee({scope:e,validator:a,config:t,attachments:o,children:l,callbacks:c,disabled:r}){const d=(0,i.wA)(),p=o.map(e=>(0,w.bM)(e)),h=(0,n.useCallback)(({active:a,over:t})=>{if(t&&a.id!==t?.id){const s=o.findIndex(e=>(0,w.bM)(e)===a.id),n=o.findIndex(e=>(0,w.bM)(e)===t.id),i=(0,$.be)(o,s,n);d(c.sortAttachments({scope:e,value:i}))}},[o]);return(0,s.jsx)(W.Mp,{onDragEnd:h,children:(0,s.jsx)($.gB,{items:p,strategy:$._G,children:(0,s.jsxs)("div",{className:"attachments with-background",children:[o.map((n,i)=>(0,s.jsx)(Z,{attachment:n,index:i,scope:e,config:t,validator:a,callbacks:c,disabled:r},(0,w.bM)(n))),l]})})})}var ae=t(15298),te=t(85400),se=t(32604);function ne({attachment:e}){const a=(0,w.QN)(e),t="Video"==a.type||"Document"==a.type?a.medium_url:a.facebook_url,n=e.metadata||{};return(0,s.jsxs)("div",{className:"image-container",children:[(0,s.jsx)(G.A,{type:a.type,processing:a.processing,failed:a.processing_failed,version:"simple",src:t,placeholderWidth:400,loaderWidth:400,loaderHeight:400}),(n.tagged_users||[]).map(e=>(0,s.jsx)(te.A,{...e},e.username)),(n.tagged_products||[]).map(e=>(0,s.jsx)(se.A,{...e},e.product_id))]})}var ie=t(86404);function oe({scope:e,attachment:a,validator:t,onDone:i,callbacks:o}){const l=(0,w.QN)(a),c="Video"==l.type?l.medium_url:l.facebook_url,[r,d,{onSpecify:p}]=o.useUserImageTagging(e,a),h=(0,n.useCallback)(e=>{e.stopPropagation();const a=e.nativeEvent.target,t=a.offsetWidth,s=a.offsetHeight,n=((e.nativeEvent.offsetX<0?0:e.nativeEvent.offsetX)/t).toFixed(3),i=((e.nativeEvent.offsetY<0?0:e.nativeEvent.offsetY)/s).toFixed(3);p({x:n,y:i})},[c]);return(0,s.jsxs)("div",{className:"user-tagging-container",children:[(0,s.jsx)("div",{className:"image-container",children:(0,s.jsxs)("div",{className:"taggings-container",children:[(0,s.jsx)(G.A,{type:l.type,processing:l.processing,failed:l.processing_failed,version:"simple",src:c,placeholderWidth:400,loaderWidth:400,loaderHeight:400,onClick:h}),d]})}),(0,s.jsx)("button",{className:"button small primary",onClick:i,children:"Finish Tagging Users"}),t.hasEntries("error","tagged_users")&&o.getInputValidationMessages(t,"tagged_users"),(0,s.jsxs)("div",{className:"taggings-message",children:["Click anywhere on the image and press ",(0,s.jsx)("strong",{children:"Enter"})," to tag public Instagram users."," ",(0,s.jsx)(ie.A,{className:"default-icon glyphicon glyphicon-info-sign",content:"Unfortunately, search for usernames and tagging private profiles are not supported due to Instagram API limitations.",placement:"bottom",popoverSize:"large",mobileAppAlertTitle:"Searching for Usernames is unavailable."})]})]})}function le({scope:e,attachment:a,validator:t,onDone:i,callbacks:o}){const l=(0,w.QN)(a),c="Video"==l.type?l.medium_url:l.facebook_url,[r,d,{onSpecify:p}]=o.useProductImageTagging(e,a),h=(0,n.useCallback)(e=>{e.stopPropagation();const a=e.nativeEvent.target,t=a.offsetWidth,s=a.offsetHeight,n=((e.nativeEvent.offsetX<0?0:e.nativeEvent.offsetX)/t).toFixed(3),i=((e.nativeEvent.offsetY<0?0:e.nativeEvent.offsetY)/s).toFixed(3);p({x:n,y:i})},[c]);return(0,s.jsxs)("div",{className:"product-tagging-container",children:[(0,s.jsx)("div",{className:"image-container",children:(0,s.jsxs)("div",{className:"taggings-container",children:[(0,s.jsx)(G.A,{type:l.type,processing:l.processing,failed:l.processing_failed,version:"simple",src:c,placeholderWidth:400,loaderWidth:400,loaderHeight:400,onClick:h}),d]})}),(0,s.jsx)("button",{className:"button small primary",onClick:i,children:"Finish Tagging Products"}),t.hasEntries("error","tagged_products")&&o.getInputValidationMessages(t,"tagged_products"),(0,s.jsxs)("div",{className:"taggings-message",children:["Click anywhere on the image and press ",(0,s.jsx)("strong",{children:"Enter"})," to tag an Instagram shop product."," "]})]})}var ce=t(16719),re=t.n(ce),de=t(69099);const pe=(0,n.lazy)(()=>Promise.all([t.e(4761),t.e(663)]).then(t.bind(t,30171)));function he({scope:e,index:a,attachment:t,onDone:o,coverPhotoUploading:l,callbacks:r}){const d=(0,i.wA)(),p=t.attachable,h=t.metadata||{},[u,m]=(0,n.useState)(null),g=(0,n.useCallback)(e=>{m(e),e.subscribeToStateChange(a=>{a.paused||e.pause()})},[]),v=(0,de.A)("photo",l.callbacks),b=(0,n.useCallback)((a,s)=>d(r.setAttachmentMetadataField({scope:e,attachment:t,key:a,value:s})),[a]),x=(0,n.useCallback)(()=>{const e=u.getState().player.currentTime,a=re()("video-frame-selector-video","png"),t=(0,c.bX)(a.dataUri,"cover.png");v.methods.addFiles([t]),b("cover_photo_offset",e),o()},[u]);let f=new URL(p.url);return f.searchParams.set("crossorigin","anonymous"),(0,s.jsxs)("div",{className:"video-frame-selector-container",children:[(0,s.jsx)("div",{className:"cover-photo-frame-selector-panel",children:(0,s.jsx)(n.Suspense,{fallback:(0,s.jsxs)("div",{className:"loading-chunk",children:[(0,s.jsx)("div",{className:"fa fa-refresh fa-spin"}),"Loading..."]}),children:(0,s.jsx)(pe,{videoId:"video-frame-selector-video",crossOrigin:"anonymous",onPlayerAvailable:g,src:f.toString(),startTime:h.cover_photo_offset||0,muted:!0,autoPlay:!0,disablePlayButton:!0,timeSliderOnly:!0},p.url)})}),(0,s.jsxs)("div",{className:"action-buttons",children:[(0,s.jsx)("button",{className:"button small secondary",onClick:o,children:"Cancel"}),(0,s.jsx)("button",{className:"button small primary",onClick:x,children:"Use This Frame"})]})]})}function ue({scope:e,media:a,children:t,onBeforeRemove:o,callbacks:l}){const c=(0,i.wA)(),r=(0,i.d4)(a=>!e.service||null!=e.fragmentIndex||!!a.post.media_overrides[e.service]),d=a&&(0,w.Bo)(a),p=(0,n.useCallback)(()=>{o&&o(),c(l.removeMedia({scope:e}))},[JSON.stringify(e),o]);return(0,O.A)({file:r?a:null,websocketOptions:r&&a?{channel:(0,w._j)(a),id:a.id}:{},onFinishedProcessing:(0,n.useCallback)(()=>
1c(l.fetchMediaProcessed({scope:e,media:a})),[JSON.stringify(e),a?.id])}),(0,s.jsxs)("div",{className:"attachments with-background",children:[a&&(0,s.jsxs)("div",{className:"attachment "+(a.processing?"processing":""),children:[(0,s.jsx)("div",{className:"photo-container",children:(0,s.jsx)(G.A,{type:a.type,processing:a.processing,failed:a.processing_failed,version:"simple",src:d,placeholderWidth:75,loaderWidth:75,loaderHeight:75})}),(0,s.jsx)("div",{className:"details-container",children:(0,s.jsx)("div",{className:"file-name",children:a&&a.file_name})}),(0,s.jsx)("div",{className:"action-container",children:(0,s.jsx)("button",{className:"btn btn-link action-icon destroy-attachment",onClick:p,children:(0,s.jsx)("span",{className:"fa fa-trash"})})})]}),t]})}function me({scope:e,errors:a,retries:t,importErrors:n=[],callbacks:o}){const l=(0,i.d4)(e=>e.context.isMobileApp),r=(0,c.NP)("Media",l,navigator.userAgent),d=((0,i.d4)(a=>o.selectFailedMediaUploadsFor(a,e))||[]).map(e=>e.file_name?`${e.file_name}: ${e.processing_error}`:e.processing_error),p=a.map(e=>e.message).concat(n||[]).concat(d);return(0,s.jsxs)("div",{className:"media-alerts alert-container",children:[r&&(0,s.jsx)("div",{className:"alert alert-warning",children:r}),p&&p.map((e,a)=>(0,s.jsx)("div",{className:"alert alert-danger",children:e},a)),t.map((e,a)=>(0,s.jsxs)("div",{className:"alert alert-warning",children:["Encountered an error uploading ",e.name,". Retrying [",e.attemptNumber,"/3]..."]},a))]})}var ge=t(5222),ve=t(43796);function be({fileUpload:e,type:a="Photo"}){return(0,s.jsxs)("div",{className:"attachment uploading",children:["VideoCoverPhoto"!=a&&(0,s.jsx)("div",{className:"drag-container",children:(0,s.jsx)("span",{className:"move-attachment fa fa-bars"})}),(0,s.jsx)("div",{className:"photo-container",children:(0,s.jsx)(ge.A,{type:a,uploading:!0,width:75,height:75})}),(0,s.jsxs)("div",{className:"details-container",children:[e.name,(0,s.jsx)(ve.A,{progress:e.progress})]}),(0,s.jsx)("div",{className:"action-container"})]})}var xe=t(10918),fe=t(55643);const je=104857600;function _e({scope:e,attachment:a,index:t,config:o,mode:c,setMode:r,coverPhotoUploading:d,callbacks:p}){const h=(0,i.wA)(),u=(o.metadata||{}).cover_photo_uploading,m=(o.metadata||{}).cover_photo_uploading_disabled_message||`Choosing a custom thumbnail for ${xe.A[e.service]} is not supported at the moment.`,g={...e,attachmentIndex:t,type:"cover_photo"},v="video_frame_selecting"==c||d.uploads.length>0||a.cover_photo&&!a.cover_photo.processed,b=(0,w.Ci)(a,o.metadata),x=(0,n.useCallback)((t,s)=>h(p.setAttachmentMetadataField({scope:e,attachment:a,key:t,value:s})),[t]),f=(0,n.useCallback)(()=>x("cover_photo_offset",null),[x]),j=(0,n.useMemo)(()=>({...d.callbacks,onStart:(e,a)=>{f(),d.callbacks.onStart(e,a)}}),[d.callbacks]),{uploads:_,errors:k,retries:N,clearErrors:C}=d,A={limit:1,maxSize:(o.metadata||{}).cover_photo_max_size||je},M=(0,de.A)("photo",j),P=(0,fe.A)(d.callbacks,{photos:M},{photos:A});return(0,s.jsxs)("div",{className:"cover-photo-field-container",children:[(0,s.jsx)("h6",{children:"Cover Photo"}),(0,s.jsx)(me,{scope:e,errors:d.errors,retries:d.retries,callbacks:p}),!b&&(0,s.jsxs)("div",{className:"action-buttons",children:[(0,s.jsx)("button",{className:"button small primary",disabled:v,onClick:()=>r("video_frame_selecting"),children:"Choose Cover Image From Video"}),u?(0,s.jsx)("div",{className:"file-chooser photos-chooser",children:(0,s.jsx)(y.A,{onDrop:P,disabled:v,config:A,children:(0,s.jsx)("button",{className:"button small primary",disabled:v,children:"Upload Custom Cover Image"})})}):(0,s.jsx)(l.A,{placement:"bottom",popoverSize:"large",content:m,children:(0,s.jsxs)("button",{className:"button small next",disabled:!0,children:["Upload Custom Cover image ",(0,s.jsx)("i",{className:"fa fa-info-circle"})]})})]}),(b||d.uploads.length>0)&&(0,s.jsx)("div",{className:"media-attachments-v2",children:(0,s.jsx)(ue,{scope:g,media:b,onBeforeRemove:f,callbacks:p,children:d.uploads.map((e,a)=>(0,s.jsx)(be,{fileUpload:e,type:"VideoCoverPhoto"},a))})})]})}function ke({validator:e,scope:a,attachments:t,config:o,callbacks:l}){const r=(0,i.wA)(),d=(0,i.d4)(e=>
1e.context.isMobileApp),p=o.metadata||{},h=(0,i.d4)(e=>l.selectMetadataModalIndexFor(e,a)),u=t[h],m=u.attachable_type,g=(0,w.QN)(u),v=e.attachmentValidatorFor(u),b=u.metadata||{},x=(0,c.NP)("Media",d,navigator.userAgent),f=l.useCoverPhotoMediaUploading(a,h),j=!(f.uploads.length>0||u.cover_photo&&!u.cover_photo.processed),_=(0,n.useCallback)(()=>j&&r(l.setAttachmentMetadataModalIndex({scope:a,value:null})),[j]),k=(0,n.useCallback)((e,t)=>r(l.setAttachmentMetadataField({scope:a,attachment:u,key:e,value:t})),[j,h]),y=(0,n.useCallback)(()=>{j&&(M(null),r(l.setAttachmentMetadataModalIndex({scope:a,value:(h-1+t.length)%t.length})))},[h,t.length]),N=(0,n.useCallback)(()=>{j&&(M(null),r(l.setAttachmentMetadataModalIndex({scope:a,value:(h+1)%t.length})))},[h,t.length]),[C,M]=(0,n.useState)(null),P=(0,n.useCallback)(()=>M(null),[]),S={scope:a,attachment:u,index:h,validator:v,config:o,callbacks:l},U={tagging_users:(0,s.jsx)(oe,{...S,onDone:P}),tagging_products:(0,s.jsx)(le,{...S,onDone:P}),video_frame_selecting:(0,s.jsx)(he,{...S,onDone:P,coverPhotoUploading:f})}[C]||(0,s.jsx)(ne,{...S}),I={alt_text:p.alt_text&&"Photo"==m,video_title:p.video_title&&"Video"==m,cover_photo:p.cover_photo&&"Video"==m,link_url:p.link_url&&"Photo"==m,link_title:p.link_title&&"Photo"==m,document_title:p.document_title&&"Document"==m,tagged_users:p.tagged_users&&"Photo"==m&&!g?.animated_gif&&!d,tagged_products:p.tagged_products&&"Photo"==m&&!g?.animated_gif&&!d};return(0,s.jsx)(A.A,{modalClassName:"attachment-metadata-modal-v2",open:!0,onClose:_,children:(0,s.jsxs)("div",{className:"modal-content-custom",children:[(0,s.jsx)("div",{className:"modal-header-custom",children:(0,s.jsxs)("div",{className:"modal-title-custom",children:["Attachment Metadata ",!d&&(0,s.jsxs)(s.Fragment,{children:["(",h+1," of ",t.length,")"]})]})}),(0,s.jsxs)("div",{className:"modal-body-custom",children:[(0,s.jsx)("div",{className:"left-navigation",children:t.length>1&&(0,s.jsx)("button",{className:"btn btn-link navigate-previous",disabled:!j,onClick:y,children:(0,s.jsx)("i",{className:"fa fa-chevron-left"})})}),(0,s.jsx)("div",{className:"content",children:(0,s.jsxs)("div",{className:"row",children:[(0,s.jsx)("div",{className:"col-md-6",children:U}),(0,s.jsx)("div",{className:"col-md-6",children:(0,s.jsxs)("div",{className:"attachment-metadata-modal-fields",children:[!Object.values(I).some(e=>e)&&(0,s.jsxs)("div",{className:"no-fields-available",children:["No settings are available for this ",u.attachable_type.toLowerCase(),"."]}),I.alt_text&&(0,s.jsxs)("div",{className:"alt-text-field-container",children:[(0,s.jsx)("h6",{children:"Alt Text"}),(0,s.jsx)(ae.A,{element:"textarea",name:"alt",label:"Descriptive Text (Alt Text)",validator:v,validatorMessages:!0,value:b.alt,onFieldChange:k})]}),I.video_title&&(0,s.jsxs)("div",{className:"title-field-container",children:[(0,s.jsx)("h6",{children:"Title"}),(0,s.jsx)(ae.A,{element:"input",name:"video_title",label:"Video Title",validator:v,validatorMessages:!0,value:b.video_title,onFieldChange:k})]}),I.document_title&&(0,s.jsxs)("div",{className:"title-field-container",children:[(0,s.jsx)("h6",{children:"Title"}),(0,s.jsx)(ae.A,{element:"input",name:"document_title",label:"Document Title",validator:v,validatorMessages:!0,value:b.document_title,onFieldChange:k})]}),I.cover_photo&&!x&&(0,s.jsx)(_e,{scope:a,attachment:u,index:h,validator:v,config:o,mode:C,setMode:M,coverPhotoUploading:f,callbacks:l}),(I.link_url||I.link_title)&&(0,s.jsxs)("div",{className:"carousel-fields-container",children:[(0,s.jsx)("h6",{children:"Carousel Entry"}),I.link_url&&(0,s.jsx)(ae.A,{element:"input",name:"link_url",label:"Link URL",validator:v,validatorMessages:!0,value:b.link_url,onFieldChange:k}),I.link_title&&(0,s.jsx)(ae.A,{element:"input",name:"link_title",label:"Link Title",validator:v,validatorMessages:!0,value:b.link_title,onFieldChange:k})]}),(I.tagged_users||I.tagged_products)&&(0,s.jsxs)("div",{className:"tagging-field-container",children:[(0,s.jsxs)("h6",{children:["Tag ",I.tagged_users&&"Users",I.tagged_users&&I.tagged_products&&" or ",I.tagged_products&&"Products"]}),I.tagged_users&&(0,s.jsx)("button",{className:"button small primary",disabled:["tagging_users","tagging_products"].includes(C),onClick:()=>M("tagging_users"),children:"Tag Users"}),I.tagged_products&&(0,s.jsx)("button",{className:"button small primary",disabled:["tagging_users","tagging_products"].includes(C),onClick:()=>M("tagging_products"),children:"Tag Products"})]})]})})]})}),(0,s.jsx)("div",{className:"right-navigation",children:t.length>1&&(0,s.jsx)("button",{className:"btn btn-link navigate-next",disabled:!j,onClick:N,children:(0,s.jsx)("i",{className:"fa fa-chevron-right"})})})]}),(0,s.jsx)("div",{className:"modal-footer-custom with-border",children:(0,s.jsx)("button",{className:"button small primary",disabled:!j,onClick:_,children:"Done"})})]})})}function ye({scope:e,callbacks:a}){const t=(0,i.wA)();return(0,i.d4)(a=>!(!e.service||e.fragment)&&!!a.post.media_overrides[e.service])&&(0,s.jsxs)("div",{className:"field-overridden",children:["Media attachments have been fine tuned for this channel."," ",(0,s.jsx)("a",{href:"#",onClick:s=>{(0,o.N)(s),t(a.setMediaOverride({service:e.service,value:!1}))},children:"Reset media changes"}),"."]})}function Ne({scope:e,validator:a,config:t,uploading:o,onDrop:l,callbacks:c,services:r,source:d,disabled:p=!1}){const h=(0,i.d4)(a=>c.selectEffectiveAttachmentsFor(a,e)),u=(0,i.d4)(a=>
1null!=c.selectMetadataModalIndexFor(a,e)),[m,g]=(0,n.useState)([]),v=(0,i.d4)(e=>e.context.features.post_builder_updated_ui),b=(0,i.d4)(e=>e.context.paths),x=h.length>0||o.uploads.length>0;return(0,s.jsxs)("div",{className:"media-attachments-v2",children:[!p&&(0,s.jsxs)("div",{className:"misc-actions no-margin",children:[(0,s.jsx)("div",{className:"left-actions",children:(0,s.jsxs)("label",{className:"attachment-count",children:[t.title||"Customize media"," (",h.length,")"]})}),(0,s.jsx)("div",{className:"right-actions",children:(0,s.jsx)(R,{scope:e,validator:a,config:t,onDrop:l,setImportErrors:g,callbacks:c,source:d,services:r})})]}),v?!p&&!x&&(0,s.jsxs)("div",{className:"upload-container",children:[(0,s.jsx)("div",{className:"upload-image-placeholder",children:(0,s.jsx)("img",{src:b.post_builder_upload_illustration,alt:"Upload illustration",style:{height:"66px",width:"auto"}})}),(0,s.jsxs)("div",{className:"upload-container-action",children:[(0,s.jsx)(y.A,{type:"any",onDrop:l,config:t.any,children:(0,s.jsx)("button",{className:"upload-media-button",children:"Upload media"})}),(0,s.jsx)("div",{className:"upload-text",children:"or drag and drop your file"})]})]}):!p&&(0,s.jsxs)("div",{className:"drag-drop-allowed-notice",children:[(0,s.jsx)("i",{className:"fa fa-upload"}),"Drag and drop files"]}),c.getPostValidationMessages(a,"attachments"),x&&(0,s.jsx)(ee,{scope:e,validator:a,config:t,attachments:h,callbacks:c,disabled:p,children:o.uploads.map((e,a)=>(0,s.jsx)(be,{fileUpload:e,type:"Photo"},a))}),u&&(0,s.jsx)(ke,{validator:a,scope:e,attachments:h,config:t,callbacks:c}),v&&!p&&x&&(0,s.jsx)(y.A,{type:"any",onDrop:l,config:t.any,children:(0,s.jsx)("button",{className:"upload-media-button",style:{marginLeft:"0px"},children:"Add media"})}),(0,s.jsx)(ye,{scope:e,callbacks:c}),(0,s.jsx)(me,{scope:e,errors:o.errors,retries:o.retries,importErrors:m,callbacks:c})]})}},69099:function(e,a,t){t.d(a,{A:function(){return o}});var s=t(96540),n=t(71468),i=t(80916);function o(e,a){const t=(0,n.d4)(e=>e.context.calendar.id),o=(0,n.d4)(e=>e.context.aws);return(0,s.useMemo)(()=>(0,i.rn)({calendarId:t,awsConfig:o,uploadType:e,uploadSuccessEndpoint:`/${e}s.json`,callbacks:a}),[t,e,a])}},71972:function(e,a,t){t.d(a,{A:function(){return M}});t(96540);var s=t(39141),n=t(35916);class i extends n.A{}var o=t(23831);class l extends o.A{validate(){return this.validateBaseLimits(),this.validateMaxVideos(1),this.validateMaxDocuments(1),super.validate()}}var c=t(74848),r=t(32606),d=t(10918),p=t(29186),h=t(3750),u=t(68263),m=t(77964),g=t(4038),v=t(50968),b=t(62525),x=t(32341),f=t(868),j=t(57028),_=t(83981),k=t(2197),y=t(69739),N=t(38316),C=t(63189);const A={facebook:h.A,twitter:u.A,instagram:m.A,pinterest:g.A,linkedin:v.A,google:b.A,youtube:x.A,tiktok:f.A,custom_channel:y.A,snapchat:j.A,threads:_.A,bluesky:k.A};class w extends r.A{setup(){Object.keys(d.A).forEach(e=>{const a=A[e];this.children[e]=new a({},{...this.context,service:e,selected:this.data.services[e],parent:this})})}validateDerived(){return this.validateDerivedMissingIdentity(),this.validateDerivedFailingIdentity(),this.validateDerivedExpiredIdentity(),this.validateDerivedRevokedIdentity(),this.validateDerivedFacebookGroupsDeprecation(),super.validateDerived()}validateDerivedMissingIdentity(){const e=this.selectedServicesWithEntries({code:"missing"});let a=(0,c.jsxs)(c.Fragment,{children:["You have not yet made a connection to ",(0,p.WP)(e.map(e=>d.A[e])),this.context.cloneToCalendars.length>0?" for all selected calendars":"",". Publishing will need to be done manually until you've created a connection."," ",this.updateConnectionsPhrase("update",e)]});e.length>0&&this.add("warning","base",a)}validateDerivedFailingIdentity(){const e=this.selectedServicesWithEntries({code:"failing"});e.length>0&&this.add("warning","base",(0,c.jsxs)(c.Fragment,{children:["Your connection to ",(0,p.WP)(e.map(e=>d.A[e]))," has failed",this.context.cloneToCalendars.length>0?" in at least one of the selected calendars":"","."," ",this.updateConnectionsPhrase("refresh",e)]}))}validateDerivedExpiredIdentity(){const e=this.selectedServicesWithEntries({code:"expired"});e.length>0&&this.add("warning","base",(0,c.jsxs)(c.Fragment,{children:["Your connection to ",(0,p.WP)(e.map(e=>d.A[e]))," is expired",this.context.cloneToCalendars.length>0?" in at least one of the selected calendars":"","."," ",this.updateConnectionsPhrase("refresh",e)]}))}validateDerivedRevokedIdentity(){const e=this.selectedServicesWithEntries({code:"revoked"});e.length>0&&this.add("warning","base",(0,c.jsxs)(c.Fragment,{children:["Your connection to ",(0,p.WP)(e.map(e=>d.A[e]))," has been revoked",this.context.cloneToCalendars.length>0?" in at least one of the selected calendars":"","."," ",this.updateConnectionsPhrase("refresh",e)]}))}validateDerivedFacebookGroupsDeprecation(){this.selectedServicesWithEntries({code:"fb_groups_deprecation"}).length>0&&this.add("warning","base",(0,c.jsx)(c.Fragment,{children:"Automated publishing to a Facebook group is no longer supported."}))}selectedServicesWithEntries(...e){return Object.values(this.children).filter(a=>a.context.selected&&a.allEntries.apply(a,e).length>0).map(e=>e.service)}inCalendarsPhrase(e){return 1==e.length&&e[0].id==this.context.calendar.id?"":` in ${(0,p.WP)(e.map(e=>e.name))}`}updateConnectionsPhrase(e="update",a){const t=!this.context.branding.is_branding_context&&this.context.calendar.permissions.create_identity&&0==this.context.cloneToCalendars.length;
1return this.context.isMobileApp||this.context.isMobileWeb?"To manage your connections, please use the desktop version of Loomly.":t?(0,c.jsxs)(c.Fragment,{children:["Please ",e," your connections.",(0,c.jsx)("ul",{className:"inline-identities-list",children:a.map(e=>(0,c.jsx)("li",{children:(0,c.jsxs)("button",{type:"button",className:"btn btn-link",onClick:()=>(0,C.A)(`/calendars/${this.context.calendar.id}/identities/connect/${e}?inline=true`),"data-turbo":"false","data-pico-action":"connect_social_account_tapped","data-pico-info":JSON.stringify({calendar_id:`${this.context.calendar.id}`,connect_social_account_platform_name:e,connect_social_account_entry_point:"post_builder"}),children:["Connect ",(0,p.ZH)(e)]})},e))})]}):this.context.branding.is_branding_context?(0,c.jsxs)(c.Fragment,{children:["Please visit"," ",(0,c.jsx)("a",{href:this.context.branding.accounts_calendar_url,className:"btn btn-link",children:this.context.branding.loomly_host})," ","to ",e," your connections."]}):(0,c.jsxs)(c.Fragment,{children:["Please "," ",(0,c.jsxs)("button",{type:"button",className:"btn btn-link",onClick:()=>(0,N._)(0==this.context.cloneToCalendars.length?this.context.calendar.id:null),children:[e," your connections"]}),"."]})}}class M extends s.A{static get AttachmentValidator(){return i}static get SelectionValidator(){return l}setup(){return this.children.identities=new w({services:this.data.services},{...this.context,parent:this}),super.setup()}validate(){return this.validateCopyOrMediaPresent(),this.validateServiceSelected(),super.validate()}validateDate(){this.context.resubmitting||super.validateDate()}validateCopyOrMediaPresent(){0==(this.data.copy||"").length&&0==this.attachments.length&&this.add("error","next","Either copy or media is required.")}validateServiceSelected(){Object.values(this.data.services||{}).some(e=>e)||this.add("error","next","At least one service must be selected.")}}},81738:function(e,a,t){t.d(a,{A:function(){return x}});var s=t(74848),n=t(96540),i=t(26916),o=t(71468),l=t(15734),c=t.n(l);t(74626)(c());var r=({generationId:e,onFinishedGenerating:a})=>{const t=(0,n.useRef)(null),s=(0,n.useCallback)(()=>{e&&(t.current&&i(),t.current=App.cable.subscriptions.create({channel:"AiCaptionChannel",id:e},{rejected:()=>{console.error("Generating Caption Status Subscription Rejected")},received:e=>{t.current&&e.result?.completed&&(i(),a(e.result))}}))},[e,t]),i=(0,n.useCallback)(()=>{t.current&&(t.current.unsubscribe(),t.current=null)},[t]);(0,n.useEffect)(()=>(e?s():i(),()=>{i()}),[e])},d=t(95222);function p({aiCaptionLocation:e,useChatMode:a,caption:t,setCaption:i,onEditWithAI:l,onClose:p,onConfirm:h}){const u=(0,o.d4)(e=>e.context.calendar.id),[m,g]=(0,n.useState)(""),[v,b]=(0,n.useState)(!1),[x,f]=(0,n.useState)(!1),[j,_]=(0,n.use
1State)(null),k=(0,n.useRef)(null),y=m,N=(0,n.useCallback)(a=>{b(!1),_(null),a.success?(i(a.caption),k.current?.focus()):f(!0),window.trackPicoUserAction("ai_caption_generate_clicked",{ai_caption_location:e,ai_caption_mode:"generate",ai_caption_prompt:m.slice(0,500),ai_caption_output_caption:a.caption?.slice(0,500)})},[e,m]),C=()=>{if(!v){if(a){window.trackPicoUserAction("ai_caption_generate_clicked",{ai_caption_location:e,ai_caption_mode:"generate",ai_caption_prompt:m.slice(0,500)});return void(d.Ay.openChatWithPrompt(m)&&p({trackDismissal:!1}))}b(!0),f(!1),i(""),((e,a)=>c().post(`/calendars/${e}/ai_caption.json`).send({prompt:a}).setCsrfToken().then(e=>e.body.id))(u,m).then(e=>_(e)).catch(e=>{b(!1),_(null),f(!0)})}};return r({generationId:j,onFinishedGenerating:N}),(0,s.jsxs)("div",{className:"ai-caption-tab",children:[(0,s.jsx)("label",{children:"Prompt"}),(0,s.jsx)("textarea",{placeholder:"Generate a funny caption announcing a new sale...",value:m,onChange:e=>g(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),y&&C())}}),(0,s.jsx)("button",{className:`button ${t?"outline":"primary"} generate-button`,disabled:!y,onClick:C,children:v?(0,s.jsx)("i",{className:"fa fa-refresh fa-spin"}):t?"Generate again":"Generate"}),t&&(0,s.jsxs)("div",{className:"output-container",children:[(0,s.jsx)("label",{children:"Generated caption"}),(0,s.jsx)("textarea",{ref:k,value:t,onChange:e=>i(e.target.value)}),(0,s.jsxs)("span",{className:"output-buttons",children:[(0,s.jsx)("div",{className:"fa fa-copy",onClick:()=>navigator.clipboard.writeText(t)}),(0,s.jsx)("button",{className:"button secondary edit-with-ai-button",onClick:()=>{window.trackPicoUserAction("ai_caption_edit_with_ai_clicked",{ai_caption_location:e}),l(t)},children:"Edit with AI"}),(0,s.jsx)("button",{className:"button primary confirm-button",onClick:()=>{window.trackPicoUserAction("ai_caption_use_as_caption_clicked",{ai_caption_location:e,ai_caption_mode:"generate",ai_caption_output_caption:t.slice(0,500)}),h(t)},children:"Use as caption"})]})]}),x&&(0,s.jsx)("div",{className:"error-message",children:"There has been an error generating your caption. Please try again."})]})}var h=t(89545);const u=[{value:null,label:"Keep length"},{value:"shorten",label:"Shorten"},{value:"lengthen",label:"Lengthen"}],m=[{value:null,label:"Don't translate"},{value:"english",label:"English"},{value:"italian",label:"Italian"},{value:"french",label:"French"},{value:"spanish",label:"Spanish"},{value:"german",label:"German"},{value:"portuguese",label:"Portuguese"},{value:"russian",label:"Russian"},{value:"arabic",label:"Arabic"},{value:"chinese",label:"Chinese"},{value:"japanese",label:"Japanese"},{value:"korean",label:"Korean"},{value:"turkish",label:"Turkish"}];function g({aiCaptionLocation:e,useChatMode:a,inputCaption:t,setInputCaption:i,onClose:l,onConfirm:p}){const g=(0,o.d4)(e=>e.context.calendar.id),[v,b]=(0,n.useState)(""),[x,f]=(0,n.useState)(null),[j,_]=(0,n.use
1State)(null),[k,y]=(0,n.useState)(!1),[N,C]=(0,n.useState)(null),[A,w]=(0,n.useState)(""),[M,P]=(0,n.useState)(!1),[S,U]=(0,n.useState)(!1),I=(0,n.useRef)(null),F=(0,n.useRef)(null);(0,n.useEffect)(()=>{(()=>{const e=I.current;e&&(e.style.height="auto",e.style.height=`${e.scrollHeight}px`)})()},[v]);const D=t&&(v||x||j||k),T=(0,n.useCallback)(a=>{P(!1),C(null),a.success?(w(a.caption),F.current?.focus()):U(!0),window.trackPicoUserAction("ai_caption_generate_clicked",{ai_caption_location:e,ai_caption_mode:"edit",ai_caption_input_caption:t.slice(0,500),ai_caption_prompt:v.slice(0,500),ai_caption_length:x,ai_caption_translate_to:j,ai_caption_add_hashtags:k,ai_caption_output_caption:a?.caption?.slice(0,500)})},[e,t,v,x,j,k]),E=()=>{if(!M){if(a){window.trackPicoUserAction("ai_caption_generate_clicked",{ai_caption_location:e,ai_caption_mode:"edit",ai_caption_input_caption:t.slice(0,500),ai_caption_prompt:v.slice(0,500),ai_caption_length:x,ai_caption_translate_to:j,ai_caption_add_hashtags:k});const a=function(e,a,t,s,n){const i=[`Edit this caption: "${e}"`];return a&&i.push(a),"shorten"===t&&i.push("Make it shorter"),"lengthen"===t&&i.push("Make it longer"),s&&i.push(`Translate to ${s}`),n&&i.push("Add hashtags"),i.join(". ")+"."}(t,v,x,j,k);return void(d.Ay.openChatWithPrompt(a)&&l({trackDismissal:!1}))}P(!0),U(!1),w(""),((e,a,t,s,n,i)=>c().patch(`/calendars/${e}/ai_caption.json`).send({input_caption:a,prompt:t,length:s,language:n,add_hashtags:i}).setCsrfToken().then(e=>e.body.id))(g,t,v,x,j,k).then(e=>C(e)).catch(e=>{P(!1),C(null),U(!0)})}};return r({generationId:N,onFinishedGenerating:T}),(0,s.jsxs)("div",{className:"ai-caption-tab",children:[(0,s.jsx)("label",{children:"Caption"}),(0,s.jsx)("textarea",{placeholder:"Caption to be edited with the AI Assistant",value:t,onChange:e=>i(e.target.value)}),(0,s.jsx)("label",{children:"Prompt"}),(0,s.jsx)("textarea",{rows:1,ref:I,className:"small-prompt",value:v,onChange:e=>b(e.target.value),placeholder:"Make it sound more professional...",onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),D&&E())},style:{overflow:"hidden",resize:"none"}}),(0,s.jsxs)("span",{className:"edit-options",children:[(0,s.jsx)("span",{className:"ai-caption-select-wrap",children:(0,s.jsx)(h.A,{className:"ai-caption-select "+(x?"active":""),options:u,value:x?u.find(e=>e.value===x):null,onChange:e=>f(e?e.value:null),placeholder:"Change length..."})}),(0,s.jsx)("span",{className:"ai-caption-select-wrap",children:(0,s.jsx)(h.A,{className:"ai-caption-select "+(j?"active":""),options:m,value:j?m.find(e=>e.value===j):null,onChange:e=>_(e?e.value:null),placeholder:"Translate to..."})}),(0,s.jsxs)("button",{className:"checkbox-button "+(k?"active":""),onClick:()=>{y(!k)},children:[(0,s.jsx)("i",{className:"fa fa-hashtag"}),"Add hashtags"]})]}),(0,s.jsx)("button",{className:`button ${A?"outline":"primary"} generate-button`,disabled:!D,onClick:E,children:M?(0,s.jsx)("i",{className:"fa fa-refresh fa-spin"}):A?"Generate Again":"Generate"}),A&&(0,s.jsxs)("div",{className:"output-container",children:[(0,s.jsx)("label",{children:"Generated caption"}),(0,s.jsx)("textarea",{ref:F,value:A,onChange:e=>w(e.target.value)}),(0,s.jsxs)("span",{className:"output-buttons",children:[(0,s.jsx)("div",{className:"fa fa-copy",onClick:()=>navigator.clipboard.writeText(A)}),(0,s.jsx)("button",{className:"button primary confirm-button",onClick:()=>{window.trackPicoUserAction("ai_caption_use_as_caption_clicked",{ai_caption_location:e,ai_caption_mode:"edit",ai_caption_output_caption:A.slice(0,500)}),p(A)},children:"Use as caption"})]})]}),S&&(0,s.jsx)("div",{className:"error-message",children:"There has been an error generating your caption. Please try again."})]})}var v=({aiCaptionLocation:e,initialCaption:a,useChatMode:t,onClose:o,onConfirm:l})=>{const[c,r]=(0,n.useState)(a?"edit":"generate"),[d,h]=(0,n.useState)(""),[u,m]=(0,n.useState)(a);return(0,s.jsx)(i.A,{modalClassName:"ai-caption-modal",open:!0,onClose:o,closeOnOverlayClick:!1,children:(0,s.jsxs)("div",{className:"modal-content-custom",children:[(0,s.jsx)("div",{className:"modal-header-custom",children:(0,s.jsx)("div",{className:"modal-title-custom",children:"AI Caption"})}),(0,s.jsxs)("div",{className:"modal-body-custom",children:[(0,s.jsxs)("ul",{className:"nav nav-tabs nav-justified responsive-icons no-collapse",role:"tablist",children:[(0,s.jsx)("li",{role:"presentation",className:"generate"==c?"active":"",children:(0,s.jsx)("a",{role:"tab","data-toggle":"tab",href:"",onClick:()=>r("generate"),className:"tab-label",children:"Generate caption"})}),(0,s.jsx)("li",{role:"presentation",className:"edit"==c?"active":"",children:(0,s.jsx)("a",{role:"tab","data-toggle":"tab",href:"",onClick:()=>
1r("edit"),className:"tab-label",children:"Edit caption"})})]}),(0,s.jsxs)("div",{className:"tab-content",children:[(0,s.jsx)("div",{id:"generate-tab",role:"tabpanel","aria-labelledby":"generate-tab",className:"tab-pane "+("generate"==c?"active":""),children:(0,s.jsx)(p,{aiCaptionLocation:e,active:"generate"==c,useChatMode:t,caption:d,setCaption:h,onEditWithAI:e=>{m(e),r("edit")},onClose:o,onConfirm:l})}),(0,s.jsx)("div",{id:"edit-tab",role:"tabpanel","aria-labelledby":"edit-tab",className:"tab-pane "+("edit"==c?"active":""),children:(0,s.jsx)(g,{aiCaptionLocation:e,active:"edit"==c,useChatMode:t,inputCaption:u,setInputCaption:m,onClose:o,onConfirm:l})})]})]})]})})},b=t(82726);function x({aiCaptionLocation:e,initialCaption:a,onConfirm:t}){const i=(0,o.d4)(e=>e.context.calendar.id),l=(0,o.d4)(e=>e.context.features?.loomly_ai),c=(0,o.d4)(e=>e.context.calendar.permissions.ai_caption),[r,p]=(0,n.useState)(!1),h=(0,d.Kf)(),u=l;return l||c?(0,s.jsxs)(n.Fragment,{children:[(0,s.jsxs)("button",{className:"ai-caption-button",disabled:u&&h,onClick:()=>{if(u&&d.Ay.get("usageLimitHit")){const e=b("#usage-limit-modal");return void(e.length&&e.addClass("active"))}const a=window.getLoomlyAiUiState?window.getLoomlyAiUiState():{};window.trackPicoUserAction("ai_caption_button_clicked",{...a,ai_caption_location:e}),p(!0)},children:[(0,s.jsx)("i",{className:"fa fa-magic"})," AI Caption"]}),r&&(0,s.jsx)(v,{aiCaptionLocation:e,initialCaption:a,useChatMode:u,onClose:(a={})=>{const{trackDismissal:t=!0}=a;t&&window.trackPicoUserAction("ai_caption_dismissed",{ai_caption_location:e}),p(!1)},onConfirm:e=>{t(e),p(!1)}})]}):(0,s.jsxs)("button",{className:"ai-caption-button load-modal","data-url":`/calendars/${i}/ai_caption/plan_limit_modal`,onClick:()=>{window.trackPicoUserAction("ai_caption_button_clicked",{ai_caption_location:e})},children:[(0,s.jsx)("i",{className:"fa fa-magic"})," AI Caption"]})}},83981:function(e,a,t){t.d(a,{A:function(){return n}});t(96540);var s=t(58761);class n extends s.A{}},95988:function(e,a,t){t.d(a,{A:function(){return c}});var s=t(74848),n=t(96540),i=t(71468);const o=["post","reel","story","carousel"],l={post:"Feed",reel:"Reels",story:"Stories",carousel:"Carousel"};function c({service:e,postType:a,onChange:t,options:c={post:!0}}){const r=(0,i.wA)(),d=o.filter(e=>c[e]).map(i=>(0,s.jsxs)(n.Fragment,{children:[(0,s.jsx)("input",{id:`${e}_${i}_radio`,type:"radio",checked:a==i,value:i,onChange:a=>r(t({service:e,value:a.target.value}))}),(0,s.jsxs)("label",{htmlFor:`${e}_${i}_radio`,className:"toggle",children:[(0,s.jsx)("span",{className:"hidden-xs hidden-sm"}),1==c[i]?l[i]:c[i]]})]},i));return(0,s.jsxs)("div",{className:"story-toggle",children:[(0,s.jsx)("p",{children:"Select where to display your content"}),(0,s.jsx)("div",{className:`toggle-container ${e}-story-toggle`,children:d})]})}}}]); 2//# sourceMappingURL=9280-6e9a78c602c7e08e142a.chunk.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.