script
code:script.js
var Jt=Object.defineProperty;var Gt=(e,t)=>{for(var n in t)Jt(e,n,{get:tn,enumerable:!0})};scrapbox.PopupMenu.addButton({title:e=>{if(!(e.split(`
).length<2))return"✂New Page"},onClick:e=>{let t=e.split(
),n=t[0].replace(/[\[\]\n]/g,"").trim();return t.unshift(✂ from ${scrapbox.Page.title}),window.open(https://scrapbox.io/${scrapbox.Project.name}/${encodeURIComponent(n)}?body=${encodeURIComponent(t.join(`
))}),✂ to [${n}]}});var We=document.createElement("style");We.innerText=".popup-menu .button-container .button.split-page-button{display:none;} .popup-menu .button-container .button.copy-plain-button:not(.button.strike-button + .copy-plain-button){border-left:none;}";document.body.appendChild(We);scrapbox.PopupMenu.addButton({title:"unlink",onClick:e=>{let t=e.split(/\n/).map(n=>n.replace(/\[([^\!"#%&'()\*\+,\-\.\/\{\|\}<>_~[^\\]*)\]/g,"$1")).join(`
);if(e!=t)return t}});var Zt=e=>{let t=e.indexOf(
),n=e.substr(0,t).split(
).map(o=>{let[s="",a=""]=o.split(" => ",2);return{before:s,after:a}}),r=e.substr(t+2).split(
);for(let{before:o,after:s}of n){let a=o.match(new RegExp("^/(.*?)/([gimy]*)$")),l=a?new RegExp(a[1],a[2]):o;r=r.map(p=>p.replace(l,s.replace(/\\n/g,
)))}return r.join(
)};scrapbox.PopupMenu.addButton({title:"replace",onClick:Zt});setTimeout(()=>{let e=[["⬜","☑️"],["☐","☑"],["□","☑"]],t=e.reduce((c,u)=>c.concat(u),[]),n=new RegExp("^\\s*("+t.join("|")+")"),r=scrapbox.Project.name;class o{constructor(){this.textArea=document.getElementById("text-input"),this.event=document.createEvent("UIEvent"),this.event.initEvent("keydown",!0,!0)}dispatch(u,i=!1,f=!1,d=!1,m=!1){this.event.keyCode=u,this.event.shiftKey=i,this.event.ctrlKey=f,this.event.altKey=d,this.event.metaKey=m,this.textArea.dispatchEvent(this.event)}}$("#app-container").off(click.toggleCheckBox_${r},".lines"),$("#app-container").on(click.toggleCheckBox_${r},".lines",async c=>{if(scrapbox.Project.name!==r){$("#app-container").off(click.toggleCheckBox_${r},".lines");return}let u=c.target;if(!s(u)||!l(u,t))return;await new Promise(y=>setTimeout(y,30));let i;try{i=a()}catch(y){console.log(y);return}if(!n.test(i))return;let f=u.getBoundingClientRect().left,d=document.getElementsByClassName("cursor")[0].getBoundingClientRect().left,m=new o;d<=f&&m.dispatch(39),m.dispatch(8);let b=(()=>{let y=i.trim();for(let h of e)for(let g=0;g<h.length;g++)if(y.startsWith(h[g]))return h[g+1<h.length?g+1:0];return u.textContent})();p(b)}),$("#text-input").off(keydown.autoInsertCheckBox_${r}),$("#text-input").on(keydown.autoInsertCheckBox_${r},async c=>{if(scrapbox.Project.name!==r){$("#text-input").off(keydown.autoInsertCheckBox_${r});return}switch(c.key){case"Enter":{let u;try{u=a()}catch(f){console.log(f);return}if(!n.test(u))return;await new Promise(f=>setTimeout(f,30));let i;try{i=a()}catch(f){console.log(f);return}if(!n.test(i)){let f=u.trim(),d=e.find(m=>m.some(b=>f.startsWith(b)));p(d[0])}return}default:return}});function s(c){return c.parentNode.firstElementChild===c}function a(){return document.querySelector(".lines div.line.cursor-line").textContent}function l(c,u){return c.tagName==="SPAN"&&u.includes(c.textContent)&&c.classList.value.split(" ").some(i=>/^c\-\d+$/.test(i))}function p(c){let u=document.getElementById("text-input");u.value=c,u.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0}))}},1500);var en=e=>({type:"title",text:e.rows[0].text}),tn=e=>{let{rows:[t,...n]}=e,{indent:r=0,text:o=""}=t??{},s=o.replace(/^\s*code:/,"");return{indent:r,type:"codeBlock",fileName:s,content:n.map(a=>a.text.substring(r+1)).join(
)}},x=(e,{parseOnNested:t,parseOnQuoted:n,patterns:r})=>(o,s,a)=>{var l,p,c,u,i,f;if(!t&&s.nested)return(l=a?.())!==null&&l!==void 0?l:[];if(!n&&s.quoted)return(p=a?.())!==null&&p!==void 0?p:[];for(let d of r){let m=d.exec(o);if(m===null)continue;let b=o.substring(0,m.index),y=o.substring(m.index+((u=(c=m[0])===null||c===void 0?void 0:c.length)!==null&&u!==void 0?u:0)),h=e((i=m[0])!==null&&i!==void 0?i:"",s);return[...U(b,s),...h,...U(y,s)]}return(f=a?.())!==null&&f!==void 0?f:[]},v=e=>[{type:"plain",raw:e,text:e}],nn=x(v,{parseOnNested:!0,parseOnQuoted:!0,patterns:[/^()(.*)()$/]}),rn=/^>.*$/,on=(e,t)=>t.context==="table"?v(e,t):[{type:"quote",raw:e,nodes:U(e.substring(1),{...t,quoted:!0})}],sn=x(on,{parseOnNested:!1,parseOnQuoted:!1,patterns:[rn]}),an=/^\? .+$/,cn=(e,t)=>t.context==="table"?v(e,t):[{type:"helpfeel",raw:e,text:e.substring(2)}],ln=x(cn,{parseOnNested:!1,parseOnQuoted:!1,patterns:[an]}),un=/\[\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)\]\]/i,pn=/\[\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}\]\]/,dn=(e,t)=>{if(t.context==="table")return v(e,t);let n=e.substring(2,e.length-2),r=/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(n);return[{type:"strongImage",raw:e,src:r?${n}/thumb/1000:n}]},fn=x(dn,{parseOnNested:!1,parseOnQuoted:!0,patterns:[un,pn]}),mn=/\[[^[\]]*\.icon(?:\*[1-9]\d*)?\]/;function ze(e){return(t,n)=>{if(e==="strongIcon"&&n.context==="table")return v(t,n);let r=e==="icon"?t.substring(1,t.length-1):t.substring(2,t.length-2),o=r.lastIndexOf(".icon"),s=r.substring(0,o),a=s.startsWith("/")?"root":"relative",l=r.substring(o+5,r.length),p=l.startsWith("*")?parseInt(l.substring(1),10):1;return new Array(p).fill({}).map(()=>({path:s,pathType:a,type:e,raw:t}))}}var hn=ze("icon"),gn=x(hn,{parseOnNested:!0,parseOnQuoted:!0,patterns:[mn]}),_n=/\[\[[^[\]]*\.icon(?:\*\d+)?\]\]/,yn=ze("strongIcon"),bn=x(yn,{parseOnNested:!1,parseOnQuoted:!0,patterns:[_n]}),xn=/\[\[(?:[^[]|\[[^[]).*?\]*\]\]/,vn=(e,t)=>t.context==="table"?v(e,t):[{type:"strong",raw:e,nodes:U(e.substring(2,e.length-2),{...t,nested:!0})}],kn=x(vn,{parseOnNested:!1,parseOnQuoted:!0,patterns:[xn]}),wn=/\[\$ .+? \]/,En=/\[\$ [^\]]+\]/,Sn=(e,t)=>t.context==="table"?v(e,t):[{type:"formula",raw:e,formula:e.substring(3,e.length-(e.endsWith(" ]")?2:1))}],Ln=x(Sn,{parseOnNested:!1,parseOnQuoted:!0,patterns:[wn,En]}),Cn=/\[[!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\]]+\]|[^\]])+\]/,Tn=(e,t)=>{if(t.context==="table")return v(e,t);let n=e.indexOf(" "),r=e.substring(1,n),o=e.substring(n+1,e.length-1),s=new Set(r);if(s.has("*")){let a=r.split("*").length-1;s.delete("*"),s.add(*-${Math.min(a,10)})}return[{type:"decoration",raw:e,rawDecos:r,decos:Array.from(s),nodes:U(o,{...t,nested:!0})}]},Mn=x(Tn,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Cn]}),Pn=/.*?/,On=(e,t)=>t.context==="table"?v(e,t):[{type:"code",raw:e,text:e.substring(1,e.length-1)}],Rn=x(On,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Pn]}),In=/^[$%] .+$/,An=(e,t)=>{var n;if(t.context==="table")return v(e,t);let r=(n=e[0])!==null&&n!==void 0?n:"",o=e.substring(2);return[{type:"commandLine",raw:e,symbol:r,text:o}]},Nn=x(An,{parseOnNested:!1,parseOnQuoted:!1,patterns:[In]}),Hn=/\[\s+\]/,$n=(e,t)=>t.context==="table"?v(e,t):[{type:"blank",raw:e,text:e.substring(1,e.length-1)}],Dn=x($n,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Hn]}),jn=/\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?(?:\s+https?:\/\/[^\s\]]+)?\]/i,Un=/\[https?:\/\/[^\s\]]+\s+https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?\]/i,Fn=/\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?(?:\s+https?:\/\/[^\s\]]+)?\]/,Bn=/\[https?:\/\/[^\s\]]+\s+https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?\]/,Wn=e=>/^https?:\/\/[^\s\]]+\.(png|jpe?g|gif|svg)(\?[^\]\s]+)?$/i.test(e)||Kn(e),Kn=e=>/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}(\/raw)?$/.test(e),zn=(e,t)=>{if(t.context==="table")return v(e,t);let n=e.search(/\s/),r=n!==-1?e.substring(1,n):e.substring(1,e.length-1),o=n!==-1?e.substring(n,e.length-1).trimLeft():"",[s,a]=Wn(o)?[o,r]:[r,o];return[{type:"image",raw:e,src:/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(s)?${s}/thumb/1000:s,link:a}]},qn=x(zn,{parseOnNested:!0,parseOnQuoted:!0,patterns:[jn,Un,Fn,Bn]}),Qn=/\[https?:\/\/[^\s\]]+\s+[^\]]*[^\s]\]/,Vn=/\[[^[\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/,Yn=/\[https?:\/\/[^\s\]]+\]/,Xn=/https?:\/\/[^\s]+/,Jn=(e,t)=>{if(t.context==="table")return v(e,t);let n=e.startsWith("[")&&e.endsWith("]")?e.substring(1,e.length-1):e,r=/^https?:\/\/[^\s\]]/.test(n),o=(r?/^https?:\/\/[^\s\]]+/:/https?:\/\/[^\s\]]+$/).exec(n);if(o?.[0]===void 0)return[];let s=r?n.substring(o[0].length):n.substring(0,o.index-1);return[{type:"link",raw:e,pathType:"absolute",href:o[0],content:s.trim()}]},Gn=x(Jn,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Qn,Vn,Yn,Xn]}),qe=/\[([^\]]*[^\s])\s+([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)\]/,Qe=/\[([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)(?:\s+([^\]]*[^\s]))?\]/,Zn=e=>{let[t="",n="",r=""]=e.split(","),o=parseFloat(t.replace(/^N/,"").replace(/^S/,"-")),s=parseFloat(n.replace(/^E/,"").replace(/^W/,"-")),a=/^Z\d+$/.test(r)?parseInt(r.replace(/^Z/,""),10):14;return{latitude:o,longitude:s,zoom:a}},er=(e,t)=>{var n;if(t.context==="table")return v(e,t);let r=(n=e.match(qe))!==null&&n!==void 0?n:e.match(Qe);if(r===null)return[];let o=e.startsWith("[N")||e.startsWith("[S"),[,s="",a=""]=o?r:[r[0],r[2],r[1]],{latitude:l,longitude:p,zoom:c}=Zn(s),u=a!==""?https://www.google.com/maps/place/${encodeURIComponent(a)}/@${l},${p},${c}z:https://www.google.com/maps/@${l},${p},${c}z;return[{type:"googleMap",raw:e,latitude:l,longitude:p,zoom:c,place:a,url:u}]},tr=x(er,{parseOnNested:!1,parseOnQuoted:!0,patterns:[qe,Qe]}),nr=/\[\/?[^[\]]+\]/,rr=e=>{let t=e.substring(1,e.length-1);return[{type:"link",raw:e,pathType:t.startsWith("/")?"root":"relative",href:t,content:""}]},or=x(rr,{parseOnNested:!0,parseOnQuoted:!0,patterns:[nr]}),sr=/(?:^|\s)#\S+/,ir=(e,t)=>{if(t.context==="table")return v(e,t);if(e.startsWith("#"))return[{type:"hashTag",raw:e,href:e.substring(1)}];let n=e.substring(0,1),r=e.substring(1);return[...v(n,t),{type:"hashTag",raw:r,href:r.substring(1)}]},ar=x(ir,{parseOnNested:!0,parseOnQuoted:!0,patterns:[sr]}),cr=/^[0-9]+\. .*$/,lr=(e,t)=>{if(t.context==="table")return v(e,t);let n=e.indexOf(" "),r=e.substring(0,n-1),o=parseInt(r,10),s=e.substring(n+1,e.length);return[{type:"numberList",raw:e,rawNumber:r,number:o,nodes:U(s,{...t,nested:!0})}]},ur=x(lr,{parseOnNested:!1,parseOnQuoted:!1,patterns:[cr]}),pr=(e,t,n)=>{var r;return e===""?[]:(r=n?.())!==null&&r!==void 0?r:[]},dr=(...e)=>(t,n)=>e.reduceRight((r,o)=>()=>o(t,n,r),()=>nn(t,n))(),U=dr(pr,sn,ln,Rn,Nn,Ln,Dn,Mn,fn,bn,kn,qn,Gn,gn,tr,or,ar,ur),fr=e=>{let{rows:[t,...n]}=e,{indent:r=0,text:o=""}=t??{},s=o.replace(/^\s*table:/,"");return{indent:r,type:"table",fileName:s,cells:n.map(a=>a.text.substring(r+1)).map(a=>a.split(" ").map(l=>U(l,{nested:!1,quoted:!1,context:"table"})))}},mr=e=>{let{indent:t,text:n}=e.rows[0];return{indent:t,type:"line",nodes:U(n.substring(t),{nested:!1,quoted:!1,context:"line"})}},hr=e=>{switch(e.type){case"title":return en(e);case"codeBlock":return tn(e);case"table":return fr(e);case"line":return mr(e)}},gr=e=>e.split(
).map(t=>{var n,r,o;return{indent:(o=(r=(n=/^\s+/.exec(t))===null||n===void 0?void 0:n[0])===null||r===void 0?void 0:r.length)!==null&&o!==void 0?o:0,text:t}}),_r=(e,t)=>{var n,r;return(e.type==="codeBlock"||e.type==="table")&&t.indent>((r=(n=e.rows[0])===null||n===void 0?void 0:n.indent)!==null&&r!==void 0?r:0)},Ke=(e,t)=>{let n=e[e.length-1];return n!==void 0&&_r(n,t)?(n.rows.push(t),e):(e.push({type:/^\s*code:/.test(t.text)?"codeBlock":/^\s*table:/.test(t.text)?"table":"line",rows:[t]}),e)},yr=(e,t)=>{var n;if(!((n=t.hasTitle)!==null&&n!==void 0)||n){let[r,...o]=e;return r===void 0?[]:[{type:"title",rows:[r]},...o.reduce(Ke,[])]}return e.reduce(Ke,[])},br=(e,t)=>{var n;let r=gr(e);return yr(r,{hasTitle:(n=t?.hasTitle)!==null&&n!==void 0?n:!0}).map(hr)},xr=e=>br(e,{hasTitle:!1}).flatMap(t=>{switch(t.type){case"title":return[];case"codeBlock":return vr(t);case"table":return kr(t);case"line":return wr(t)}}).map(t=>t).join(
),vr=({fileName:e,content:t,indent:n})=>{let r=" ".repeat(n);return[${r}code:${e},...t.split(
).map(o=>${r} ${o})]},kr=({fileName:e,cells:t,indent:n})=>{let r=" ".repeat(n);return[${r}table:${e},...t.map(o=>${r} ${o.map(s=>s.map(a=>a.raw).join("")).join(" ")})]},wr=({nodes:e,indent:t})=>[${" ".repeat(t)}${e.map(n=>${ie(n)}).join("")}],ie=e=>{switch(e.type){case"quote":return> ${e.nodes.map(t=>ie(t)).join("")};case"helpfeel":return-? ${e.text};case"commandLine":return-${e.symbol} ${e.text};case"icon":case"strongIcon":case"image":case"strongImage":case"formula":case"code":case"googleMap":return e.raw;case"strong":return${e.nodes.map(t=>ie(t)).join("")};case"decoration":{e.decos.includes("-")||e.decos.push("-");let t=e.decos.map(n=>{let r=parseInt(n.match(/\*-(\d)/)?.[1]??"0");return r>0?"*".repeat(r):n}).join("");return[${t?${t} :""}${e.nodes.map(n=>ie(n)).join("")}]}case"link":switch(e.pathType){case"root":case"relative":return${e.href};case"absolute":return[- ${e.content?${e.content} :""}${e.href}]]}case"hashTag":return#${e.href};case"numberList":return${e.number}. ${e.nodes.map(t=>ie(t)).join("")};case"blank":case"plain":return${e.text}}};scrapbox.PopupMenu.addButton({title:"打消し",onClick:e=>{let t=xr(e);if(e!==t)return t}});var Q=document.createElement("div");Ce();scrapbox.on("layout:changed",Ce);scrapbox.on("lines:changed",Ce);function Ce(){if(scrapbox.Layout!=="page")Q.remove();else{document.querySelector(".status-bar").appendChild(Q);let e=scrapbox.Page.metadata.charsCount,t=scrapbox.Page.metadata.linesCount;Q.innerText=${t}lines ${e}char,e<4096?Q.style.color=null:e<8192?Q.style.color="#f80":Q.style.color="#f00"}}scrapbox.PopupMenu.addButton({title:function(e){let t=e.replace(/[\r\n]/g,"").length;return${e.split(`
).length}l ${t}c},onClick:()=>null});var Re,_,Ge,Er,W,Ve,Ze,et,tt,Ie,Te,Me,Sr,Pe={},nt=[],Lr=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|inech|zoo|^ord|itera/i,ae=Array.isArray;function N(e,t){for(var n in t)en=tn;return e}function Ae(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function ce(e,t,n){var r,o,s,a={};for(s in t)s=="key"?r=ts:s=="ref"?o=ts:as=ts;if(arguments.length>2&&(a.children=arguments.length>3?Re.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(s in e.defaultProps)as===void 0&&(as=e.defaultPropss);return he(e,a,r,o,null)}function he(e,t,n,r,o){var s={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++Ge,__i:-1,__u:0};return o==null&&_.vnode!=null&&_.vnode(s),s}function S(e){return e.children}function P(e,t){this.props=e,this.context=t}function V(e,t){if(t==null)return e.__?V(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__kt)!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?V(e):null}function rt(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((n=e.__kt)!=null&&n.__e!=null){e.__e=e.__c.base=n.__e;break}return rt(e)}}function Ye(e){(!e.__d&&(e.__d=!0)&&W.push(e)&&!ge.__r++||Ve!=_.debounceRendering)&&((Ve=_.debounceRendering)||Ze)(ge)}function ge(){for(var e,t,n,r,o,s,a,l=1;W.length;)W.length>l&&W.sort(et),e=W.shift(),l=W.length,e.__d&&(n=void 0,o=(r=(t=e).__v).__e,s=[],a=[],t.__P&&((n=N({},r)).__v=r.__v+1,_.vnode&&_.vnode(n),it(t.__P,n,r,t.__n,t.__P.namespaceURI,32&r.__u?o:null,s,o??V(r),!!(32&r.__u),a),n.__v=r.__v,n.__.__kn.__i=n,Mr(s,n,a),n.__e!=o&&rt(n)));ge.__r=0}function ot(e,t,n,r,o,s,a,l,p,c,u){var i,f,d,m,b,y,h,g=r&&r.__k||nt,L=t.length;for(p=Cr(n,t,g,p,L),i=0;i<L;i++)(d=n.__ki)!=null&&(f=d.__i==-1?Pe:gd.__i||Pe,d.__i=i,y=it(e,d,f,o,s,a,l,p,c,u),m=d.__e,d.ref&&f.ref!=d.ref&&(f.ref&&Ne(f.ref,null,d),u.push(d.ref,d.__c||m,d)),b==null&&m!=null&&(b=m),(h=!!(4&d.__u))||f.__k===d.__k?p=st(d,p,e,h):typeof d.type=="function"&&y!==void 0?p=y:m&&(p=m.nextSibling),d.__u&=-7);return n.__e=b,p}function Cr(e,t,n,r,o){var s,a,l,p,c,u=n.length,i=u,f=0;for(e.__k=new Array(o),s=0;s<o;s++)(a=ts)!=null&&typeof a!="boolean"&&typeof a!="function"?(p=s+f,(a=e.__ks=typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?he(null,a,null,null,null):ae(a)?he(S,{children:a},null,null,null):a.constructor==null&&a.__b>0?he(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=e,a.__b=e.__b+1,l=null,(c=a.__i=Tr(a,n,p,i))!=-1&&(i--,(l=nc)&&(l.__u|=2)),l==null||l.__v==null?(c==-1&&(o>u?f--:o<u&&f++),typeof a.type!="function"&&(a.__u|=4)):c!=p&&(c==p-1?f--:c==p+1?f++:(c>p?f--:f++,a.__u|=4))):e.__ks=null;if(i)for(s=0;s<u;s++)(l=ns)!=null&&!(2&l.__u)&&(l.__e==r&&(r=V(l)),ct(l,l));return r}function st(e,t,n,r){var o,s;if(typeof e.type=="function"){for(o=e.__k,s=0;o&&s<o.length;s++)os&&(os.__=e,t=st(os,t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=V(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Y(e,t){return t=t||[],e==null||typeof e=="boolean"||(ae(e)?e.some(function(n){Y(n,t)}):t.push(e)),t}function Tr(e,t,n,r){var o,s,a,l=e.key,p=e.type,c=tn,u=c!=null&&(2&c.__u)==0;if(c===null&&e.key==null||u&&l==c.key&&p==c.type)return n;if(r>(u?1:0)){for(o=n-1,s=n+1;o>=0||s<t.length;)if((c=ta=o>=0?o--:s++)!=null&&!(2&c.__u)&&l==c.key&&p==c.type)return a}return-1}function Xe(e,t,n){t0=="-"?e.setProperty(t,n??""):et=n==null?"":typeof n!="number"||Lr.test(t)?n:n+"px"}function me(e,t,n,r,o){var s,a;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof r=="string"&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||Xe(e.style,t,"");if(n)for(t in n)r&&nt==rt||Xe(e.style,t,nt)}else if(t0=="o"&&t1=="n")s=t!=(t=t.replace(tt,"$1")),a=t.toLowerCase(),t=a in e||t=="onFocusOut"||t=="onFocusIn"?a.slice(2):t.slice(2),e.l||(e.l={}),e.lt+s=n,n?r?n.u=r.u:(n.u=Ie,e.addEventListener(t,s?Me:Te,s)):e.removeEventListener(t,s?Me:Te,s);else{if(o=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{et=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t4!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function Je(e){return function(t){if(this.l){var n=this.lt.type+e;if(t.t==null)t.t=Ie++;else if(t.t<n.u)return;return n(_.event?_.event(t):t)}}}function it(e,t,n,r,o,s,a,l,p,c){var u,i,f,d,m,b,y,h,g,L,E,R,D,ee,B,I,T,w=t.type;if(t.constructor!=null)return null;128&n.__u&&(p=!!(32&n.__u),s=l=t.__e=n.__e),(u=_.__b)&&u(t);e:if(typeof w=="function")try{if(h=t.props,g="prototype"in w&&w.prototype.render,L=(u=w.contextType)&&ru.__c,E=u?L?L.props.value:u.__:r,n.__c?y=(i=t.__c=n.__c).__=i.__E:(g?t.__c=i=new w(h,E):(t.__c=i=new P(h,E),i.constructor=w,i.render=Or),L&&L.sub(i),i.props=h,i.state||(i.state={}),i.context=E,i.__n=r,f=i.__d=!0,i.__h=[],i._sb=[]),g&&i.__s==null&&(i.__s=i.state),g&&w.getDerivedStateFromProps!=null&&(i.__s==i.state&&(i.__s=N({},i.__s)),N(i.__s,w.getDerivedStateFromProps(h,i.__s))),d=i.props,m=i.state,i.__v=t,f)g&&w.getDerivedStateFromProps==null&&i.componentWillMount!=null&&i.componentWillMount(),g&&i.componentDidMount!=null&&i.__h.push(i.componentDidMount);else{if(g&&w.getDerivedStateFromProps==null&&h!==d&&i.componentWillReceiveProps!=null&&i.componentWillReceiveProps(h,E),!i.__e&&i.shouldComponentUpdate!=null&&i.shouldComponentUpdate(h,i.__s,E)===!1||t.__v==n.__v){for(t.__v!=n.__v&&(i.props=h,i.state=i.__s,i.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(M){M&&(M.__=t)}),R=0;R<i._sb.length;R++)i.__h.push(i._sbR);i._sb=[],i.__h.length&&a.push(i);break e}i.componentWillUpdate!=null&&i.componentWillUpdate(h,i.__s,E),g&&i.componentDidUpdate!=null&&i.__h.push(function(){i.componentDidUpdate(d,m,b)})}if(i.context=E,i.props=h,i.__P=e,i.__e=!1,D=_.__r,ee=0,g){for(i.state=i.__s,i.__d=!1,D&&D(t),u=i.render(i.props,i.state,i.context),B=0;B<i._sb.length;B++)i.__h.push(i._sbB);i._sb=[]}else do i.__d=!1,D&&D(t),u=i.render(i.props,i.state,i.context),i.state=i.__s;while(i.__d&&++ee<25);i.state=i.__s,i.getChildContext!=null&&(r=N(N({},r),i.getChildContext())),g&&!f&&i.getSnapshotBeforeUpdate!=null&&(b=i.getSnapshotBeforeUpdate(d,m)),I=u,u!=null&&u.type===S&&u.key==null&&(I=at(u.props.children)),l=ot(e,ae(I)?I:I,t,n,r,o,s,a,l,p,c),i.base=t.__e,t.__u&=-161,i.__h.length&&a.push(i),y&&(i.__E=i.__=null)}catch(M){if(t.__v=null,p||s!=null)if(M.then){for(t.__u|=p?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;ss.indexOf(l)=null,t.__e=l}else{for(T=s.length;T--;)Ae(sT);Oe(t)}else t.__e=n.__e,t.__k=n.__k,M.then||Oe(t);_.__e(M,t,n)}else s==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):l=t.__e=Pr(n.__e,t,n,r,o,s,a,p,c);return(u=_.diffed)&&u(t),128&t.__u?void 0:l}function Oe(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(Oe)}function Mr(e,t,n){for(var r=0;r<n.length;r++)Ne(nr,n++r,n++r);_.__c&&_.__c(t,e),e.some(function(o){try{e=o.__h,o.__h=[],e.some(function(s){s.call(o)})}catch(s){_.__e(s,o.__v)}})}function at(e){return typeof e!="object"||e==null||e.__b&&e.__b>0?e:ae(e)?e.map(at):N({},e)}function Pr(e,t,n,r,o,s,a,l,p){var c,u,i,f,d,m,b,y=n.props,h=t.props,g=t.type;if(g=="svg"?o="http://www.w3.org/2000/svg":g=="math"?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),s!=null){for(c=0;c<s.length;c++)if((d=s[c])&&"setAttribute"in d==!!g&&(g?d.localName==g:d.nodeType==3)){e=d,sc=null;break}}if(e==null){if(g==null)return document.createTextNode(h);e=document.createElementNS(o,g,h.is&&h),l&&(_.__m&&_.__m(t,s),l=!1),s=null}if(g==null)y===h||l&&e.data==h||(e.data=h);else{if(s=s&&Re.call(e.childNodes),y=n.props||Pe,!l&&s!=null)for(y={},c=0;c<e.attributes.length;c++)y[(d=e.attributesc).name]=d.value;for(c in y)if(d=yc,c!="children"){if(c=="dangerouslySetInnerHTML")i=d;else if(!(c in h)){if(c=="value"&&"defaultValue"in h||c=="checked"&&"defaultChecked"in h)continue;me(e,c,null,d,o)}}for(c in h)d=hc,c=="children"?f=d:c=="dangerouslySetInnerHTML"?u=d:c=="value"?m=d:c=="checked"?b=d:l&&typeof d!="function"||yc===d||me(e,c,d,yc,o);if(u)l||i&&(u.__html==i.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(i&&(e.innerHTML=""),ot(t.type=="template"?e.content:e,ae(f)?f:f,t,n,r,g=="foreignObject"?"http://www.w3.org/1999/xhtml":o,s,a,s?s[0]:n.__k&&V(n,0),l,p),s!=null)for(c=s.length;c--;)Ae(s[c]);l||(c="value",g=="progress"&&m==null?e.removeAttribute("value"):m!=null&&(m!==e[c]||g=="progress"&&!m||g=="option"&&m!=y[c])&&me(e,c,m,y[c],o),c="checked",b!=null&&b!=e[c]&&me(e,c,b,y[c],o))}return e}function Ne(e,t,n){try{if(typeof e=="function"){var r=typeof e.__u=="function";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(o){_.__e(o,n)}}function ct(e,t,n){var r,o;if(_.unmount&&_.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Ne(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(s){_.__e(s,t)}r.base=r.__P=null}if(r=e.__k)for(o=0;o<r.length;o++)ro&&ct(ro,t,n||typeof e.type!="function");n||Ae(e.__e),e.__c=e.__=e.__e=void 0}function Or(e,t,n){return this.constructor(e,n)}Re=nt.slice,_={__e:function(e,t,n,r){for(var o,s,a;t=t.__;)if((o=t.__c)&&!o.__)try{if((s=o.constructor)&&s.getDerivedStateFromError!=null&&(o.setState(s.getDerivedStateFromError(e)),a=o.__d),o.componentDidCatch!=null&&(o.componentDidCatch(e,r||{}),a=o.__d),a)return o.__E=o}catch(l){e=l}throw e}},Ge=0,Er=function(e){return e!=null&&e.constructor==null},P.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=N({},this.state),typeof e=="function"&&(e=e(N({},n),this.props)),e&&N(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Ye(this))},P.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Ye(this))},P.prototype.render=S,W=[],Ze=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,et=function(e,t){return e.__v.__b-t.__v.__b},ge.__r=0,tt=/(PointerCapture)$|Capture$/i,Ie=0,Te=Je(!1),Me=Je(!0),Sr=0;var lt,O,He,ut;var yt=[],k=_,pt=k.__b,dt=k.__r,ft=k.diffed,mt=k.__c,ht=k.unmount,gt=k.__;function Rr(){for(var e;e=yt.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(_e),e.__H.__h.forEach($e),e.__H.__h=[]}catch(t){e.__H.__h=[],k.__e(t,e.__v)}}k.__b=function(e){O=null,pt&&pt(e)},k.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),gt&&gt(e,t)},k.__r=function(e){dt&&dt(e),lt=0;var t=(O=e.__c).__H;t&&(He===O?(t.__h=[],O.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.forEach(_e),t.__h.forEach($e),t.__h=[],lt=0)),He=O},k.diffed=function(e){ft&&ft(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(yt.push(t)!==1&&ut===k.requestAnimationFrame||((ut=k.requestAnimationFrame)||Ir)(Rr)),t.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),He=O=null},k.__c=function(e,t){t.some(function(n){try{n.__h.forEach(_e),n.__h=n.__h.filter(function(r){return!r.__||$e(r)})}catch(r){t.some(function(o){o.__h&&(o.__h=[])}),t=[],k.__e(r,n.__v)}}),mt&&mt(e,t)},k.unmount=function(e){ht&&ht(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{_e(r)}catch(o){t=o}}),n.__H=void 0,t&&k.__e(t,n.__v))};var _t=typeof requestAnimationFrame=="function";function Ir(e){var t,n=function(){clearTimeout(r),_t&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);_t&&(t=requestAnimationFrame(n))}function _e(e){var t=O,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),O=t}function $e(e){var t=O;e.__c=e.__(),O=t}function Hr(e,t){for(var n in t)en=tn;return e}function bt(e,t){for(var n in e)if(n!=="__source"&&!(n in t))return!0;for(var r in t)if(r!=="__source"&&er!==tr)return!0;return!1}function xt(e,t){this.props=e,this.context=t}(xt.prototype=new P).isPureReactComponent=!0,xt.prototype.shouldComponentUpdate=function(e,t){return bt(this.props,e)||bt(this.state,t)};var vt=_.__b;_.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),vt&&vt(e)};var ts=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;var $r=_.__e;_.__e=function(e,t,n,r){if(e.then){for(var o,s=t;s=s.__;)if((o=s.__c)&&o.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),o.__c(e,t)}$r(e,t,n,r)};var kt=_.unmount;function Ot(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(r){typeof r.__c=="function"&&r.__c()}),e.__c.__H=null),(e=Hr({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(r){return Ot(r,t,n)})),e}function Rt(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return Rt(r,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function De(){this.__u=0,this.o=null,this.__b=null}function It(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function ye(){this.i=null,this.l=null}_.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),kt&&kt(e)},(De.prototype=new P).__c=function(e,t){var n=t.__c,r=this;r.o==null&&(r.o=[]),r.o.push(n);var o=It(r.__v),s=!1,a=function(){s||(s=!0,n.__R=null,o?o(l):l())};n.__R=a;var l=function(){if(!--r.__u){if(r.state.__a){var p=r.state.__a;r.__v.__k0=Rt(p,p.__c.__P,p.__c.__O)}var c;for(r.setState({__a:r.__b=null});c=r.o.pop();)c.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k0}),e.then(a,a)},De.prototype.componentWillUnmount=function(){this.o=[]},De.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),r=this.__v.__k0.__c;this.__v.__k0=Ot(this.__b,n,r.__O=r.__P)}this.__b=null}var o=t.__a&&ce(S,null,e.fallback);return o&&(o.__u&=-33),ce(S,null,t.__a?null:e.children),o};var wt=function(e,t,n){if(++n1===n0&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder0!=="t"||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n1<n0)break;e.i=n=n2}};(ye.prototype=new P).__a=function(e){var t=this,n=It(t.__v),r=t.l.get(e);return r0++,function(o){var s=function(){t.props.revealOrder?(r.push(o),wt(t,e,r)):o()};n?n(s):s()}},ye.prototype.render=function(e){this.i=null,this.l=new Map;var t=Y(e.children);e.revealOrder&&e.revealOrder0==="b"&&t.reverse();for(var n=t.length;n--;)this.l.set(tn,this.i=1,0,this.i);return e.children},ye.prototype.componentDidUpdate=ye.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){wt(e,n,t)})};var Dr=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,jr=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))A-Z/,Ur=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Fr=/A-Z0-9/g,Br=typeof document<"u",Wr=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};P.prototype.isReactComponent={},"componentWillMount","componentWillReceiveProps","componentWillUpdate".forEach(function(e){Object.defineProperty(P.prototype,e,{configurable:!0,get:function(){return this"UNSAFE_"+e},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var Et=_.event;function Kr(){}function zr(){return this.cancelBubble}function qr(){return this.defaultPrevented}_.event=function(e){return Et&&(e=Et(e)),e.persist=Kr,e.isPropagationStopped=zr,e.isDefaultPrevented=qr,e.nativeEvent=e};var At,Qr={enumerable:!1,configurable:!0,get:function(){return this.class}},St=_.vnode;_.vnode=function(e){typeof e.type=="string"&&function(t){var n=t.props,r=t.type,o={},s=r.indexOf("-")===-1;for(var a in n){var l=na;if(!(a==="value"&&"defaultValue"in n&&l==null||Br&&a==="children"&&r==="noscript"||a==="class"||a==="className")){var p=a.toLowerCase();a==="defaultValue"&&"value"in n&&n.value==null?a="value":a==="download"&&l===!0?l="":p==="translate"&&l==="no"?l=!1:p0==="o"&&p1==="n"?p==="ondoubleclick"?a="ondblclick":p!=="onchange"||r!=="input"&&r!=="textarea"||Wr(n.type)?p==="onfocus"?a="onfocusin":p==="onblur"?a="onfocusout":Ur.test(a)&&(a=p):p=a="oninput":s&&jr.test(a)?a=a.replace(Fr,"-$&").toLowerCase():l===null&&(l=void 0),p==="oninput"&&oa=p&&(a="oninputCapture"),oa=l}}r=="select"&&o.multiple&&Array.isArray(o.value)&&(o.value=Y(n.children).forEach(function(c){c.props.selected=o.value.indexOf(c.props.value)!=-1})),r=="select"&&o.defaultValue!=null&&(o.value=Y(n.children).forEach(function(c){c.props.selected=o.multiple?o.defaultValue.indexOf(c.props.value)!=-1:o.defaultValue==c.props.value})),n.class&&!n.className?(o.class=n.class,Object.defineProperty(o,"className",Qr)):(n.className&&!n.class||n.class&&n.className)&&(o.class=o.className=n.className),t.props=o}(e),e.$$typeof=Dr,St&&St(e)};var Lt=_.__r;_.__r=function(e){Lt&&Lt(e),At=e.__c};var Ct=_.diffed;_.diffed=function(e){Ct&&Ct(e);var t=e.props,n=e.__e;n!=null&&e.type==="textarea"&&"value"in t&&t.value!==n.value&&(n.value=t.value==null?"":t.value),At=null};var Nt=!1;scrapbox.addListener("lines:changed",()=>Nt=!1);scrapbox.addListener("layout:changed",()=>Nt=!1);var Ht=(e,t)=>{if(!(e instanceof HTMLTextAreaElement))throw new TypeError("${t}" must be HTMLTextAreaElement but actual is "${e}")};var K=()=>{let e=document.getElementById("text-input");if(e)return Ht(e,"textarea#text-input"),e};var Ys=2**31-1;var jt=e=>{if(e===0)return;let t={};return e&1&&(t.capture=!0),e&2&&(t.once=!0),e&4&&(t.passive=!0),t};var oo=new Map;scrapbox.on("layout:changed",()=>{let e=K();if(e)for(lett,nof oo)for(letr,oof n)for(let s of o)e.addEventListener(t,r,jt(s))});var La=Array.isArray;var C=!1;var G=e=>Object.fromEntries(...Object.entries(console).map((t,n)=>{if(typeof n!="function")returnt,n;switch(t){case"warn":case"error":return[t,(...r)=>n(%c${e},je,...r)];case"log":case"info":case"debug":return[t,(...r)=>{C!==!0&&(!C||!C.has(e))||n(%c${e},je,...r)}];case"assert":return[t,(r,...o)=>{C!==!0&&(!C||!C.has(e))||n(r,%c${e},je,...o)}];case"time":case"timeEnd":return[t,r=>{C!==!0&&(!C||!C.has(e))||n(${e} ${r})}];default:returnt,(...r)=>{if(!(C!==!0&&(!C||!C.has(e))))return n(...r)}}})),je="color: gray";var Nc=G("scrapbox-select-suggestion:useLifecycle.ts");var Dc=Symbol("Comlink.proxy"),jc=Symbol("Comlink.endpoint"),io=Symbol("Comlink.releaseProxy"),Uc=Symbol("Comlink.finalizer"),Fc=Symbol("Comlink.thrown");function ao(e){return e.constructor.name==="MessagePort"}function co(e){ao(e)&&e.close()}function lo(e){return uo(e,new Map,{type:"RELEASE"}).then(()=>{co(e)})}var Ut=new WeakMap,Bc="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{let t=(Ut.get(e)||0)-1;Ut.set(e,t),t===0&&lo(e)});function uo(e,t,n,r){return new Promise(o=>{let s=po();t.set(s,o),e.start&&e.start(),e.postMessage(Object.assign({id:s},n),r)})}function po(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var Gc=G("scrapbox-select-suggestion:cancelableSearch.ts");var be="SharedWorker"in globalThis;var Nl=G("scrapbox-select-suggestion:useSearch.ts");var Ue={};Gt(Ue,{default:()=>Wt});var ho=Object.create,Bt=Object.defineProperty,go=Object.getOwnPropertyDescriptor,_o=Object.getOwnPropertyNames,yo=Object.getPrototypeOf,bo=Object.prototype.hasOwnProperty,xo=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),vo=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of _o(t))!bo.call(e,o)&&o!==n&&Bt(e,o,{get:()=>to,enumerable:!(r=go(t,o))||r.enumerable});return e},ko=(e,t,n)=>(n=e!=null?ho(yo(e)):{},vo(t||!e||!e.__esModule?Bt(n,"default",{value:e,enumerable:!0}):n,e)),wo=xo((e,t)=>{(function(){var n;n=function(){var r,o,s;r=2147483648,s=256,o=r,0,0,0,a.prototype.isupper=function(l){return l>=65&&l<=90},a.prototype.islower=function(l){return l>=97&&l<=122},a.prototype.tolower=function(l){return this.isupper(l)?l+32:l},a.prototype.toupper=function(l){return this.islower(l)?l-32:l};function a(l){var p,c,u,i,f,d;for(this.source=l,this.shiftpat=[],this.epsilon=0,this.acceptpat=0,c=r,p=u=0;0<=s?u<s:u>s;p=0<=s?++u:--u)this.shiftpatp=0;for(d=this.unpack(this.source),i=0,f=d.length;i<f;i++)p=di,p===32?this.epsilon|=c:(this.shiftpatp|=c,this.shiftpatthis.toupper(p)|=c,this.shiftpatthis.tolower(p)|=c,c>>>=1);return this.acceptpat=c,this}return a.prototype.state=function(l,p){var c,u,i,f,d,m,b,y,h;for(l==null&&(l=o),p==null&&(p=""),u=l0,i=l1,f=l2,d=l3,h=this.unpack(p),b=0,y=h.length;b<y;b++)c=hb,m=this.shiftpatc,d=d&this.epsilon|(d&m)>>>1|f>>>1|f,f=f&this.epsilon|(f&m)>>>1|i>>>1|i,i=i&this.epsilon|(i&m)>>>1|u>>>1|u,u=u&this.epsilon|(u&m)>>>1,i|=u>>>1,f|=i>>>1,d|=f>>>1;returnu,i,f,d},a.prototype.match=function(l,p){var c;return p==null&&(p=0),c=this.state(o,l),p<o.length||(p=o.length-1),(cp&this.acceptpat)!==0},a.prototype.unpack=function(l){var p,c,u,i,f,d;for(p=[],d=l.split(""),i=0,f=d.length;i<f;i++)c=di,u=c.charCodeAt(0),u>255&&p.push((u&65280)>>>8),p.push(u&255);return p},a}(),typeof t<"u"&&t!==null&&t.exports!=null?t.exports=n:typeof window<"u"&&window!==null&&(window.Asearch=n)}).call(e)}),Ft=ko(wo()),Wt=Ft.default??Ft;var Z=e=>{let t=r=>typeof r.default<"u"?r.default:r,n=r=>Object.assign({__esModule:!0},r);switch(e){case"asearch":return t(Ue);default:return console.error('module "'+e+'" not found'),null}},Eo=Object.create,zt=Object.defineProperty,So=Object.getOwnPropertyDescriptor,Lo=Object.getOwnPropertyNames,Co=Object.getPrototypeOf,To=Object.prototype.hasOwnProperty,Mo=(e=>typeof Z<"u"?Z:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof Z<"u"?Z:t)n}):e)(function(e){if(typeof Z<"u")return Z.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),xe=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Po=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Lo(t))!To.call(e,o)&&o!==n&&zt(e,o,{get:()=>to,enumerable:!(r=So(t,o))||r.enumerable});return e},Oo=(e,t,n)=>(n=e!=null?Eo(Co(e)):{},Po(t||!e||!e.__esModule?zt(n,"default",{value:e,enumerable:!0}):n,e)),qt=xe((e,t)=>{var n;n=function(){function r(o){this.s=o,this.a=o.split(""),this.p=0,this.t="",this.u=""}return r.prototype.gettoken=function(){if(this.u!=="")return this.t=this.u,this.u="",this.t;if(this.p>=this.a.length)return this.t="","";if(this.t=this.athis.p,this.t.match(/^[\(\|\)\*\+\?\\]$/))return this.p+=1,this.t;if(this.t==="\\")return this.t=this.a++this.p,this.t==="n"&&(this.t=`
),this.t==="t"&&(this.t=" "),this.p+=1,this.t;for(this.p+=1;this.p<this.a.length&&!this.a[this.p].match(/^[\(\|\)\*\+\?\[\]\\]$/);)this.t+=this.a[this.p++];return this.t},r.prototype.ungettoken=function(){return this.u===""?this.u=this.t:console.log("Can't ungettoken()")},r.prototype.nexttoken=function(){return this.t},r}(),t.exports=n}),Qt=xe((e,t)=>{var n,r;r=function(){function o(s,a){this.pat=s,this.dest=a}return o.prototype.str=function(){return this.pat.split(/\t/)[0]},o.prototype.arg=function(){var s;return s=this.pat.match(/^(.*)\t(.*)$/),s?s[2]:this.pat},o}(),n=function(){o.id=1,o.nodes={};function o(){this.id=o.id,this.accept=null,this.trans=[],o.nodes[o.id++]=this,this.pars=[]}return o.prototype.addTrans=function(s,a){var l;return l=new r(s,a),this.trans.push(l)},o.node=function(s){return o.nodes[s]},o}(),t.exports=n}),Ro=xe((e,t)=>{var n,r,o;n=Qt(),o=qt(),r=function(){function s(){}return s.prototype.regexp=function(a,l){var p,c,u,i,f,d;for(l==null&&(l=!1),d=new n,p=new n,l&&(this.pars=[],this.parno=0,this.ruleid=0),d.pars=this.pars,p.pars=this.pars,i=this.regcat(a),c=i[0],u=i[1],d.addTrans("",c),l&&(u.accept=this.ruleid),u.addTrans("",p);a.gettoken()==="|"&&a.nexttoken()!=="";)l&&(this.pars=[],this.parno=0,this.ruleid+=1),f=this.regcat(a),c=f[0],u=f[1],d.addTrans("",c),l&&(u.accept=this.ruleid),u.addTrans("",p);return a.ungettoken(),[d,p]},s.prototype.regcat=function(a){var l,p,c,u,i,f;for(u=this.regfactor(a),f=u[0],l=u[1];!a.gettoken().match(/^[\)\]\|]$/)&&a.nexttoken()!=="";)a.ungettoken(),i=this.regfactor(a),p=i[0],c=i[1],l.addTrans("",p),l=c;return a.ungettoken(),[f,l]},s.prototype.regfactor=function(a){var l,p,c,u,i;return c=this.regterm(a),u=c[0],l=c[1],i=a.gettoken(),i.match(/^[\?]$/)?u.addTrans("",l):i.match(/^[\+]$/)?l.addTrans("",u):i.match(/^[\*]$/)?(p=new n,u.addTrans("",l),l.addTrans("",p),p.addTrans("",u)):a.ungettoken(),[u,l]},s.prototype.regterm=function(a){var l,p,c,u,i,f;return f=a.gettoken(),f==="("?(this.parno+=1,this.pars.push(this.parno),u=this.regexp(a),p=u[0],c=u[1],p.pars=this.pars.slice(0),f=a.gettoken(),f===")"?(this.pars.pop(),c.pars=this.pars.slice(0),[p,c]):(console.log("missing )"),null)):(i=new n,i.pars=this.pars.slice(0),l=new n,l.pars=this.pars.slice(0),i.addTrans(f,l),[i,l])},s}(),t.exports=r}),Io=xe((e,t)=>{var n,r,o,s,a,l;l=qt(),a=Ro(),s=Qt(),n=Mo("asearch"),r=function(){function p(c,u,i,f,d){this.id=c,this.state=u??[],this.s=i??"",this.substrings=f??[],this.accept=d??!1}return p}(),o=function(){function p(c,u){c==null&&(c=""),u==null&&(u=""),this.s=[c],this.commands=[u],this.par=0}return p.prototype.add=function(c,u){return this.s[0]===""?this.s=[c]:this.s.push(c),this.commands[0]===""?this.commands=[u]:this.commands.push(u)},p.prototype.delete=function(){return this.s.pop,this.commands.pop},p.prototype.filter=function(c,u,i){var f,d,m,b,y,h,g,L,E,R,D,ee,B,I,T,w,M,ue,ve,pe,de,ke,te,ne,Yt,re,we,Ee,Se,oe,se,z,j,fe,A,Le,Be,q;for(u==null&&(u=null),this.maxambig=i??2,z=[[],[],[]],Yt=c.split("").map(function(Xt){return Xt.toLowerCase()}),this.asearch=new n(c),this.regexp=new a,this.scanner=new l(this.s.join("|")),we=this.regexp.regexp(this.scanner,!0),Be=we[0],b=we[1],M=[],w=[{},{},{}],h={},T=[],T[0]=new r(Be.id,this.asearch.state()),M[0]=T,I=L=0;L<=1e4;I=++L){for(T=M[I],de=[],E=0,D=T.length;E<D;E++)if(y=T[E],fe=s.node(y.id),T.length*fe.trans.length<1e5)for(Ee=fe.trans,R=0,ee=Ee.length;R<ee;R++){for(q=Ee[R],A=y.substrings.slice(0),Se=fe.pars,pe=0,B=Se.length;pe<B;pe++)g=Se[pe],typeof A[g-1]>"u"&&(A[g-1]=""),A[g-1]=A[g-1]+q.arg();if(ke=this.asearch.state(y.state,q.str()),j=y.s+q.str(),f=q.dest.accept,de.push(new r(q.dest.id,ke,j,A,f)),f!==null){for(d=te=0,oe=this.maxambig;0<=oe?te<=oe:te>=oe;d=0<=oe?++te:--te)if((u&&!h[j]||!u&&!w[d][j])&&ke[d]&this.asearch.acceptpat){if(w[d][j]=!0,h[j]=!0,Le=A.length,ve=[],Le>0){for(ne=[],g=re=0,se=Le;0<=se?re<se:re>se;g=0<=se?++re:--re)ne.push("(.*)");ne=ne.join(" "),ve=A.join(" ").match(ne)}for(m=this.commands[f],m||(m="");ue=m.match(/^(.*)(\$(\d+))(.*)$/);)m=""+ue[1]+ve[ue[3]]+ue[4];u?u([j].concat(A),m):z[d].push([j,m])}}}if(de.length===0||(M.push(de),z[0].length>100))break}return[z[0],z[1],z[2]]},p}(),String.prototype.expand=function(p,c,u){var i,f,d,m,b,y,h;if(p==null&&(p=" "),c==null&&(c=null),u==null&&(u=0),i=new o,i.add(this,""),h=[],c)return i.filter(p,c);for(m=i.filter(p),b=m[0].length>0?m[0]:m[1].length>0?m[1]:m[2],f=0,d=b.length;f<d;f++)y=b[f],h.push(y[0]);return h},t.exports=o}),Kt=Oo(Io()),Fe=Kt.default??Kt;var Ao=e=>{let t=new Fe(e);try{return[...new Set(t.filter(" ").flatMap(n=>n.map(([r])=>r)))]}catch(n){if(n instanceof TypeError)return[];throw n}},Vt=/^\s*\[(^\n+)\]/,No=e=>{let t=e.match(Vt);return t===null?e:\[${t[1]}]\` ${Ao(t[1].replace(/[\[\]]/g,"")).flatMap(n=>n!==""?[(${n})]:[]).join(" ")}};scrapbox.PopupMenu.addButton({title:e=>e.split(`
).some(t=>Vt.test(t.trim()))?"正規表現を展開":"",onClick:e=>e.split(
).map(No).join(
`)});scrapbox.TimeStamp.addFormat("]YYYY/MM/DD[");
/*! Bundled license information:
comlink/dist/esm/comlink.mjs:
(**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: Apache-2.0
*)
*/