@lit-pigeon/core 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lit Pigeon Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("immer"),j=require("nanoid");class ${constructor(t){this._steps=[],this._selection=null,this._selectionSet=!1,this._meta=new Map,this._doc=t}get steps(){return this._steps}get selection(){return this._selection}get selectionSet(){return this._selectionSet}get meta(){return this._meta}get doc(){return this._doc}addStep(t){return this._doc=t.apply(this._doc),this._steps.push(t),this}setSelection(t){return this._selection=t,this._selectionSet=!0,this}setMeta(t,e){return this._meta.set(t,e),this}getMeta(t){return this._meta.get(t)}}function m(o,t,e,n){return{type:o,path:t,apply(r){return B.produce(r,e)},invert(r){return m(`${o}:invert`,t,n,e)}}}function w(){return j.nanoid(10)}function g(o=0){return{top:o,right:o,bottom:o,left:o}}function z(){return{content:"<p>Enter your text here</p>",padding:g(10),lineHeight:"1.5",textAlign:"left"}}function q(){return{src:"",alt:"",width:"auto",padding:g(10),alignment:"center"}}function N(){return{content:"<p>Click me</p>",href:"#",backgroundColor:"#3b82f6",textColor:"#ffffff",borderRadius:4,padding:g(10),innerPadding:{top:12,right:24,bottom:12,left:24},fontSize:16,fontWeight:"600",alignment:"center",fullWidth:!1}}function U(){return{borderColor:"#e2e8f0",borderWidth:1,borderStyle:"solid",padding:g(10),width:"100%"}}function F(){return{height:20}}function K(){return{icons:[],iconSize:32,spacing:8,alignment:"center",padding:g(10)}}function G(){return{content:"",padding:g(0)}}function Y(){return{backgroundUrl:"",backgroundPosition:"center center",mode:"fluid-height",width:600,height:400,verticalAlign:"middle",padding:g(0),innerPadding:g(20),backgroundColor:"#ffffff",content:'<p style="color:#ffffff;font-size:24px;">Hero Title</p>'}}function X(){return{links:[{href:"#",text:"Home"},{href:"#",text:"About"},{href:"#",text:"Contact"}],hamburger:"hamburger",alignment:"center",padding:g(10),linkColor:"#000000",linkFontSize:14,linkPadding:"10px 15px"}}const M={text:z,image:q,button:N,divider:U,spacer:F,social:K,html:G,hero:Y,navbar:X};function h(o){const t=M[o];if(!t)throw new Error(`Unknown block type: ${o}`);return t()}let I=null;function Z(o){I=o}function J(o,t){const e=M[o];if(e)return{id:w(),type:o,values:{...e(),...t}};const n=I==null?void 0:I(o);if(n)return{id:w(),type:o,values:{...structuredClone(n),...t}};throw new Error(`Unknown block type: ${o}`)}function T(o=[]){return{id:w(),type:"column",attributes:{padding:g(0),verticalAlign:"top"},blocks:o}}function Q(o,t){const e=o??[T()],n=t??e.map(()=>Math.floor(12/e.length));return{id:w(),type:"row",attributes:{padding:g(0),fullWidth:!1},columns:e,columnRatios:n,locked:!1}}function H(o="Untitled"){const t=new Date().toISOString();return{version:"1.0",metadata:{name:o,createdAt:t,updatedAt:t},body:{attributes:{width:600,backgroundColor:"#f4f4f5",fontFamily:"Arial, Helvetica, sans-serif",contentAlignment:"center"},rows:[]}}}class S{constructor(t,e,n,r){this.doc=t,this.selection=e,this.plugins=n,this._pluginList=r}static create(t={}){const e=t.doc??H(),n=t.plugins??[],r=new Map,s=new S(e,null,r,n);for(const i of n)i.init&&r.set(i.name,i.init(s));return s}createTransaction(){return new $(this.doc)}apply(t){let e=t.doc;const n=t.selectionSet?t.selection:this.selection,r=new Map(this.plugins);for(const i of this._pluginList)if(i.apply){const l=r.get(i.name);r.set(i.name,i.apply(t,l))}t.steps.length>0&&!t.getMeta("skipTimestamp")&&(e=B.produce(e,i=>{i.metadata.updatedAt=new Date().toISOString()}));const s=new S(e,n,r,this._pluginList);for(const i of this._pluginList)i.onStateChange&&i.onStateChange(s,this);return s}getPluginState(t){return this.plugins.get(t)}}function v(o,t,e){return{type:"block",rowId:o,columnId:t,blockId:e}}function A(o){return{type:"row",rowId:o}}function tt(o,t){return{type:"column",rowId:o,columnId:t}}function et(){return{type:"body"}}function ot(o,t){return o===t?!0:!o||!t?!1:o.type===t.type&&o.rowId===t.rowId&&o.columnId===t.columnId&&o.blockId===t.blockId}function k(o,t,e){const n=o.body.rows.findIndex(s=>s.id===t);if(n===-1)return null;const r=o.body.rows[n].columns.findIndex(s=>s.id===e);return r===-1?null:{rowIndex:n,columnIndex:r}}function nt(o,t,e,n){return(r,s)=>{const i=k(r.doc,o,t);if(!i)return!1;const l=r.doc.body.rows[i.rowIndex].columns[i.columnIndex],c=n??l.blocks.length;if(s){const a=r.createTransaction(),u=m("insertBlock",`body.rows[${i.rowIndex}].columns[${i.columnIndex}].blocks`,d=>{d.body.rows[i.rowIndex].columns[i.columnIndex].blocks.splice(c,0,e)},d=>{d.body.rows[i.rowIndex].columns[i.columnIndex].blocks.splice(c,1)});a.addStep(u),a.setSelection(v(o,t,e.id)),s(a)}return!0}}function rt(o,t,e){return(n,r)=>{const s=k(n.doc,o,t);if(!s)return!1;const i=n.doc.body.rows[s.rowIndex].columns[s.columnIndex],l=i.blocks.findIndex(c=>c.id===e);if(l===-1)return!1;if(r){const c=i.blocks[l],a=n.createTransaction(),u=m("deleteBlock",`body.rows[${s.rowIndex}].columns[${s.columnIndex}].blocks`,d=>{d.body.rows[s.rowIndex].columns[s.columnIndex].blocks.splice(l,1)},d=>{d.body.rows[s.rowIndex].columns[s.columnIndex].blocks.splice(l,0,c)});a.addStep(u),a.setSelection(null),r(a)}return!0}}function st(o,t,e,n){return(r,s)=>{const i=k(r.doc,o,t);if(!i)return!1;const l=r.doc.body.rows[i.rowIndex].columns[i.columnIndex],c=l.blocks.findIndex(a=>a.id===e);if(c===-1)return!1;if(s){const a=l.blocks[c],u=r.createTransaction(),d=m("updateBlock",`body.rows[${i.rowIndex}].columns[${i.columnIndex}].blocks[${c}]`,p=>{const b=p.body.rows[i.rowIndex].columns[i.columnIndex].blocks[c];Object.assign(b.values,n)},p=>{p.body.rows[i.rowIndex].columns[i.columnIndex].blocks[c]=a});u.addStep(d),s(u)}return!0}}function it(o,t,e,n,r,s){return(i,l)=>{const c=k(i.doc,o,t);if(!c)return!1;const u=i.doc.body.rows[c.rowIndex].columns[c.columnIndex].blocks.findIndex(p=>p.id===e);if(u===-1)return!1;const d=k(i.doc,n,r);if(!d)return!1;if(l){const p=i.createTransaction(),b=m("moveBlock","body.rows",y=>{const[R]=y.body.rows[c.rowIndex].columns[c.columnIndex].blocks.splice(u,1);y.body.rows[d.rowIndex].columns[d.columnIndex].blocks.splice(s,0,R)},y=>{const[R]=y.body.rows[d.rowIndex].columns[d.columnIndex].blocks.splice(s,1);y.body.rows[c.rowIndex].columns[c.columnIndex].blocks.splice(u,0,R)});p.addStep(b),p.setSelection(v(n,r,e)),l(p)}return!0}}function lt(o,t,e){return(n,r)=>{const s=k(n.doc,o,t);if(!s)return!1;const i=n.doc.body.rows[s.rowIndex].columns[s.columnIndex],l=i.blocks.findIndex(c=>c.id===e);if(l===-1)return!1;if(r){const c=i.blocks[l],a=w(),u=structuredClone(c);u.id=a;const d=l+1,p=n.createTransaction(),b=m("duplicateBlock",`body.rows[${s.rowIndex}].columns[${s.columnIndex}].blocks`,y=>{y.body.rows[s.rowIndex].columns[s.columnIndex].blocks.splice(d,0,u)},y=>{y.body.rows[s.rowIndex].columns[s.columnIndex].blocks.splice(d,1)});p.addStep(b),p.setSelection(v(o,t,a)),r(p)}return!0}}function ct(o,t){return(e,n)=>{const r=t??e.doc.body.rows.length;if(n){const s=e.createTransaction(),i=m("insertRow","body.rows",l=>{l.body.rows.splice(r,0,o)},l=>{l.body.rows.splice(r,1)});s.addStep(i),s.setSelection(A(o.id)),n(s)}return!0}}function at(o){return(t,e)=>{const n=t.doc.body.rows.findIndex(r=>r.id===o);if(n===-1)return!1;if(e){const r=structuredClone(t.doc.body.rows[n]),s=t.createTransaction(),i=m("deleteRow","body.rows",l=>{l.body.rows.splice(n,1)},l=>{l.body.rows.splice(n,0,r)});s.addStep(i),s.setSelection(null),e(s)}return!0}}function dt(o,t){return(e,n)=>{const r=e.doc.body.rows.findIndex(s=>s.id===o);if(r===-1||r===t)return!1;if(n){const s=e.createTransaction(),i=m("moveRow","body.rows",l=>{const[c]=l.body.rows.splice(r,1);l.body.rows.splice(t,0,c)},l=>{const[c]=l.body.rows.splice(t,1);l.body.rows.splice(r,0,c)});s.addStep(i),s.setSelection(A(o)),n(s)}return!0}}function ut(o){return(t,e)=>{const n=t.doc.body.rows.findIndex(r=>r.id===o);if(n===-1)return!1;if(e){const r=t.doc.body.rows[n],s=structuredClone(r);s.id=w(),s.columns.forEach(a=>{a.id=w(),a.blocks.forEach(u=>{u.id=w()})});const i=n+1,l=t.createTransaction(),c=m("duplicateRow","body.rows",a=>{a.body.rows.splice(i,0,s)},a=>{a.body.rows.splice(i,1)});l.addStep(c),l.setSelection(A(s.id)),e(l)}return!0}}function ft(o,t){return(e,n)=>{const r=e.doc.body.rows.findIndex(s=>s.id===o);if(r===-1)return!1;if(n){const s={...e.doc.body.rows[r].attributes},i=e.createTransaction(),l=m("updateRowAttributes",`body.rows[${r}].attributes`,c=>{Object.assign(c.body.rows[r].attributes,t)},c=>{c.body.rows[r].attributes=s});i.addStep(l),n(i)}return!0}}function pt(o){return(t,e)=>{const n=t.doc.body.rows.findIndex(s=>s.id===o);if(n===-1)return!1;const r=t.doc.body.rows[n];if(r.locked||r.columns.length>=4)return!1;if(e){const s=T(),i=r.columns.length+1,l=D(i),c=[...r.columnRatios],a=t.createTransaction(),u=m("addColumn",`body.rows[${n}]`,d=>{d.body.rows[n].columns.push(s),d.body.rows[n].columnRatios=l},d=>{d.body.rows[n].columns.pop(),d.body.rows[n].columnRatios=c});a.addStep(u),e(a)}return!0}}function mt(o,t){return(e,n)=>{const r=e.doc.body.rows.findIndex(l=>l.id===o);if(r===-1)return!1;const s=e.doc.body.rows[r];if(s.locked||s.columns.length<=1)return!1;const i=s.columns.findIndex(l=>l.id===t);if(i===-1)return!1;if(n){const l=structuredClone(s.columns[i]),c=[...s.columnRatios],a=s.columns.length-1,u=D(a),d=e.createTransaction(),p=m("removeColumn",`body.rows[${r}]`,b=>{b.body.rows[r].columns.splice(i,1),b.body.rows[r].columnRatios=u},b=>{b.body.rows[r].columns.splice(i,0,l),b.body.rows[r].columnRatios=c});d.addStep(p),n(d)}return!0}}function gt(o,t){return(e,n)=>{const r=e.doc.body.rows.findIndex(l=>l.id===o);if(r===-1)return!1;const s=e.doc.body.rows[r];if(t.length!==s.columns.length||t.reduce((l,c)=>l+c,0)!==12)return!1;if(n){const l=[...s.columnRatios],c=e.createTransaction(),a=m("resizeColumns",`body.rows[${r}].columnRatios`,u=>{u.body.rows[r].columnRatios=t},u=>{u.body.rows[r].columnRatios=l});c.addStep(a),n(c)}return!0}}function D(o){const t=Math.floor(12/o),e=12-t*o,n=new Array(o).fill(t);for(let r=0;r<e;r++)n[r]+=1;return n}const bt=["text","image","button","divider","spacer","social","html","hero","navbar"];function W(o){const t=[];if(!o||typeof o!="object")return t.push({path:"",message:"Document must be an object"}),t;const e=o;if(e.version!=="1.0"&&t.push({path:"version",message:'Version must be "1.0"'}),!e.metadata||typeof e.metadata!="object"?t.push({path:"metadata",message:"Metadata is required"}):typeof e.metadata.name!="string"&&t.push({path:"metadata.name",message:"Name must be a string"}),!e.body||typeof e.body!="object")return t.push({path:"body",message:"Body is required"}),t;const n=e.body;return(!n.attributes||typeof n.attributes!="object")&&t.push({path:"body.attributes",message:"Body attributes are required"}),Array.isArray(n.rows)?(n.rows.forEach((r,s)=>{t.push(...ht(r,`body.rows[${s}]`))}),t):(t.push({path:"body.rows",message:"Rows must be an array"}),t)}function ht(o,t){const e=[];return o.id||e.push({path:`${t}.id`,message:"Row must have an id"}),o.type!=="row"&&e.push({path:`${t}.type`,message:'Row type must be "row"'}),Array.isArray(o.columns)?(Array.isArray(o.columnRatios)?o.columnRatios.length!==o.columns.length&&e.push({path:`${t}.columnRatios`,message:"Column ratios length must match columns length"}):e.push({path:`${t}.columnRatios`,message:"Column ratios must be an array"}),o.columns.forEach((n,r)=>{e.push(...yt(n,`${t}.columns[${r}]`))}),e):(e.push({path:`${t}.columns`,message:"Columns must be an array"}),e)}function yt(o,t){const e=[];return o.id||e.push({path:`${t}.id`,message:"Column must have an id"}),Array.isArray(o.blocks)?(o.blocks.forEach((n,r)=>{e.push(...wt(n,`${t}.blocks[${r}]`))}),e):(e.push({path:`${t}.blocks`,message:"Blocks must be an array"}),e)}function wt(o,t){const e=[];return o.id||e.push({path:`${t}.id`,message:"Block must have an id"}),bt.includes(o.type)||e.push({path:`${t}.type`,message:`Invalid block type: ${o.type}`}),(!o.values||typeof o.values!="object")&&e.push({path:`${t}.values`,message:"Block must have values"}),e}function kt(o){return W(o).length===0}const x=new Map,xt=[{type:"text",label:"Text",icon:"text",defaultValues:h("text")},{type:"image",label:"Image",icon:"image",defaultValues:h("image")},{type:"button",label:"Button",icon:"button",defaultValues:h("button")},{type:"divider",label:"Divider",icon:"divider",defaultValues:h("divider")},{type:"spacer",label:"Spacer",icon:"spacer",defaultValues:h("spacer")},{type:"social",label:"Social",icon:"social",defaultValues:h("social")},{type:"html",label:"HTML",icon:"html",defaultValues:h("html")},{type:"hero",label:"Hero",icon:"hero",defaultValues:h("hero")},{type:"navbar",label:"Navbar",icon:"navbar",defaultValues:h("navbar")}];function It(){for(const o of xt)x.set(o.type,o);Z(o=>{var t;return(t=x.get(o))==null?void 0:t.defaultValues})}function P(o){x.set(o.type,o)}function St(o){return x.get(o)}function vt(){return Array.from(x.values())}function At(o){return x.has(o)}It();const Ct=100;function Rt(){return{undoStack:[],redoStack:[]}}function _t(o,t){const e=[...o.undoStack,t];return e.length>Ct&&e.shift(),{undoStack:e,redoStack:[]}}function Tt(o){if(o.undoStack.length===0)return{history:o,entry:null};const t=[...o.undoStack],e=t.pop(),n=[...o.redoStack,e];return{history:{undoStack:t,redoStack:n},entry:e}}function Bt(o){if(o.redoStack.length===0)return{history:o,entry:null};const t=[...o.redoStack],e=t.pop();return{history:{undoStack:[...o.undoStack,e],redoStack:t},entry:e}}function V(o){return o.undoStack.length>0}function E(o){return o.redoStack.length>0}const C="history";function $t(){return{name:C,init(){return Rt()},apply(o,t){const e=t;if(o.meta.get("isUndo")||o.meta.get("isRedo"))return o.meta.get("newHistory")??e;if(o.steps.length===0||o.meta.get("skipHistory"))return e;const n={steps:[...o.steps],doc:o.doc,timestamp:Date.now()};return _t(e,n)}}}function Mt(o,t){const e=o.plugins.get(C);if(!e||!V(e))return!1;if(t){const{history:n,entry:r}=Tt(e);if(!r)return!1;const s=o.createTransaction();for(let i=r.steps.length-1;i>=0;i--){const l=r.steps[i].invert(s.doc);s.addStep(l)}s.setMeta("isUndo",!0),s.setMeta("newHistory",n),s.setMeta("skipTimestamp",!0),t(s)}return!0}function Ht(o,t){const e=o.plugins.get(C);if(!e||!E(e))return!1;if(t){const{history:n,entry:r}=Bt(e);if(!r)return!1;const s=o.createTransaction();for(const i of r.steps)s.addStep(i);s.setMeta("isRedo",!0),s.setMeta("newHistory",n),s.setMeta("skipTimestamp",!0),t(s)}return!0}class Dt{constructor(){this._plugins=new Map}register(t){if(this._plugins.has(t.name))throw new Error(`Plugin "${t.name}" is already registered`);if(this._plugins.set(t.name,t),t.blocks)for(const e of t.blocks)P(e)}unregister(t){this._plugins.delete(t)}get(t){return this._plugins.get(t)}getAll(){return Array.from(this._plugins.values())}getCommands(){const t={};for(const e of this._plugins.values())e.commands&&Object.assign(t,e.commands);return t}has(t){return this._plugins.has(t)}}function _(o,t){if(o===t)return!0;if(o==null||t==null||typeof o!=typeof t)return!1;if(Array.isArray(o))return!Array.isArray(t)||o.length!==t.length?!1:o.every((e,n)=>_(e,t[n]));if(typeof o=="object"){const e=Object.keys(o),n=Object.keys(t);return e.length!==n.length?!1:e.every(r=>_(o[r],t[r]))}return!1}const f="2026-05-26T10:00:00.000Z",Wt={id:"starter-welcome",name:"Welcome",description:"A clean welcome email with a hero, intro paragraph, and call-to-action.",category:"welcome",createdAt:f,updatedAt:f,document:{version:"1.0",metadata:{name:"Welcome",previewText:"We're glad you're here.",createdAt:f,updatedAt:f},body:{attributes:{width:600,backgroundColor:"#f5f7fb",fontFamily:"Inter, sans-serif",contentAlignment:"center"},rows:[{id:"r-hero",type:"row",locked:!1,attributes:{padding:{top:0,right:0,bottom:0,left:0},fullWidth:!0},columnRatios:[12],columns:[{id:"c-hero",type:"column",attributes:{padding:{top:0,right:0,bottom:0,left:0},verticalAlign:"top"},blocks:[{id:"b-hero",type:"hero",values:{backgroundUrl:"https://placehold.co/600x280/0f172a/ffffff?text=Welcome",backgroundPosition:"center center",mode:"fixed-height",width:600,height:280,verticalAlign:"middle",padding:{top:0,right:0,bottom:0,left:0},innerPadding:{top:40,right:40,bottom:40,left:40},backgroundColor:"#0f172a",content:'<h1 style="color:#ffffff;font-size:32px;margin:0;">Welcome, {{firstName}}</h1>'}}]}]},{id:"r-intro",type:"row",locked:!1,attributes:{backgroundColor:"#ffffff",padding:{top:32,right:24,bottom:8,left:24},fullWidth:!1},columnRatios:[12],columns:[{id:"c-intro",type:"column",attributes:{padding:{top:0,right:0,bottom:0,left:0},verticalAlign:"top"},blocks:[{id:"b-intro",type:"text",values:{content:"<p>Thanks for joining — we've put together a quick guide to help you get the most out of your account.</p>",padding:{top:0,right:0,bottom:0,left:0},lineHeight:"1.6",textAlign:"left"}}]}]},{id:"r-cta",type:"row",locked:!1,attributes:{backgroundColor:"#ffffff",padding:{top:16,right:24,bottom:32,left:24},fullWidth:!1},columnRatios:[12],columns:[{id:"c-cta",type:"column",attributes:{padding:{top:0,right:0,bottom:0,left:0},verticalAlign:"top"},blocks:[{id:"b-cta",type:"button",values:{content:"<p>Get started</p>",href:"https://example.com/start",backgroundColor:"#3b82f6",textColor:"#ffffff",borderRadius:6,padding:{top:8,right:8,bottom:8,left:8},innerPadding:{top:12,right:24,bottom:12,left:24},fontSize:16,fontWeight:"600",alignment:"center",fullWidth:!1}}]}]}]}}},Pt={id:"starter-newsletter",name:"Newsletter",description:"A simple 3-section newsletter — headline + body + footer.",category:"newsletter",createdAt:f,updatedAt:f,document:{version:"1.0",metadata:{name:"Newsletter",previewText:"This month's updates",createdAt:f,updatedAt:f},body:{attributes:{width:600,backgroundColor:"#ffffff",fontFamily:"Inter, sans-serif",contentAlignment:"center"},rows:[{id:"r-head",type:"row",locked:!1,attributes:{padding:{top:24,right:24,bottom:8,left:24},fullWidth:!1},columnRatios:[12],columns:[{id:"c-head",type:"column",attributes:{padding:{top:0,right:0,bottom:0,left:0},verticalAlign:"top"},blocks:[{id:"b-head",type:"text",values:{content:'<h1 style="font-size:24px;margin:0;">This month at Acme</h1>',padding:{top:0,right:0,bottom:0,left:0},lineHeight:"1.3",textAlign:"left"}}]}]},{id:"r-body",type:"row",locked:!1,attributes:{padding:{top:8,right:24,bottom:24,left:24},fullWidth:!1},columnRatios:[12],columns:[{id:"c-body",type:"column",attributes:{padding:{top:0,right:0,bottom:0,left:0},verticalAlign:"top"},blocks:[{id:"b-body",type:"text",values:{content:"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sodales, mauris vel rhoncus sodales, eros lectus rutrum lectus.</p><p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>",padding:{top:0,right:0,bottom:0,left:0},lineHeight:"1.6",textAlign:"left"}}]}]},{id:"r-foot",type:"row",locked:!1,attributes:{backgroundColor:"#f5f7fb",padding:{top:16,right:24,bottom:16,left:24},fullWidth:!1},columnRatios:[12],columns:[{id:"c-foot",type:"column",attributes:{padding:{top:0,right:0,bottom:0,left:0},verticalAlign:"top"},blocks:[{id:"b-foot",type:"text",values:{content:'<p style="color:#64748b;font-size:12px;">© Acme · <a href="https://example.com/unsubscribe">Unsubscribe</a></p>',padding:{top:0,right:0,bottom:0,left:0},lineHeight:"1.5",textAlign:"center"}}]}]}]}}},Vt={id:"starter-transactional",name:"Transactional (order confirmation)",description:"Order confirmation pattern with summary and a primary button.",category:"transactional",createdAt:f,updatedAt:f,document:{version:"1.0",metadata:{name:"Order confirmation",previewText:"Order {{orderNumber}} is on its way.",createdAt:f,updatedAt:f},body:{attributes:{width:600,backgroundColor:"#ffffff",fontFamily:"Inter, sans-serif",contentAlignment:"center"},rows:[{id:"r-h",type:"row",locked:!1,attributes:{padding:{top:32,right:24,bottom:8,left:24},fullWidth:!1},columnRatios:[12],columns:[{id:"c-h",type:"column",attributes:{padding:{top:0,right:0,bottom:0,left:0},verticalAlign:"top"},blocks:[{id:"b-h",type:"text",values:{content:'<h1 style="font-size:24px;margin:0 0 8px;">Thanks for your order, {{firstName}}</h1><p style="margin:0;">Order <strong>{{orderNumber}}</strong> is on its way.</p>',padding:{top:0,right:0,bottom:0,left:0},lineHeight:"1.5",textAlign:"left"}}]}]},{id:"r-summary",type:"row",locked:!1,attributes:{backgroundColor:"#f8fafc",padding:{top:16,right:24,bottom:16,left:24},fullWidth:!1},columnRatios:[12],columns:[{id:"c-summary",type:"column",attributes:{padding:{top:0,right:0,bottom:0,left:0},verticalAlign:"top"},blocks:[{id:"b-summary",type:"text",values:{content:'<p style="margin:0 0 8px;"><strong>Summary</strong></p><p style="margin:0;">{{itemCount}} item(s) · {{total}}</p><p style="margin:8px 0 0;color:#64748b;font-size:12px;">Estimated delivery: {{deliveryDate}}</p>',padding:{top:0,right:0,bottom:0,left:0},lineHeight:"1.5",textAlign:"left"}}]}]},{id:"r-cta",type:"row",locked:!1,attributes:{padding:{top:24,right:24,bottom:24,left:24},fullWidth:!1},columnRatios:[12],columns:[{id:"c-cta",type:"column",attributes:{padding:{top:0,right:0,bottom:0,left:0},verticalAlign:"top"},blocks:[{id:"b-cta",type:"button",values:{content:"<p>View order</p>",href:"https://example.com/orders/{{orderNumber}}",backgroundColor:"#0f172a",textColor:"#ffffff",borderRadius:6,padding:{top:0,right:0,bottom:0,left:0},innerPadding:{top:12,right:24,bottom:12,left:24},fontSize:16,fontWeight:"600",alignment:"left",fullWidth:!1}}]}]}]}}},Et={id:"starter-promo",name:"Promo / Sale",description:"Two-column product grid with a primary CTA and a social-link footer.",category:"promo",createdAt:f,updatedAt:f,document:{version:"1.0",metadata:{name:"Spring sale",previewText:"Two days only — 30% off.",createdAt:f,updatedAt:f},body:{attributes:{width:600,backgroundColor:"#fdf6ee",fontFamily:"Inter, sans-serif",contentAlignment:"center"},rows:[{id:"r-hero",type:"row",locked:!1,attributes:{padding:{top:0,right:0,bottom:0,left:0},fullWidth:!0},columnRatios:[12],columns:[{id:"c-hero",type:"column",attributes:{padding:{top:0,right:0,bottom:0,left:0},verticalAlign:"middle"},blocks:[{id:"b-hero",type:"hero",values:{backgroundUrl:"https://placehold.co/600x240/e76f51/ffffff?text=30%25+off",backgroundPosition:"center center",mode:"fluid-height",width:600,height:240,verticalAlign:"middle",padding:{top:0,right:0,bottom:0,left:0},innerPadding:{top:32,right:32,bottom:32,left:32},backgroundColor:"#e76f51",content:'<h1 style="color:#ffffff;font-size:36px;margin:0 0 8px;">30% off, this weekend only</h1><p style="color:#ffffff;font-size:16px;margin:0;">Code <strong>SPRING30</strong> at checkout.</p>'}}]}]},{id:"r-grid",type:"row",locked:!1,attributes:{backgroundColor:"#ffffff",padding:{top:24,right:16,bottom:24,left:16},fullWidth:!1},columnRatios:[6,6],columns:[{id:"c-l",type:"column",attributes:{padding:{top:0,right:8,bottom:0,left:0},verticalAlign:"top"},blocks:[{id:"b-l-img",type:"image",values:{src:"https://placehold.co/280x200",alt:"Linen shirt",width:"auto",href:"https://example.com/p/shirt",padding:{top:0,right:0,bottom:8,left:0},alignment:"center",borderRadius:6}},{id:"b-l-txt",type:"text",values:{content:'<p style="text-align:center;margin:0;"><strong>Linen shirt</strong><br><span style="color:#64748b;">$48 · was $69</span></p>',padding:{top:0,right:0,bottom:0,left:0},lineHeight:"1.5",textAlign:"center"}}]},{id:"c-r",type:"column",attributes:{padding:{top:0,right:0,bottom:0,left:8},verticalAlign:"top"},blocks:[{id:"b-r-img",type:"image",values:{src:"https://placehold.co/280x200",alt:"Wool jumper",width:"auto",href:"https://example.com/p/jumper",padding:{top:0,right:0,bottom:8,left:0},alignment:"center",borderRadius:6}},{id:"b-r-txt",type:"text",values:{content:'<p style="text-align:center;margin:0;"><strong>Wool jumper</strong><br><span style="color:#64748b;">$84 · was $120</span></p>',padding:{top:0,right:0,bottom:0,left:0},lineHeight:"1.5",textAlign:"center"}}]}]},{id:"r-cta",type:"row",locked:!1,attributes:{backgroundColor:"#ffffff",padding:{top:8,right:16,bottom:24,left:16},fullWidth:!1},columnRatios:[12],columns:[{id:"c-cta",type:"column",attributes:{padding:{top:0,right:0,bottom:0,left:0},verticalAlign:"top"},blocks:[{id:"b-cta",type:"button",values:{content:"<p>Shop the sale</p>",href:"https://example.com/sale",backgroundColor:"#0f172a",textColor:"#ffffff",borderRadius:6,padding:{top:8,right:0,bottom:8,left:0},innerPadding:{top:14,right:28,bottom:14,left:28},fontSize:16,fontWeight:"600",alignment:"center",fullWidth:!0}}]}]}]}}},O=Object.freeze([Wt,Pt,Vt,Et]);function L(){return O.map(o=>structuredClone(o))}function Ot(o){const t=O.find(e=>e.id===o);return t?structuredClone(t):null}class Lt{constructor(t={}){if(this._byId=new Map,t.includeStarters!==!1)for(const e of L())this._byId.set(e.id,e);if(t.seed)for(const e of t.seed)this._byId.set(e.id,e)}async list(){return Array.from(this._byId.values()).map(t=>structuredClone(t))}async get(t){const e=this._byId.get(t);return e?structuredClone(e):null}async save(t){if(!t.id)throw new Error("Template.id is required");const e=structuredClone(t);e.updatedAt=new Date().toISOString(),this._byId.has(e.id)||(e.createdAt=e.updatedAt),this._byId.set(e.id,e)}async delete(t){this._byId.delete(t)}}class jt{constructor(t={}){if(this._byId=new Map,t.seed)for(const e of t.seed)this._byId.set(e.id,e)}async list(){return Array.from(this._byId.values()).map(t=>structuredClone(t))}async get(t){const e=this._byId.get(t);return e?structuredClone(e):null}async save(t){if(!t.id)throw new Error("BrandKit.id is required");const e=structuredClone(t);e.updatedAt=new Date().toISOString(),this._byId.has(e.id)||(e.createdAt=e.updatedAt),this._byId.set(e.id,e)}async delete(t){this._byId.delete(t)}}class zt{constructor(t={}){if(this._byId=new Map,t.seed)for(const e of t.seed)this._byId.set(e.id,e)}async list(t={}){let n=Array.from(this._byId.values()).map(i=>structuredClone(i)).filter(i=>qt(i,t));n.sort((i,l)=>i.updatedAt<l.updatedAt?1:i.updatedAt>l.updatedAt?-1:0);const r=t.offset??0,s=t.limit;return n=n.slice(r,s!==void 0?r+s:void 0),n}async get(t){const e=this._byId.get(t);return e?structuredClone(e):null}async save(t){if(!t.id)throw new Error("Asset.id is required");if(!t.src)throw new Error("Asset.src is required");const e=structuredClone(t);e.updatedAt=new Date().toISOString(),this._byId.has(e.id)||(e.createdAt=e.updatedAt),e.folder||(e.folder="/"),this._byId.set(e.id,e)}async delete(t){this._byId.delete(t)}async listFolders(){const t=new Set;for(const e of this._byId.values())t.add(e.folder||"/");return Array.from(t).sort()}}function qt(o,t){if(t.folder&&(o.folder||"/")!==t.folder)return!1;if(t.tags&&t.tags.length>0){const e=new Set(o.tags??[]);if(!t.tags.every(n=>e.has(n)))return!1}if(t.search){const e=t.search.toLowerCase();if(![o.name,o.alt??"",...o.tags??[]].join(" ").toLowerCase().includes(e))return!1}return!0}exports.EditorState=S;exports.HISTORY_PLUGIN_NAME=C;exports.InMemoryAssetStorage=zt;exports.InMemoryBrandKitStorage=jt;exports.InMemoryTemplateStorage=Lt;exports.PluginRegistry=Dt;exports.Transaction=$;exports.addColumn=pt;exports.canRedo=E;exports.canUndo=V;exports.createBlock=J;exports.createBlockSelection=v;exports.createBodySelection=et;exports.createColumn=T;exports.createColumnSelection=tt;exports.createDefaultDocument=H;exports.createDocStep=m;exports.createHistoryPlugin=$t;exports.createRow=Q;exports.createRowSelection=A;exports.deepEqual=_;exports.defaultSpacing=g;exports.deleteBlock=rt;exports.deleteRow=at;exports.duplicateBlock=lt;exports.duplicateRow=ut;exports.generateId=w;exports.getAllBlockDefinitions=vt;exports.getBlockDefinition=St;exports.getDefaultValues=h;exports.getStarterTemplate=Ot;exports.getStarterTemplates=L;exports.insertBlock=nt;exports.insertRow=ct;exports.isKnownBlockType=At;exports.isValidDocument=kt;exports.moveBlock=it;exports.moveRow=dt;exports.redo=Ht;exports.registerBlock=P;exports.removeColumn=mt;exports.resizeColumns=gt;exports.selectionsEqual=ot;exports.undo=Mt;exports.updateBlock=st;exports.updateRowAttributes=ft;exports.validateDocument=W;