PageSourceSearch

https://rodcraft-corpo.onrender.com/_next/static/chunks/3366.5bfb93def6911c5c.js

js rodcraft-corpo.onrender.com collected 2026-10-03 11:43:53 UTC 53,556 bytes, 2 lines download raw bytes

1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7127b6cb-d3a4-483b-b600-993e56ec6825",e._sentryDebugIdIdentifier="sentry-dbid-7127b6cb-d3a4-483b-b600-993e56ec6825")}catch(e){}}(),(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3366],{53366:function(e,t,l){"use strict";l.r(t);var n=l(27573),i=l(84304),a=l(14081);let r="batch-edit-selection",o=["string","text","boolean","integer","float","date","date_time","slug"],c=["rich_text","single_block","structured_text"],s=[{key:"title",label:"Title",fieldType:"string"},{key:"description",label:"Description",fieldType:"text"},{key:"no_index",label:"No index",fieldType:"boolean"}],d={title:null,description:null,image:null,twitter_card:null,no_index:null},u=["title","description"];var p=l(7653),f=l(42291);let h=document.getElementById("root");if(!h)throw Error("Root element not found");let m=(0,f.createRoot)(h);function y(e){m.render((0,n.jsx)(p.StrictMode,{children:e}))}function b(e){let{ctx:t}=e;return(0,n.jsx)("div",{style:{margin:18},children:(0,n.jsx)("p",{children:(0,n.jsxs)("ol",{children:[(0,n.jsx)("li",{children:"If not already done, add the targeted new locale from the top right of the page. Most of the time, you will want to copy from an existing content (English) to keep the original page structure."}),(0,n.jsx)("li",{children:"Save the new locale"}),(0,n.jsx)("li",{children:"Click the Download button of the Translations Import/Export section to download the content into an Excel file"}),(0,n.jsx)("li",{children:"Translate column B of the Excel file without modifying column A"}),(0,n.jsx)("li",{children:"To upload the translated file and translate the content, click the Load from computer button and choose your translated Excel file"}),(0,n.jsx)("li",{children:"Save the content again if needed"})]})})})}function v(e){var t,l;let{ctx:i}=e,a=null==i?void 0:null===(l=i.parameters)||void 0===l?void 0:null===(t=l.errors)||void 0===t?void 0:t.match(/\[(.|[\r\n])*\]$/g);return(0,n.jsx)("div",{style:{margin:18},children:(null==a?void 0:a.length)?(0,n.jsx)("pre",{style:{overflow:"scroll"},children:a[0]}):"Undefined error, contact the administrator."})}var g=l(6228),x=l(1327),_=l(86750),j=l(78190),k=l(24322),w=l(29551);function T(e,t){let l=/([0-9]\]|.id|.upload_id|.slug|.layout|.color|.level|.item|.size|.variant|.focal_point.(x|y)|.video.(height|width)|.image|.is_dark|.is_left_variant|.is_full_width|.link|.type|.creator|.status|.first_published_at|.published_at|.updated_at|.created_at|.item_type|.schema|.relationships)$/,n=/\.video\./;for(let i in e)!e[i]||l.test(i)||n.test(i)||!(new RegExp('(\\.|\\[\\")'.concat(t,'(\\.|\\"]|\\[)')).test(i)||new RegExp('(\\.|\\[\\")'.concat(t,"$")).test(i))||"boolean"==typeof e[i]?delete e[i]:null!==e[i]&&"object"==typeof e[i]&&e[i].upload_id?delete e[i]:Array.isArray(e[i])?e[i]=e[i].map(e=>e?T(e,t):e):"object"==typeof e[i]&&(e[i]=T(e[i],t));return e}var C=l(41696);function A(e){var t,l,n,i,a,r,o;if(null==e?void 0:null===(n=e.content)||void 0===n?void 0:null===(l=n.document)||void 0===l?void 0:null===(t=l.children)||void 0===t?void 0:t.some(e=>{var t;return(null==e?void 0:e.type)==="block"||(null==e?void 0:null===(t=e.children)||void 0===t?void 0:t.some(e=>"inlineItem"===e.type))}))return e;for(let t in e)if(Array.isArray(e[t]))e[t]=e[t].map(e=>null!==e?A(e):e);else if(e[t]&&"object"==typeof e[t]&&e[t].schema&&"dast"===e[t].schema){let l=null===(a=e[t].document)||void 0===a?void 0:null===(i=a.children)||void 0===i?void 0:i.some(e=>{var t;return(null==e?void 0:e.type)==="itemLink"||(null==e?void 0:null===(t=e.children)||void 0===t?void 0:t.some(e=>"itemLink"===e.type))}),n=null===(o=e[t].document)||void 0===o?void 0:null===(r=o.children)||void 0===r?void 0:r.some(e=>{var t;return(null==e?void 0:e.type)==="inlineItem"||(null==e?void 0:null===(t=e.children)||void 0===t?void 0:t.some(e=>"inlineItem"===e.type))});if((l||n)&&!e[t].links)continue;e[t]="STRUCTURED_TEXT__"+(0,C.sY)(e[t],{renderLinkToRecord:e=>{let{record:t,children:l,transformedMeta:n}=e,i=Object.entries(n||{}).map(e=>{let[t,l]=e;return"".concat(t,'="').concat(l,'"')}).join(" ");return"<a ".concat(i,">").concat(l,"</a>")},renderInlineRecord:e=>{let{record:t}=e;return t.id||""}})}else"object"==typeof e[t]&&(e[t]=A(e[t]));return e}var I=l(69422);let N=(e,t)=>(0,I.k)({apiToken:e,environment:t});function S(){return(0,n.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"#000000",width:"24",height:"24",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"M12.71,11.29a1,1,0,0,0-.33-.21,1,1,0,0,0-.76,0,1,1,0,0,0-.33.21l-2,2a1,1,0,0,0,1.42,1.42l.29-.3V17a1,1,0,0,0,2,0V14.41l.29.3a1,1,0,0,0,1.42,0,1,1,0,0,0,0-1.42ZM20,8.94a1.31,1.31,0,0,0-.06-.27l0-.09a1.07,1.07,0,0,0-.19-.28h0l-6-6h0a1.07,1.07,0,0,0-.28-.19l-.1,0A1.1,1.1,0,0,0,13.06,2H7A3,3,0,0,0,4,5V19a3,3,0,0,0,3,3H17a3,3,0,0,0,3-3V9S20,9,20,8.94ZM14,5.41,16.59,8H15a1,1,0,0,1-1-1ZM18,19a1,
11,0,0,1-1,1H7a1,1,0,0,1-1-1V5A1,1,0,0,1,7,4h5V7a3,3,0,0,0,3,3h3Z"})})}function z(e){let{isDisabled:t,uploadFile:l,label:i}=e;return(0,n.jsxs)("div",{className:"relative overflow-hidden flex justify-center py-4 px-0",children:[(0,n.jsx)(g.z,{leftIcon:(0,n.jsx)(S,{}),children:i}),(0,n.jsx)("input",{className:"absolute text-xl top-0 left-0 opacity-0",id:"upload",accept:".xls,.xlsx",type:"file",disabled:t,onChange:e=>l(e)})]})}var L=l(52166),K=l(66803),M=l(73262),E=l(49216);function P(e){let{locales:t,changeLocale:l,label:i,keyPrefix:a,selectedLocale:r,className:o}=e,c=a||"locale-option";return(0,n.jsx)("div",{className:"w-full",children:(0,n.jsx)(L.L,{renderTrigger:e=>{let{open:t,onClick:l}=e;return(0,n.jsx)(g.z,{className:o,buttonSize:"xxs",fullWidth:!0,onClick:l,rightIcon:t?(0,n.jsx)(K.y8,{}):(0,n.jsx)(K.VA,{}),children:i})},children:(0,n.jsx)(M.v,{alignment:"right",children:t.map(e=>(0,n.jsx)(E.W,{active:e===r,onClick:()=>l(e),children:e},"".concat(c,"-").concat(e)))})})})}function R(){return new Date().toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).replace(" ","_").replace(". ","_").replace(", ","_").replace(":","_")}function F(e){let t=new k.Workbook,l=t.addWorksheet("Converted"),n=1,i=(e,t)=>{let i=l.getRow(n);i.getCell(1).value=e,i.getCell(2).value=(t||"-").toString(),n+=1},a=(e,t)=>{let l;return null!==e?(l=[e,t]).join("."):l=t,l},r=(e,t)=>{for(let l of Object.keys(t)){let n=t[l];"object"==typeof n&&null!==n?r(a(e,l),n):i(a(e,l),n)}};return r(null,e),l.getColumn(1).width=100,l.getColumn(2).width=200,t.xlsx.writeBuffer()}function U(){return(0,n.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",children:[(0,n.jsx)("path",{d:"M3 15C3 17.8284 3 19.2426 3.87868 20.1213C4.75736 21 6.17157 21 9 21H15C17.8284 21 19.2426 21 20.1213 20.1213C21 19.2426 21 17.8284 21 15",stroke:"#fff",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,n.jsx)("path",{d:"M12 3V16M12 16L16 11.625M12 16L8 11.625",stroke:"#fff",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}function B(e){let{ctx:t}=e,[l,i]=(0,p.useState)(!1),[r,o]=(0,p.useState)(t.locale),[c,s]=(0,p.useState)(""),d=N(t.currentUserAccessToken,t.environment);async function u(){var e;let l=await t.formValuesToItem(t.formValues),n=T((0,w.xH)(A(l)),r),i=await F(n),a=URL.createObjectURL(new Blob([i])),o=document.createElement("a");o.href=a,o.setAttribute("download","page_".concat(null===(e=t.item)||void 0===e?void 0:e.id,"_locale_").concat(t.locale,"_").concat(R(),".xls")),document.body.appendChild(o),o.click()}async function f(e){if(e.target.files){i(!0);let l=e.target.files[0],n=new FileReader;n.onload=async e=>{var l,n;s("Importing, please wait...");let a=new Uint8Array(null===(l=e.target)||void 0===l?void 0:l.result),r=new k.Workbook,o=a.buffer;await r.xlsx.load(o);let c={};r.worksheets[0].eachRow(e=>{c[e.getCell(1).value]=e.getCell(2).value});let u=await t.formValuesToItem(t.formValues),p={...(0,w.xH)(A({...u}),!0),...c};for(let e in p)p[e]&&"string"==typeof p[e]&&p[e].startsWith("STRUCTURED_TEXT__")&&(p[e]=await (0,_.Cx)(j.Qc(p[e].replace("STRUCTURED_TEXT__",""))));let f=(0,w.rr)(p).attributes;d.items.update(null===(n=t.item)||void 0===n?void 0:n.id,f).then(()=>console.log("Item updated")).catch(e=>{m(Error(e).message).then(()=>console.log(e))}),setTimeout(()=>{i(!1),s("Import successful, check new content, publish and save."),setTimeout(()=>s(""),5e3)},5e3)},n.readAsArrayBuffer(l)}}let h=async()=>{let e=await t.openModal({id:"HowToModal",title:"How to",initialHeight:910});t.notice(e)},m=async e=>{let l=await t.openModal({id:"ErrorModal",title:"File content error",initialHeight:800,parameters:{errors:e}});t.notice(l)};return(0,n.jsxs)(a.Xz,{ctx:t,children:[(0,n.jsxs)("div",{className:"font-bold mb-2",children:['Export "',r,'" translatable fields to .xls']}),(0,n.jsx)(P,{locales:t.formValues.internalLocales,changeLocale:o,label:"Select an other source language",selectedLocale:r}),(0,n.jsx)("p",{className:"mt-2 mb-4 text-xs",children:"If you don't see the language you're looking for, add a new locale to the page"}),(0,n.jsx)(g.z,{buttonSize:"xxs",buttonType:"primary",fullWidth:!0,onClick:()=>u(),leftIcon:(0,n.jsx)(U,{}),children:"Download"}),(0,n.jsx)("hr",{className:"my-6"}),(0,n.jsx)("div",{className:"font-bold mb-0",children:"Import translated fields from a .xls"}),l?(0,n.jsx)(x.$,{placement:"centered",style:{marginTop:"8rem"}}):(0,n.jsxs)("div",{children:[(0,n.jsx)(z,{label:"Load from computer",uploadFile:e=>f(e)}),c&&(0,n.jsx)("p",{children:(0,n.jsx)("b",{children:c})})]}),(0,n.jsx)("div",{children:(0,n.jsx)("a",{style:{cursor:"pointer"},onClick:h,children:(0,n.jsx)("b",{children:"How to ?"})})})]})}function D(e){let{models:t,changeModel:l,label:i,keyPrefix:a,selectedModel:r,className:o}=e,c=a||"model-option";return(0,n.jsx)("div",{className:"w-full",children:(0,n.jsx)(L.L,{renderTrigger:e=>{let{open:t,onClick:l}=e;return(0,n.jsx)(g.z,{className:o,buttonSize:"xxs",fullWidth:!0,onClick:l,rightIcon:t?(0,n.jsx)(K.y8,{}):(0,n.jsx)(K.VA,{}),children:i})},children:(0,n.jsx)(M.v,{alignment:"right",children:t.map(e=>(0,n.jsx)(E.W,{active:e.value===r,onClick:()=>l(e),children:e.label},"".concat(c,"-").concat(e.value)))})})})}let O=[{label:"Blog",value:"blog"},{label:"Articles",value:"article"},{label:"Catalog",value:"catalog"},{label:"Category",value:"category"},{label:"Products",value:"product"},{label:"Product details",value:"product_detail"},{label:"Case studies",value:"client_experience"},{label:"Customers",value:"customer"},{label:"Testimonie",value:"testimony"},{label:"Company",value:"company"},{label:"Industries",value:"industry"},{label:"Services",value:"service"},{label:"Solutions",value:"solution"},{label:"Processes",value:"process"},{label:"Series",value:"sub_category"},{label:"Header",value:"header"},{label:"Header Submenu",value:"dropdown_block"},{label:"Footer",value:"footer"},{label:"Legal",value:"legalpage"},{label:"Legal subpages",value:"legal"},{label:"Home",value:"home"},{label:"Digital twin",value:"digital_twin"},{label:"Sustainability",value:"sustainability"},{label:"Contact",value:"contact"},{label:"Article types",value:"article_type"},{label:"External links",value:"external_link"},{label:"Internal links",value:"internal_link"},{label:"Languages",value:"language"}];function V(e){let{ctx:t}=e,[l,i]=(0,p.useState)(!1),[r,o]=(0,p.useState)(!1),[c,s]=(0,p.useState)("en"),[d,u]=(0,p.useState)(O[1]),[f,h]=(0,p.useState)(""),m=N(t.currentUserAccessToken,t.environment);async function y(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=await m.items.list({page:{limit:30,offset:e},nested:!0,filter:{type:d.value},version:"current",locale:c});if(t.length){let l=await y(e+30);if(l.length)return[...t,...l]}return t}async function b(){i(!0);let e=await y(),t=T((0,w.xH)(e.map(e=>A(e))),c),l=await F(t),n=URL.createObjectURL(new Blob([l])),a=document.createElement("a");a.href=n,a.setAttribute("download","all_pages_".concat(R(),".xls")),document.body.appendChild(a),a.click(),i(!1)}async function v(e){if(e.target.files){o(!0),h("Loading file...");let t=e.target.files[0],l=new FileReader;l.onload=async e=>{var t;let l=new Uint8Array(null===(t=e.target)||void 0===t?void 0:t.result),n=new k.Workbook,i=l.buffer;await n.xlsx.load(i),h("Processing file...");let a={};n.worksheets[0].eachRow(e=>{a[e.getCell(1).value]=e.getCell(2).value});let r=await y(),c={...(0,w.xH)(A(r),!0),...a};for(let e in c)c[e]&&"string"==typeof c[e]&&c[e].startsWith("STRUCTURED_TEXT__")&&(c[e]=await (0,_.Cx)(j.Qc(c[e].replace("STRUCTURED_TEXT__",""))));for(let e of Object.values((0,w.rr)(c)))h("Processing ".concat(e.id,"...")),delete e.meta,await m.items.update(e.id,{...e,id:void 0}).then(e=>console.log("".concat(e.id," Updated"))).catch(t=>{console.log(t,e)});o(!1)},l.readAsArrayBuffer(t)}}return(0,n.jsx)(a.Xz,{ctx:t,noAutoResizer:!0,children:(0,n.jsxs)("div",{className:"w-[600px] mt-8 mx-auto",children:[(0,n.jsx)("h1",{className:"text-xl",children:"Translations Import/Export"}),!r&&(0,n.jsx)("p",{className:"mb-2 text-sm",children:"If you don't see the content you're looking for, add a new locale to a page"}),!r&&(l?(0,n.jsxs)("p",{children:[(0,n.jsx)("b",{children:"Export can take some time, please wait"}),(0,n.jsx)(x.$,{placement:"centered"})]}):(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)(P,{className:"bg-white",locales:t.site.attributes.locales,changeLocale:s,label:"Select a source language (".concat(c,")"),selectedLocale:c}
1),(0,n.jsx)(D,{className:"bg-white",models:O,changeModel:u,label:"Select a model (".concat(d.label,")"),selectedModel:d.value})]}),(0,n.jsx)("div",{style:{marginTop:8},children:(0,n.jsx)(g.z,{fullWidth:!0,buttonSize:"xxs",buttonType:"primary",onClick:b,leftIcon:(0,n.jsx)(U,{}),children:"Export translatable fields to .xls"})})]})),!(r||l)&&(0,n.jsx)("h4",{className:"text-center mt-4 mb-1",children:"or"}),r?(0,n.jsxs)("p",{children:[(0,n.jsx)("b",{children:f}),(0,n.jsx)(x.$,{placement:"centered",style:{top:"9rem"}})]}):!l&&(0,n.jsx)(z,{label:"Load from computer",uploadFile:e=>v(e)})]})})}var H=l(27558);function W(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function X(e){return o.includes(e)}function q(e,t){return X(e)?t?"localized_scalar":"unlocalized_scalar":"complex"}function Y(e){return"complex"!==e.kind&&("localized_scalar"===e.kind||!!e.block||!!e.seo)}function $(e){return!e.block&&(e.seo?u.includes(e.seo.property):"localized_scalar"===e.kind)}function Q(e){let{recordId:t,fieldApiKey:l,locale:n,blockId:i=""}=e;return"".concat(t,"::").concat(l,"::").concat(n,"::").concat(i)}function Z(e){let[t,l,n,i]=e.split("::");return{recordId:null!=t?t:"",fieldApiKey:null!=l?l:"",locale:null!=n?n:"",blockId:null!=i?i:""}}function J(e){return null==e?"":"boolean"==typeof e?e?"true":"false":String(e)}var G=l(95157),ee=l.n(G);let et=["localized_scalar","unlocalized_scalar","seo_localized","seo_shared","block_localized","block_shared","complex"],el={localized_scalar:"Localized scalars",unlocalized_scalar:"Unlocalized scalars",seo_localized:"SEO properties (per locale)",seo_shared:"SEO properties (shared across locales)",block_localized:"Block fields (per locale)",block_shared:"Block fields (shared across locales)",complex:"Complex fields"};function en(e){let t=e.seo?e.localized?"seo_localized":"seo_shared":e.block?e.localized?"block_localized":"block_shared":e.kind;return e.seo?{value:e.apiKey,label:e.apiKey,meta:"".concat(e.label," \xb7 ").concat(e.fieldType),group:t}:e.block?{value:e.apiKey,label:"".concat(e.block.blockApiKey,".").concat(e.block.fieldApiKey),meta:"".concat(e.block.containerLabel," › ").concat(e.block.blockName," \xb7 ").concat(e.fieldType),group:t}:{value:e.apiKey,label:e.label,meta:"".concat(e.apiKey," \xb7 ").concat(e.fieldType),group:t}}function ei(e){let{fields:t,selectedApiKeys:l,onChange:i}=e,a=(0,p.useMemo)(()=>{let e=t.map(en);return et.map(t=>({label:el[t],options:e.filter(e=>e.group===t)})).filter(e=>e.options.length>0)},[t]),r=(0,p.useMemo)(()=>new Map(t.map(e=>[e.apiKey,en(e)])),[t]),o=(0,p.useMemo)(()=>l.map(e=>r.get(e)).filter(e=>!!e),[l,r]);return(0,n.jsxs)("div",{className:ee().wrapper,children:[(0,n.jsxs)("div",{className:ee().header,children:[(0,n.jsx)("span",{className:ee().title,children:"Fields"}),(0,n.jsxs)("div",{className:ee().actions,children:[(0,n.jsx)("button",{type:"button",className:ee().linkButton,onClick:function(){i(t.filter($).map(e=>e.apiKey))},children:"Default"}),(0,n.jsx)("button",{type:"button",className:ee().linkButton,onClick:function(){i(t.map(e=>e.apiKey))},children:"All"}),(0,n.jsx)("button",{type:"button",className:ee().linkButton,onClick:function(){i([])},children:"None"})]})]}),(0,n.jsx)("div",{className:ee().select,children:(0,n.jsx)(H.lq,{inputId:"field-picker",name:"fields",classNamePrefix:"fieldPicker",placeholder:"Type to search fields — block fields as block.field…",options:a,value:o,onChange:function(e){i(e?e.map(e=>e.value):[])},isMulti:!0,isClearable:!0,closeMenuOnSelect:!1,blurInputOnSelect:!1,hideSelectedOptions:!1,noOptionsMessage:()=>"No matching field",formatOptionLabel:(e,t)=>
1{let{context:l}=t;return"menu"===l?(0,n.jsxs)("span",{className:ee().option,children:[e.label,(0,n.jsx)("span",{className:ee().optionMeta,children:e.meta})]}):e.label}})})]})}function ea(e){return W(e)&&"string"==typeof e.id?{id:e.id,attributes:W(e.attributes)?e.attributes:{}}:null}function er(e,t){return"rich_text"===t?Array.isArray(e)?e:[]:"single_block"===t?null==e?[]:[e]:W(e)?function e(t){return W(t)?"block"===t.type||"inlineBlock"===t.type?[t.item]:Array.isArray(t.children)?t.children.flatMap(e):[]:[]}(e.document):[]}function eo(e,t){if(!W(e)||"string"!=typeof e.id)return e;let l=t.get(e.id);return l?{type:"item",id:e.id,attributes:l}:e.id}function ec(e,t,l){return"rich_text"===t?Array.isArray(e)?e.map(e=>eo(e,l)):e:"single_block"===t?null==e?e:eo(e,l):W(e)?{...e,document:function e(t,l){return W(t)?"block"===t.type||"inlineBlock"===t.type?{...t,item:eo(t.item,l)}:Array.isArray(t.children)?{...t,children:t.children.map(t=>e(t,l))}:t:t}(e.document,l)}:e}function es(e,t){let l=W(e)?{...e}:{...d};for(let e of t)l[e.ref.property]=e.value;return l}function ed(e){if(!e.currentUserAccessToken)return null;let t=e.cmaBaseUrl;return(0,I.k)({apiToken:e.currentUserAccessToken,environment:e.environment,..."string"==typeof t?{baseUrl:t}:{}})}async function eu(e){let{client:t,itemTypeId:l,query:n,page:i,ids:a}=e,r=n.trim(),o=await t.items.list({filter:{type:l,...a?{ids:a}:{},...r?{query:r}:{}},page:{offset:(i-1)*30,limit:30},version:"current",nested:!0});return{records:o.map(e=>(function(e){let{id:t,type:l,meta:n,relationships:i,item_type:a,creator:r,__itemTypeId:o,...c}=e;return{id:t,attributes:c}})(e)),hasMore:30===o.length,nextPage:i+1}}function ep(e){if("string"==typeof e&&e.trim())return e;if("number"==typeof e||"boolean"==typeof e)return String(e);if(!W(e))return null;for(let t of Object.values(e)){let e=ep(t);if(e)return e}return null}function ef(e,t,l){if("complex"===t.kind||t.block)return null;if(t.seo)return function(e){var t;let l=null===(t=function(e){let{record:t,ref:l,locale:n}=e,i=t.attributes[l.containerApiKey];if(!W(i))return null;if(!l.containerLocalized)return i;let a=i[n];return W(a)?a:null}(e))||void 0===t?void 0:t[e.ref.property];return"string"==typeof l||"number"==typeof l||"boolean"==typeof l?l:null}({record:e,ref:t.seo,locale:l});let n=e.attributes[t.apiKey];if(t.localized){if(!W(n))return null;let e=n[l];return"string"==typeof e||"number"==typeof e||"boolean"==typeof e?e:null}return"string"==typeof n||"number"==typeof n||"boolean"==typeof n?n:null}function eh(e){let t=new Map;for(let n of e){var l;let e=null!==(l=t.get(n.ref.containerApiKey))&&void 0!==l?l:[];e.push(n),t.set(n.ref.containerApiKey,e)}return t}async function em(e){let{client:t,records:l,dirtyKeys:n,dirtyValues:i,fieldsByApiKey:a}=e,r=new Set(n.map(e=>Z(e).recordId).filter(Boolean)),o=[],c=[];for(let e of r){let r=l.find(t=>t.id===e);if(!r){c.push("Record ".concat(e," is not loaded."));continue}let s=function(e){let{record:t,dirtyKeys:l,dirtyValues:n,fieldsByApiKey:i}=e,a=t.attributes,r={},o=new Map,c=[],s=[];for(let e of l){var d,u,p,f;let{recordId:l,fieldApiKey:a,locale:r,blockId:h}=Z(e);if(l!==t.id)continue;let m=i.get(a);if(!m||!Y(m))continue;if(m.block){h&&c.push({ref:m.block,blockId:h,locale:r,value:null!==(d=n[e])&&void 0!==d?d:null});continue}if(m.seo){s.push({ref:m.seo,locale:r,value:null!==(u=n[e])&&void 0!==u?u:null});continue}if("localized_scalar"!==m.kind)continue;let y=null!==(p=o.get(a))&&void 0!==p?p:[];y.push({locale:r,value:null!==(f=n[e])&&void 0!==f?f:null}),o.set(a,y)}for(let[e,t]of o){let l=a[e],n=l&&"object"==typeof l&&!Array.isArray(l)?{...l}:{};for(let e of t)n[e.locale]=e.value;r[e]=n}return{...r,...function(e){let{record:t,edits:l}=e,n={};for(let[e,a]of eh(l)){let[l]=a;if(!l)continue;let r={containerApiKey:e,containerFieldType:l.ref.containerFieldType,containerLocalized:l.ref.containerLocalized},o=function(e){let{record:t,ref:l}=e;return new Map((function(e,t){let l=e.attributes[t.containerApiKey];return t.containerLocalized?W(l)?Object.values(l):[]:[l]})(t,l).flatMap(e=>er(e,l.containerFieldType)).map(ea).filter(e=>null!==e).map(e=>[e.id,e]))}({record:t,ref:r}),c=new Map;for(let e of a){var i;let t=o.get(e.blockId);t&&c.set(e.blockId,function(e){let{attributes:t,stored:l,ref:n,locale:i,value:a}=e;
1if(!n.fieldLocalized)return{...t,[n.fieldApiKey]:a};let r=t[n.fieldApiKey],o=null==l?void 0:l.attributes[n.fieldApiKey],c=W(r)?r:W(o)?o:{};return{...t,[n.fieldApiKey]:{...c,[i]:a}}}({attributes:null!==(i=c.get(e.blockId))&&void 0!==i?i:{},stored:t,ref:e.ref,locale:e.locale,value:e.value}))}0!==c.size&&(n[e]=function(e){let{record:t,ref:l,attributesByBlockId:n}=e,i=t.attributes[l.containerApiKey];return l.containerLocalized?W(i)?Object.fromEntries(Object.entries(i).map(e=>{let[t,i]=e;return[t,ec(i,l.containerFieldType,n)]})):i:ec(i,l.containerFieldType,n)}({record:t,ref:r,attributesByBlockId:c}))}return n}({record:t,edits:c}),...function(e){let{record:t,edits:l}=e,n={};for(let[e,i]of eh(l)){let[l]=i;l&&(n[e]=function(e){let{record:t,containerApiKey:l,containerLocalized:n,edits:i}=e,a=t.attributes[l];if(!n)return es(a,i);let r=W(a)?a:{};return Object.fromEntries([...Object.entries(r),...[...function(e){let t=new Map;for(let n of e){var l;let e=null!==(l=t.get(n.locale))&&void 0!==l?l:[];e.push(n),t.set(n.locale,e)}return t}(i)].map(e=>{let[t,l]=e;return[t,es(r[t],l)]})])}({record:t,containerApiKey:e,containerLocalized:l.ref.containerLocalized,edits:i}))}return n}({record:t,edits:s})}}({record:r,dirtyKeys:n,dirtyValues:i,fieldsByApiKey:a});if(0!==Object.keys(s).length)try{await t.items.update(e,s),o.push(e)}catch(l){let t=l instanceof Error?l.message:"Unknown error";c.push("".concat(e,": ").concat(t))}}return{updatedIds:o,errors:c}}var ey=l(12910),eb=l.n(ey);function ev(e){let t=e.search(/[-_]/);return(-1===t?e:e.slice(0,t)).toLowerCase()}function eg(e){let{ctx:t,locales:l,records:i,fields:a,dirtyValues:r,onCellChange:o,presentationTitleApiKey:c=null,emptyMessage:s}=e;return 0===i.length?(0,n.jsx)("div",{className:eb().empty,children:null!=s?s:"No records match the current filter. Adjust the filter and apply again."}):0===a.length?(0,n.jsx)("div",{className:eb().empty,children:"Select at least one field to display."}):(0,n.jsx)("div",{className:eb().scroll,children:(0,n.jsxs)("table",{className:eb().table,children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{className:eb().fieldCol,children:"Field"}),l.map(e=>(0,n.jsx)("th",{children:e},e))]})}),i.map(e=>(0,n.jsxs)("tbody",{className:eb().group,children:[(0,n.jsx)("tr",{className:eb().groupHeader,children:(0,n.jsx)("td",{colSpan:l.length+1,onClick:()=>{t.editItem(e.id)},style:{cursor:"pointer"},children:(0,n.jsxs)("div",{className:eb().groupTitle,children:[(0,n.jsx)("strong",{children:function(e,t){let l=e.attributes;if(t){let e=ep(l[t]);if(e)return e}for(let e of["title","name","label","slug","internal_name"]){let t=ep(l[e]);if(t)return t}return e.id}(e,c)}),(0,n.jsx)("span",{className:eb().recordId,children:e.id})]})})}),a.map(i=>(0,n.jsx)(ex,{ctx:t,locales:l,record:e,field:i,dirtyValues:r,onCellChange:o},"".concat(e.id,"-").concat(i.apiKey)))]},e.id))]})})}function ex(e){let{ctx:t,locales:l,record:i,field:a,dirtyValues:r,onCellChange:o}=e,c=a.block;if(!c)return(0,n.jsxs)("tr",{children:[(0,n.jsxs)("td",{className:eb().fieldCol,children:[(0,n.jsx)("div",{className:eb().fieldLabel,children:a.label}),(0,n.jsx)("div",{className:eb().fieldMeta,children:a.apiKey})]}),l.map((e,c)=>{let s=ev(e);return(0,n.jsx)("td",{children:(0,n.jsx)(ej,{ctx:t,record:i,field:a,locale:e,localeIndex:c,dirtyValues:r,onCellChange:o,getPropagateKeys:e=>(function(e){let{locales:t,field:l,record:n,sourceLanguageCode:i,scope:a}=e;return t.filter(e=>"language"!==a||ev(e)===i).map(e=>Q({recordId:n.id,fieldApiKey:l.apiKey,locale:l.localized?e:""}))})({locales:l,field:a,record:i,sourceLanguageCode:s,scope:e})})},"".concat(i.id,"-").concat(a.apiKey,"-").concat(e))})]});let s=new Map(l.map(e=>[e,function(e){let{record:t,ref:l,locale:n}=e;return er(function(e,t,l){let n=e.attributes[t.containerApiKey];return t.containerLocalized?W(n)?n[l]:null:n}(t,l,n),l.containerFieldType).filter(e=>W(e)&&function(e){if("string"==typeof e.__itemTypeId)return e.__itemTypeId;let t=e.relationships;if(!W(t))return null;let l=t.item_type;return W(l)&&W(l.data)&&"string"==typeof l.data.id?l.data.id:null}(e)===l.blockItemTypeId).map(ea).filter(e=>null!==e)}({record:i,ref:c,locale:e})])),d=Math.max(...[...s.values()].map(e=>e.length),0);return 0===d?(0,n.jsxs)("tr",{children:[(0,n.jsxs)("td",{className:eb().fieldCol,children:[(0,n.jsx)("div",{className:eb().fieldLabel,children:a.label}),(0,n.jsx)("div",{className:eb().fieldMeta,children:a.apiKey})]}),(0,n.jsx)("td",{colSpan:l.length,children:(0,n.jsxs)("span",{className:eb().blockNotice,children:["No ",c.blockName," block in ",c.c
1ontainerLabel]})})]}):(0,n.jsx)(n.Fragment,{children:Array.from({length:d},(e,t)=>(0,n.jsxs)("tr",{children:[(0,n.jsxs)("td",{className:eb().fieldCol,children:[(0,n.jsxs)("div",{className:eb().fieldLabel,children:[a.label,d>1&&(0,n.jsxs)("span",{className:eb().occurrence,children:["#",t+1]})]}),(0,n.jsx)("div",{className:eb().fieldMeta,children:a.apiKey})]}),l.map((e,c)=>{var d,u;let p=ev(e),f=null!==(u=null===(d=s.get(e))||void 0===d?void 0:d[t])&&void 0!==u?u:null;return(0,n.jsx)("td",{children:(0,n.jsx)(e_,{record:i,field:a,locale:e,localeIndex:c,occurrence:f,dirtyValues:r,onCellChange:o,getPropagateKeys:e=>(function(e){let{locales:t,field:l,record:n,blockIndex:i,occurrencesByLocale:a,sourceLanguageCode:r,scope:o}=e;if(!l.block)return[];let c=!l.localized;return t.filter(e=>"language"!==o||ev(e)===r).flatMap(e=>{var t,r;let o=null!==(r=null===(t=a.get(e))||void 0===t?void 0:t[i])&&void 0!==r?r:null;return o?[Q({recordId:n.id,fieldApiKey:l.apiKey,locale:c?"":e,blockId:o.id})]:[]})})({locales:l,field:a,record:i,blockIndex:t,occurrencesByLocale:s,sourceLanguageCode:p,scope:e})})},"".concat(i.id,"-").concat(a.apiKey,"-").concat(t,"-").concat(e))})]},"".concat(i.id,"-").concat(a.apiKey,"-").concat(t)))})}function e_(e){let{record:t,field:l,locale:i,localeIndex:a,occurrence:r,dirtyValues:o,onCellChange:c,getPropagateKeys:s}=e,d=l.block;if(!d)return(0,n.jsx)("span",{className:eb().muted,children:"—"});let u=!l.localized;return u&&a>0||!r?(0,n.jsx)("span",{className:eb().muted,children:"—"}):(0,n.jsx)(ek,{fieldType:l.fieldType,ariaLabel:u?"".concat(l.label," (").concat(d.blockName,")"):"".concat(l.label," (").concat(d.blockName,", ").concat(i,")"),baseValue:function(e){let{occurrence:t,ref:l,locale:n}=e,i=t.attributes[l.fieldApiKey],a=l.fieldLocalized?W(i)?i[n]:null:i;return"string"==typeof a||"number"==typeof a||"boolean"==typeof a?a:null}({occurrence:r,ref:d,locale:i}),dirtyKey:Q({recordId:t.id,fieldApiKey:l.apiKey,locale:u?"":i,blockId:r.id}),dirtyValues:o,onCellChange:c,canPropagate:!u,getPropagateKeys:s})}function ej(e){let{ctx:t,record:l,field:i,locale:a,localeIndex:r,dirtyValues:o,onCellChange:c,getPropagateKeys:s}=e;if(r>0&&("complex"===i.kind||!i.localized))return(0,n.jsx)("span",{className:eb().muted,children:"—"});if("complex"===i.kind)return(0,n.jsx)(g.z,{buttonSize:"xxs",buttonType:"muted",onClick:()=>{t.editItem(l.id)},children:"Open record"});if(!Y(i)){let e=ef(l,i,a);return(0,n.jsx)("input",{className:eb().input,value:J(e),disabled:!0,readOnly:!0,"aria-label":"".concat(i.label," (unlocalized)")})}return(0,n.jsx)(ek,{fieldType:i.fieldType,ariaLabel:i.localized?"".concat(i.label," (").concat(a,")"):i.label,baseValue:ef(l,i,a),dirtyKey:Q({recordId:l.id,fieldApiKey:i.apiKey,locale:i.localized?a:""}),dirtyValues:o,onCellChange:c,canPropagate:i.localized,getPropagateKeys:s})}function ek(e){let{fieldType:t,ariaLabel:l,baseValue:i,dirtyKey:a,dirtyValues:r,onCellChange:o,canPropagate:c,getPropagateKeys:s}=e,[d,u]=(0,p.useState)(0),f=a in r?r[a]:i,h=0===d?"language":"row",m=0===d?"Propagate to locales with the same language":"Propagate to all locales in this row";return(0,n.jsxs)("div",{className:eb().cellEditor,children:[(0,n.jsx)(ew,{fieldType:t,ariaLabel:l,baseValue:i,dirtyKey:a,dirtyValues:r,onCellChange:o}),c&&(0,n.jsx)("button",{type:"button",className:eb().propagateBtn,onClick:()=>{for(let e of s(h))o(e,f);u(e=>(e+1)%2)},title:m,"aria-label":m,children:"↗"})]})}function ew(e){let{fieldType:t,ariaLabel:l,baseValue:i,dirtyKey:a,dirtyValues:r,onCellChange:o}=e,c=a in r,s=c?r[a]:i;if("boolean"===t)return(0,n.jsxs)("select",{className:c?eb().inputDirty:eb().input,value:!0===s?"true":"false",onChange:e=>{o(a,"true"===e.target.value)},"aria-label":l,children:[(0,n.jsx)("option",{value:"false",children:"false"}),(0,n.jsx)("option",{value:"true",children:"true"})]});let d="integer"===t||"float"===t?"number":"date"===t?"date":"date_time"===t?"datetime-local":"text",u={className:c?eb().inputDirty:eb().input,value:J(s),step:"float"===t?"any":void 0,onChange:e=>{o(a,function(e,t,l){if("boolean"===e)return"true"===t;if("integer"===e){if(""===t.trim())return null;let e=Number.parseInt(t,10);return Number.isNaN(e)?"number"==typeof l?l:null:e}if("float"===e){if(""===t.trim())return null;let e=Number.parseFloat(t);return Number.isNaN(e)?"number"==typeof l?l:null:e}return t}(t,e.target.value,s))},"aria-label":l};return"text"===d?(0,n.jsx)("textarea",{...u}):(0,n.jsx)("input",{type:d,...u})}var eT=l(97206),eC=l(73308),eA=l.n(eC);function eI(e){let{query:t,isLoading:l,onQueryChange:i,onApply:a}=e;return(0,n.jsxs)("form",{className:eA().form,onSubmit:function(e){e.preventDefault(),a()},children:[(0,n.jsx)("div",{className:eA().field,children:(0,n.jsx)(eT.n,{id:"record-filter-query",name:"query",label:"Filter records",value:t,onChange:i})}),(0,n.jsx)(g.z,{type:"submit",buttonType:"muted",disabled:l,buttonSize:"xs",children:"Apply"})]})}var eN=l(14591),eS=l.n(eN);function ez(e){let{ctx:t,batchEdit:l,showRecordFilter:i=!0}
1=e,a=t.site.attributes.locales;return(0,n.jsxs)("div",{className:eS().panel,children:[!l.hasToken&&(0,n.jsxs)("div",{className:eS().notice,children:["Enable the ",(0,n.jsx)("code",{children:"currentUserAccessToken"})," permission for this private plugin to load and save records."]}),l.errorMessage&&(0,n.jsx)("div",{className:eS().error,children:l.errorMessage}),(0,n.jsxs)("div",{className:eS().filters,children:[i&&(0,n.jsx)(eI,{query:l.query,isLoading:l.isLoadingRecords,onQueryChange:l.setQuery,onApply:l.applyFilter}),l.isLoadingFields?(0,n.jsx)(x.$,{size:24}):(0,n.jsx)(ei,{fields:l.fields,selectedApiKeys:l.selectedFieldKeys,onChange:l.selectFieldKeys})]}),(0,n.jsx)("div",{className:eS().tableArea,children:l.isLoadingRecords&&0===l.records.length?(0,n.jsx)(x.$,{size:48,placement:"centered"}):(0,n.jsx)(eg,{ctx:t,locales:a,records:l.records,fields:l.selectedFields,dirtyValues:l.dirtyValues,onCellChange:l.changeCell,presentationTitleApiKey:l.presentationTitleApiKey,emptyMessage:i?void 0:"No selected record could be read."})}),l.hasMore&&(0,n.jsx)("div",{className:eS().footer,children:(0,n.jsx)(g.z,{buttonSize:"xxs",buttonType:"muted",disabled:l.isLoadingRecords,onClick:l.loadMore,children:l.isLoadingRecords?"Loading…":"Load more"})})]})}function eL(e){let{batchEdit:t}=e;return(0,n.jsx)(g.z,{buttonSize:"xxs",buttonType:"primary",disabled:!t.hasToken||0===t.dirtyCount||t.isSaving,onClick:()=>{t.save()},children:t.isSaving?"Saving…":t.dirtyCount>0?"Save changes (".concat(t.dirtyCount,")"):"Save changes"})}function eK(e){let t=e.attributes.validators,l=[];if("rich_text_blocks"in t&&l.push(...t.rich_text_blocks.item_types),"single_block_blocks"in t&&l.push(...t.single_block_blocks.item_types),"structured_text_blocks"in t&&l.push(...t.structured_text_blocks.item_types),"structured_text_inline_blocks"in t){var n,i;l.push(...null!==(i=null===(n=t.structured_text_inline_blocks)||void 0===n?void 0:n.item_types)&&void 0!==i?i:[])}return[...new Set(l)]}function eM(e){let t=e.attributes.field_type,l=e.attributes.localized;return{id:e.id,apiKey:e.attributes.api_key,label:e.attributes.label,fieldType:t,localized:l,kind:q(t,l)}}function eE(e){let t=e.attributes.localized,l=e.attributes.api_key,n=e.attributes.label;return(function(e){let t=e.attributes.appearance.parameters,l=W(t)?t.fields:null;return Array.isArray(l)?s.filter(e=>l.includes(e.key)):s})(e).map(i=>({id:"".concat(e.id,":").concat(i.key),apiKey:"".concat(l,".").concat(i.key),label:"".concat(n," › ").concat(i.label),fieldType:i.fieldType,localized:t,kind:q(i.fieldType,t),seo:{containerApiKey:l,containerLabel:n,containerLocalized:t,property:i.key}}))}async function eP(e,t){let l=[...new Set(t.flatMap(eK))];return new Map(await Promise.all(l.map(async t=>{var l,n;let i=e.itemTypes[t],a=await e.loadItemTypeFields(t);return[t,{name:null!==(l=null==i?void 0:i.attributes.name)&&void 0!==l?l:t,apiKey:null!==(n=null==i?void 0:i.attributes.api_key)&&void 0!==n?n:t,fields:a}]})))}var eR=l(59540),eF=l.n(eR);function eU(e){let{ctx:t}=e,{itemTypeId:l,recordIds:i}=function(e){let{itemTypeId:t,recordIds:l}=e;return{itemTypeId:"string"==typeof t?t:"",recordIds:Array.isArray(l)?l.filter(e=>"string"==typeof e):[]}}(t.parameters),r=function(e){let{ctx:t,itemTypeId:l,recordIds:n}=e,[i,a]=(0,p.useState)([]),[r,o]=(0,p.useState)([]),[s,d]=(0,p.useState)(null),[u,f]=(0,p.useState)(""),[h,m]=(0,p.useState)(""),[y,b]=(0,p.useState)([]),[v,g]=(0,p.useState)(1),[x,_]=(0,p.useState)(!1),[j,k]=(0,p.useState)(!1),[w,T]=(0,p.useState)(!1),[C,A]=(0,p.useState)(!1),[I,N]=(0,p.useState)({}),[S,z]=(0,p.useState)(null),L=(0,p.useRef)(t);L.current=t;let K=n&&n.length>0?n.join(","):null,M=(0,p.useMemo)(()=>i.filter(e=>r.includes(e.apiKey)),[i,r]),E=(0,p.useMemo)(()=>new Map(i.map(e=>[e.apiKey,e])),[i]),P=Object.keys(I).length,R=!!t.currentUserAccessToken,F=(0,p.useCallback)(async e=>{k(!0),z(null);try{let t=await L.current.loadItemTypeFields(e),l=await eP(L.current,t),n=function(e){let{modelFields:t,blockModels:l}=e,n=t.map(eM).sort((e,t)=>e.label.localeCompare(t.label)),i=t.flatMap(e=>eK(e).flatMap(t=>{let n=l.get(t);
1return n?function(e){let{containerField:t,blockItemTypeId:l,blockModel:n}=e,i=t.attributes.field_type;if(!c.includes(i))return[];let a=t.attributes.localized;return n.fields.filter(e=>X(e.attributes.field_type)).map(e=>{let r=e.attributes.localized,o=a||r;return{id:"".concat(t.id,":").concat(e.id),apiKey:"".concat(t.attributes.api_key,".").concat(n.apiKey,".").concat(e.attributes.api_key),label:e.attributes.label,fieldType:e.attributes.field_type,localized:o,kind:q(e.attributes.field_type,o),block:{containerApiKey:t.attributes.api_key,containerLabel:t.attributes.label,containerFieldType:i,containerLocalized:a,blockItemTypeId:l,blockApiKey:n.apiKey,blockName:n.name,fieldApiKey:e.attributes.api_key,fieldLocalized:r}}})}({containerField:e,blockItemTypeId:t,blockModel:n}):[]})).sort((e,t)=>e.apiKey.localeCompare(t.apiKey));return[...n,...i,...t.filter(e=>"seo"===e.attributes.field_type).flatMap(eE)]}({modelFields:t,blockModels:l});a(n),d(function(e){var t,l,n,i;let a=null!==(n=null===(l=e.itemType)||void 0===l?void 0:null===(t=l.relationships.presentation_title_field.data)||void 0===t?void 0:t.id)&&void 0!==n?n:null;if(!a)return null;let r=e.modelFields.find(e=>e.id===a);return null!==(i=null==r?void 0:r.attributes.api_key)&&void 0!==i?i:null}({itemType:L.current.itemTypes[e],modelFields:t})),o(n.filter($).map(e=>e.apiKey))}catch(e){z(e instanceof Error?e.message:"Failed to load fields"),a([]),d(null),o([])}finally{k(!1)}},[]),U=(0,p.useCallback)(async e=>{let t=ed(L.current);if(!t){z("This plugin needs the currentUserAccessToken permission. Enable it in the plugin permissions tab."),b([]),_(!1);return}T(!0),z(null);try{let l=await eu({client:t,itemTypeId:e.itemTypeId,query:e.query,page:e.page,ids:e.ids});b(t=>e.append?[...t,...l.records]:l.records),_(l.hasMore),g(e.page)}catch(t){z(t instanceof Error?t.message:"Failed to load records"),e.append||(b([]),_(!1))}finally{T(!1)}},[]);(0,p.useEffect)(()=>{l&&(N({}),f(""),m(""),b([]),g(1),_(!1),F(l),U({itemTypeId:l,query:"",page:1,append:!1,ids:K}))},[l,K,F,U]);let B=(0,p.useCallback)(()=>{l&&(!(Object.keys(I).length>0)||window.confirm("You have unsaved changes. Reload records and discard them?"))&&(N({}),m(u),U({itemTypeId:l,query:u,page:1,append:!1,ids:K}))},[l,I,u,K,U]),D=(0,p.useCallback)(()=>{l&&x&&!w&&U({itemTypeId:l,query:h,page:v+1,append:!0,ids:K})},[l,x,w,h,v,K,U]),O=(0,p.useCallback)((e,t)=>{N(l=>({...l,[e]:t}))},[]),V=(0,p.useCallback)(async()=>{let e=ed(L.current);if(!e){await L.current.alert("This action requires API access. Check the plugin permissions.");return}A(!0);try{let t=Object.keys(I),{updatedIds:n,errors:i}=await em({client:e,records:y,dirtyKeys:t,dirtyValues:I,fieldsByApiKey:E});if(n.length>0){let t=await eu({client:e,itemTypeId:null!=l?l:"",query:h,page:1,ids:K}),i=t.records,a=2,r=t.hasMore;
1for(;r&&a<=v;){let t=await eu({client:e,itemTypeId:null!=l?l:"",query:h,page:a,ids:K});i=[...i,...t.records],r=t.hasMore,a+=1}b(i),_(r),N({}),await L.current.notice("Saved ".concat(n.length," record").concat(1===n.length?"":"s","."))}i.length>0&&await L.current.alert(i.join("\n"))}catch(t){let e=t instanceof Error?t.message:"Save failed";await L.current.alert(e)}finally{A(!1)}},[I,y,E,l,h,v,K]);return{fields:i,selectedFields:M,selectedFieldKeys:r,selectFieldKeys:o,presentationTitleApiKey:s,query:u,setQuery:f,records:y,hasMore:x,isLoadingFields:j,isLoadingRecords:w,isSaving:C,dirtyValues:I,dirtyCount:P,errorMessage:S,hasToken:R,applyFilter:B,loadMore:D,changeCell:O,save:V}}({ctx:t,itemTypeId:l||null,recordIds:i});return(0,n.jsx)(a.Xz,{ctx:t,noAutoResizer:!0,children:(0,n.jsxs)("div",{className:eF().modal,children:[(0,n.jsxs)("header",{className:eF().bar,children:[(0,n.jsxs)("div",{className:eF().heading,children:[(0,n.jsx)("span",{className:eF().title,children:"Batch edit"}),(0,n.jsxs)("span",{className:eF().subtitle,children:[i.length," selected record",1===i.length?"":"s"]})]}),(0,n.jsx)("div",{className:eF().barActions,children:(0,n.jsx)(eL,{batchEdit:r})})]}),(0,n.jsx)(ez,{ctx:t,batchEdit:r,showRecordFilter:!1})]})})}var eB=l(492),eD=l(69557);function eO(e){return{youtubeApiKey:"string"==typeof(null==e?void 0:e.youtubeApiKey)?e.youtubeApiKey:"",youtubeChannelId:"string"==typeof(null==e?void 0:e.youtubeChannelId)?e.youtubeChannelId:""}}function eV(e){let{ctx:t}=e,l=eO(t.plugin.attributes.parameters),[i,r]=(0,p.useState)(l.youtubeApiKey),[o,c]=(0,p.useState)(l.youtubeChannelId),[s,d]=(0,p.useState)(!1),u=t.currentRole.meta.final_permissions.can_edit_schema,f=i!==l.youtubeApiKey||o!==l.youtubeChannelId;async function h(){d(!0);try{await t.updatePluginParameters({youtubeApiKey:i,youtubeChannelId:o}),await t.notice("Settings saved!")}finally{d(!1)}}return(0,n.jsxs)(a.Xz,{ctx:t,children:[(0,n.jsx)(eB.$,{title:"YouTube",children:(0,n.jsxs)(eD.N,{children:[(0,n.jsx)(eT.n,{id:"youtubeApiKey",name:"youtubeApiKey",label:"YouTube API Key",hint:"A YouTube Data API v3 key, used to read the channel's videos. Create a project at https://console.cloud.google.com",value:i,onChange:r,textInputProps:{disabled:!u}}),(0,n.jsx)(eT.n,{id:"youtubeChannelId",name:"youtubeChannelId",label:"YouTube Channel ID",hint:"The channel's id (starts with UC…) available at: youtube.com/account_advanced",value:o,onChange:c,textInputProps:{disabled:!u}})]})}),u&&(0,n.jsx)(g.z,{onClick:h,buttonType:"primary",fullWidth:!0,disabled:s||!f,children:s?"Saving...":"Save"})]})}class eH extends Error{constructor(e,t,l){super(e),this.status=t,this.reason=l}}async function eW(e,t,l){let n=new URL("".concat("https://www.googleapis.com/youtube/v3","/").concat(e));for(let[e,l]of Object.entries(t))n.searchParams.set(e,l);let i=await l(n.toString());if(!i.ok){var a,r,o,c,s;let t=await i.json().catch(()=>null),l=null==t?void 0:null===(o=t.error)||void 0===o?void 0:null===(r=o.errors)||void 0===r?void 0:null===(a=r[0])||void 0===a?void 0:a.reason,n=null!==(s=null==t?void 0:null===(c=t.error)||void 0===c?void 0:c.message)&&void 0!==s?s:i.statusText;throw new eH('YouTube API request to "'.concat(e,'" failed (').concat(i.status,"): ").concat(n),i.status,l)}return await i.json()}async function eX(e,t){var l,n,i,a;let{apiKey:r,channelId:o}=e,c=null===(a=(await eW("channels",{part:"contentDetails",id:o,key:r},t)).items)||void 0===a?void 0:null===(i=a[0])||void 0===i?void 0:null===(n=i.contentDetails)||void 0===n?void 0:null===(l=n.relatedPlaylists)||void 0===l?void 0:l.uploads;if(!c)throw new eH('No YouTube channel found for id "'.concat(o,'"'));return c}async function eq(e,t){let l,{apiKey:n,playlistId:i}=e,a=[];do{var r,o;let e=await eW("playlistItems",{part:"contentDetails",playlistId:i,maxResults:"50",key:n,...l?{pageToken:l}:{}},t);for(let t of null!==(r=e.items)&&void 0!==r?r:[]){let e=null===(o=t.contentDetails)||void 0===o?void 0:o.videoId;e&&a.push(e)}l=e.nextPageToken}while(l);return a}async function eY(e,t){let l,{apiKey:n,channelId:i}=e,a=[];do{var r,o;let e=await eW("search",{part:"id",channelId:i,type:"video",order:"date",maxResults:"50",key:n,...l?{pageToken:l}:{}},t);for(let t of null!==(r=e.items)&&void 0!==r?r:[]){let e=null===(o=t.id)||void 0===o?void 0:o.videoId;e&&a.push(e)}l=e.nextPageToken}while(l);return a}
1async function e$(e,t){let{apiKey:l,videoIds:n}=e,i=[];for(let e of function(e,t){let l=[];for(let t=0;t<e.length;t+=50)l.push(e.slice(t,t+50));return l}(n,0)){var a,r,o,c,s,d,u,p,f,h,m,y,b,v,g,x,_,j;for(let n of null!==(a=(await eW("videos",{part:"snippet,localizations",id:e.join(","),key:l},t)).items)&&void 0!==a?a:[])i.push({id:n.id,url:"https://www.youtube.com/watch?v=".concat(n.id),title:null!==(b=null===(r=n.snippet)||void 0===r?void 0:r.title)&&void 0!==b?b:"",description:null!==(v=null===(o=n.snippet)||void 0===o?void 0:o.description)&&void 0!==v?v:"",thumbnailUrl:null!==(_=null!==(x=null!==(g=null===(d=n.snippet)||void 0===d?void 0:null===(s=d.thumbnails)||void 0===s?void 0:null===(c=s.maxres)||void 0===c?void 0:c.url)&&void 0!==g?g:null===(f=n.snippet)||void 0===f?void 0:null===(p=f.thumbnails)||void 0===p?void 0:null===(u=p.high)||void 0===u?void 0:u.url)&&void 0!==x?x:null===(y=n.snippet)||void 0===y?void 0:null===(m=y.thumbnails)||void 0===m?void 0:null===(h=m.default)||void 0===h?void 0:h.url)&&void 0!==_?_:"",localizations:null!==(j=n.localizations)&&void 0!==j?j:{}})}return i}async function eQ(e){let t,{apiKey:l,channelId:n}=e,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:fetch,a=await eX({apiKey:l,channelId:n},i);try{t=await eq({apiKey:l,playlistId:a},i)}catch(e){if(e instanceof eH&&"playlistNotFound"===e.reason)t=await eY({apiKey:l,channelId:n},i);else throw e}return 0===t.length?[]:e$({apiKey:l,videoIds:t},i)}var eZ=l(44593),eJ=l(12877);async function eG(e){let{client:t,itemTypeId:l}=e,n=new Set,i=0;for(;;){let e=await t.items.list({filter:{type:l},page:{offset:i,limit:100},version:"current"});for(let t of e){let e=function(e){if(!e||"object"!=typeof e)return null;for(let t of Object.values(e))if(t&&"object"==typeof t&&"url"in t){let e=t.url;if("string"==typeof e&&e)return e}return null}(t.video),l=(0,eZ.jx)(e);l&&n.add(l)}if(e.length<100)break;i+=100}return n}function e0(e,t,l){let n={};for(let i of t)n[i]=function(e,t,l){var n;return(null===(n=e.localizations[t])||void 0===n?void 0:n[l])||e[l]}(e,i,l);return n}async function e1(e){let{client:t,itemTypeId:l,locales:n,videos:i}=e,a=[],r=[];for(let e of i)try{let i=await t.items.create({item_type:{type:"item_type",id:l},slug:function(e){let t=(0,eJ.N)(e.title)||"video",l=e.id.replace(/[^a-zA-Z0-9]/g,"").slice(-8).toLowerCase();return l?"".concat(t,"-").concat(l):t}(e),label:e.title,title:e0(e,n,"title"),description:e0(e,n,"description"),video:function(e,t){let l={url:e.url,title:e.title,width:1280,height:720,provider:"youtube",provider_uid:e.id,thumbnail_url:e.thumbnailUrl},n={};for(let e of t)n[e]=l;return n}(e,n)});a.push(i.id)}catch(l){let t=l instanceof Error?l.message:"Unknown error";r.push("".concat(e.title," (").concat(e.id,"): ").concat(t))}return{createdIds:a,errors:r}}function e2(e){let{ctx:t}=e,l=eO(t.plugin.attributes.parameters),i=l.youtubeApiKey.trim().length>0&&l.youtubeChannelId.trim().length>0,r=t.site.attributes.locales,[o,c]=(0,p.useState)("loading"),[s,d]=(0,p.useState)([]),[u,f]=(0,p.useState)(""),h=(0,p.useCallback)(async()=>{if(t.currentUserAccessToken){c("loading"),f("");try{let e=(0,I.k)({apiToken:t.currentUserAccessToken,environment:t.environment}),[n,i]=await Promise.all([eQ({apiKey:l.youtubeApiKey,channelId:l.youtubeChannelId}),eG({client:e,itemTypeId:t.itemType.id})]);d(n.filter(e=>!i.has(e.id))),c("ready")}catch(e){f(e instanceof Error?e.message:"Unknown error"),c("error")}}},[l.youtubeApiKey,l.youtubeChannelId,t.itemType.id]);if((0,p.useEffect)(()=>{i&&h()},[i,h]),!i)return(0,n.jsx)(a.Xz,{ctx:t,children:(0,n.jsx)("div",{style:{padding:"12px 16px",fontSize:"var(--font-size-s)"},children:"Configure the YouTube API key and channel ID in Settings → Plugins to enable syncing."})});async function m(){if(t.currentUserAccessToken&&0!==s.length){c("syncing");try{let e=(0,I.k)({apiToken:t.currentUserAccessToken,environment:t.environment}),{createdIds:l,errors:n}=await e1({client:e,itemTypeId:t.itemType.id,locales:r,videos:s});n.length>0?await t.alert("Synced ".concat(l.length," video(s) as drafts, ").concat(n.length," failed:\n").concat(n.join("\n"))):await t.notice("Synced ".concat(l.length," video(s) as drafts.")),await h()}catch(e){await t.alert(e instanceof Error?e.message:"Sync failed"),c("error")}}}return(0,n.jsx)(a.Xz,{ctx:t,children:(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 16px",backgroundColor:"var(--color--surface-muted)",borderRadius:"4px",gap:"12px"},children:[!1,"loading"===o?(0,n.jsx)(x.$,{}):"error"===o?(0,n.jsxs)("span",{style:{fontSize:"var(--font-size-s)"},children:["Could not check YouTube sync status: ",u]}):(0,n.jsx)("span",{style:{fontSize:"var(--font-size-s)"},children:0===s.length?"No videos to import from YouTube":"".concat(s.length," video").concat(s.length>
11?"s":""," to import from YouTube")}),(0,n.jsxs)("div",{style:{display:"flex",gap:"8px"},children:[(0,n.jsx)(g.z,{buttonSize:"xxs",buttonType:"muted",disabled:"loading"===o||"syncing"===o,onClick:()=>void h(),children:"Refresh"}),(0,n.jsx)(g.z,{buttonSize:"xxs",buttonType:"primary",disabled:"loading"===o||"syncing"===o||0===s.length,onClick:m,children:"syncing"===o?"Syncing…":"Sync now"})]})]})})}let e3="youtube-sync-outlet",e6="batch-edit";(0,i.$)({renderConfigScreen(e){y((0,n.jsx)(eV,{ctx:e}))},itemCollectionOutlets:e=>"video"!==e.attributes.api_key?[]:[{id:e3,initialHeight:0}],renderItemCollectionOutlet(e,t){e===e3&&y((0,n.jsx)(e2,{ctx:t}))},mainNavigationTabs:()=>[{label:"Translations Import/Export",icon:"file-export",pointsTo:{pageId:"global_import_export"},placement:["before","configuration"]}],itemFormSidebarPanels:()=>[{id:"page_translations_import_export",label:"Translations Import/Export"}],renderItemFormSidebarPanel(e,t){y((0,n.jsx)(B,{ctx:t}))},itemsDropdownActions:e=>e.attributes.modular_block||e.attributes.singleton?[]:[{id:e6,label:"Batch edit",icon:"table-list",parameters:{itemTypeId:e.id}}],async executeItemsDropdownAction(e,t,l){var n;if(e!==e6)return;let i=null===(n=l.parameters)||void 0===n?void 0:n.itemTypeId;"string"==typeof i&&await l.openModal({id:r,title:"Batch edit",width:"fullWidth",parameters:{itemTypeId:i,recordIds:t.map(e=>e.id)}})},itemFormDropdownActions:e=>e.attributes.singleton?[{id:e6,label:"Batch edit",icon:"table-list"}]:[],async executeItemFormDropdownAction(e,t){if(e===e6){if(!t.item){await t.alert("Save this record once before opening the batch edit grid.");return}if(t.isFormDirty){await t.alert("You have unsaved changes on this record. Save them before opening the batch edit grid.");return}await t.openModal({id:r,title:"Batch edit",width:"fullWidth",parameters:{itemTypeId:t.itemType.id,recordIds:[t.item.id]}})}},renderPage(e,t){y((0,n.jsx)(V,{ctx:t}))},renderModal(e,t){switch(e){case"HowToModal":y((0,n.jsx)(a.Xz,{ctx:t,children:(0,n.jsx)(b,{ctx:t})}));break;case"ErrorModal":y((0,n.jsx)(a.Xz,{ctx:t,children:(0,n.jsx)(v,{ctx:t})}));break;case r:y((0,n.jsx)(eU,{ctx:t}))}}})},12877:function(e,t,l){"use strict";l.d(t,{N:function(){return n}});let n=e=>e.toString().normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim().replace(/\s+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,"").replace(/_/g,"-")},44593:function(e,t,l){"use strict";function n(e){if(!e)return null;try{let t=new URL(e),l=t.hostname.toLowerCase();if(!(l.includes("youtube.com")||l.includes("youtu.be")))return null;if(l.includes("youtu.be"))return t.pathname.replace("/","")||null;if(t.searchParams.get("v"))return t.searchParams.get("v");let n=t.pathname.split("/"),i=n.findIndex(e=>"embed"===e);if(-1!==i&&n[i+1])return n[i+1];return n[n.length-1]||null}catch(l){let t=e.trim();return/^[a-zA-Z0-9_-]{8,}$/.test(t)?t:null}}function i(e,t){return"".concat("https://www.youtube.com/embed","/").concat(e,"?").concat(new URLSearchParams({autoplay:t?"1":"0",playsinline:"1",modestbranding:"1",rel:"0"}).toString())}function a(e){var t;let{provider:l,providerUid:a,url:r,autoplay:o=!0}=e;switch(null!==(t=null==l?void 0:l.toLowerCase())&&void 0!==t?t:function(e){if(!e)return null;try{let t=new URL(e).hostname.toLowerCase();if(t.includes("youtube.com")||t.includes("youtu.be"))return"youtube";if(t.includes("vimeo.com"))return"vimeo";if(t.includes("facebook.com")||t.includes("fb.watch"))return"facebook";return null}catch(e){return null}}(r)){case"youtube":{let e=a||n(r);return e?i(e,o):null}case"vimeo":{let e=a||function(e){if(!e)return null;try{let t=new URL(e);if(!t.hostname.toLowerCase().includes("vimeo.com"))return null;return t.pathname.split("/").find(e=>/^\d+$/.test(e))||null}catch(t){return/^\d+$/.test(e.trim())?e.trim():null}}(r);if(!e)return null;let t=new URLSearchParams({autoplay:o?"1":"0",playsinline:"1",dnt:"1"});return"".concat("https://player.vimeo.com/video","/").concat(e,"?").concat(t.toString())}case"facebook":{if(!r)return null;let e=new URLSearchParams({href:r,autoplay:o?"true":"false"});return"".concat("https://www.facebook.com/plugins/video.php","?").concat(e.toString())}default:return null}}function r(e){let{query:t,title:l,description:n,videoTitle:i}=e,a=t.trim().toLowerCase();if(!a)return!0;let r=[l,n,i].filter(e=>!!e).join(" ").toLowerCase();return a.split(/\s+/).every(e=>r.includes(e))}l.d(t,{JW:function(){return r},Lx:function(){return a},Qs:function(){return i},jx:function(){return n}})},69422:function(e,t,l){"use strict";l.d(t,{k:function(){return n.k}});var n=l(61675)},14591:function(e){e.exports={panel:"BatchEditPanel_panel__bKODn",filters:"BatchEditPanel_filters__6DcNO",tableArea:"BatchEditPanel_tableArea__jPgfh",footer
1:"BatchEditPanel_footer__F_xaf",notice:"BatchEditPanel_notice__7piYp",error:"BatchEditPanel_error__GjEmV"}},95157:function(e){e.exports={wrapper:"FieldPicker_wrapper__cc6lb",header:"FieldPicker_header__l9biK",title:"FieldPicker_title__kfAsb",actions:"FieldPicker_actions__Ad4jE",linkButton:"FieldPicker_linkButton__4il6e",select:"FieldPicker_select__zSl3R",option:"FieldPicker_option__tyyzD",optionMeta:"FieldPicker_optionMeta__YTNgJ"}},12910:function(e){e.exports={scroll:"LocaleTable_scroll__Dzgmw",table:"LocaleTable_table__FME2h",fieldCol:"LocaleTable_fieldCol__l8i9_",groupHeader:"LocaleTable_groupHeader__R5kO_",groupTitle:"LocaleTable_groupTitle__qcXtN",recordId:"LocaleTable_recordId__LKMlz",fieldLabel:"LocaleTable_fieldLabel__PvXqP",fieldMeta:"LocaleTable_fieldMeta__6PXCQ",occurrence:"LocaleTable_occurrence__BKF_D",blockNotice:"LocaleTable_blockNotice__91cPi",input:"LocaleTable_input__qBar_",inputDirty:"LocaleTable_inputDirty__hWlaV",muted:"LocaleTable_muted__dMbKd",empty:"LocaleTable_empty__I6I1b",cellEditor:"LocaleTable_cellEditor__NzSXh",propagateBtn:"LocaleTable_propagateBtn__6bnEV"}},73308:function(e){e.exports={form:"RecordFilter_form__9uCyR",field:"RecordFilter_field__8RQiw"}},59540:function(e){e.exports={modal:"BatchEditModal_modal__JTRZ1",bar:"BatchEditModal_bar__C4uL6",heading:"BatchEditModal_heading__XaII9",title:"BatchEditModal_title__N9Bdi",subtitle:"BatchEditModal_subtitle__E2oMl",barActions:"BatchEditModal_barActions__Nl5T9"}}}]);
2//# sourceMappingURL=3366.5bfb93def6911c5c.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.